Show More
@@ -347,6 +347,11 b' static PyObject *bdiff(PyObject *self, P' | |||||
347 | if (!PyArg_ParseTuple(args, "s#s#:bdiff", &sa, &la, &sb, &lb)) |
|
347 | if (!PyArg_ParseTuple(args, "s#s#:bdiff", &sa, &la, &sb, &lb)) | |
348 | return NULL; |
|
348 | return NULL; | |
349 |
|
349 | |||
|
350 | if (la > UINT_MAX || lb > UINT_MAX) { | |||
|
351 | PyErr_SetString(PyExc_ValueError, "bdiff inputs too large"); | |||
|
352 | return NULL; | |||
|
353 | } | |||
|
354 | ||||
350 | _save = PyEval_SaveThread(); |
|
355 | _save = PyEval_SaveThread(); | |
351 | an = splitlines(sa, la, &al); |
|
356 | an = splitlines(sa, la, &al); | |
352 | bn = splitlines(sb, lb, &bl); |
|
357 | bn = splitlines(sb, lb, &bl); | |
@@ -381,18 +386,9 b' static PyObject *bdiff(PyObject *self, P' | |||||
381 | for (h = l.next; h; h = h->next) { |
|
386 | for (h = l.next; h; h = h->next) { | |
382 | if (h->a1 != la || h->b1 != lb) { |
|
387 | if (h->a1 != la || h->b1 != lb) { | |
383 | len = bl[h->b1].l - bl[lb].l; |
|
388 | len = bl[h->b1].l - bl[lb].l; | |
384 |
|
389 | putbe32((uint32_t)(al[la].l - al->l), rb); | ||
385 | #define checkputbe32(__x, __c) \ |
|
390 | putbe32((uint32_t)(al[h->a1].l - al->l), rb + 4); | |
386 | if (__x > UINT_MAX) { \ |
|
391 | putbe32((uint32_t)len, rb + 8); | |
387 | PyErr_SetString(PyExc_ValueError, \ |
|
|||
388 | "bdiff: value too large for putbe32"); \ |
|
|||
389 | goto nomem; \ |
|
|||
390 | } \ |
|
|||
391 | putbe32((uint32_t)(__x), __c); |
|
|||
392 |
|
||||
393 | checkputbe32(al[la].l - al->l, rb); |
|
|||
394 | checkputbe32(al[h->a1].l - al->l, rb + 4); |
|
|||
395 | checkputbe32(len, rb + 8); |
|
|||
396 | memcpy(rb + 12, bl[lb].l, len); |
|
392 | memcpy(rb + 12, bl[lb].l, len); | |
397 | rb += 12 + len; |
|
393 | rb += 12 + len; | |
398 | } |
|
394 | } |
General Comments 0
You need to be logged in to leave comments.
Login now