Show More
@@ -404,7 +404,8 PyMODINIT_FUNC PyInit_mpatch(void) | |||
|
404 | 404 | if (m == NULL) |
|
405 | 405 | return NULL; |
|
406 | 406 | |
|
407 |
mpatch_Error = PyErr_NewException("mpatch.mpatchError", |
|
|
407 | mpatch_Error = PyErr_NewException("mercurial.mpatch.mpatchError", | |
|
408 | NULL, NULL); | |
|
408 | 409 | Py_INCREF(mpatch_Error); |
|
409 | 410 | PyModule_AddObject(m, "mpatchError", mpatch_Error); |
|
410 | 411 | |
@@ -415,6 +416,7 PyMODINIT_FUNC | |||
|
415 | 416 | initmpatch(void) |
|
416 | 417 | { |
|
417 | 418 | Py_InitModule3("mpatch", methods, mpatch_doc); |
|
418 |
mpatch_Error = PyErr_NewException("mpatch.mpatchError", |
|
|
419 | mpatch_Error = PyErr_NewException("mercurial.mpatch.mpatchError", | |
|
420 | NULL, NULL); | |
|
419 | 421 | } |
|
420 | 422 | #endif |
@@ -12,6 +12,10 import struct | |||
|
12 | 12 | |
|
13 | 13 | StringIO = cStringIO.StringIO |
|
14 | 14 | |
|
15 | class mpatchError(Exception): | |
|
16 | """error raised when a delta cannot be decoded | |
|
17 | """ | |
|
18 | ||
|
15 | 19 | # This attempts to apply a series of patches in time proportional to |
|
16 | 20 | # the total size of the patches, rather than patches * len(text). This |
|
17 | 21 | # means rather than shuffling strings around, we shuffle around |
@@ -84,7 +88,10 def patches(a, bins): | |||
|
84 | 88 | last = 0 |
|
85 | 89 | while pos < end: |
|
86 | 90 | m.seek(pos) |
|
91 | try: | |
|
87 | 92 | p1, p2, l = struct.unpack(">lll", m.read(12)) |
|
93 | except struct.error: | |
|
94 | raise mpatchError("patch cannot be decoded") | |
|
88 | 95 | _pull(new, frags, p1 - last) # what didn't change |
|
89 | 96 | _pull([], frags, p2 - p1) # what got deleted |
|
90 | 97 | new.append((l, pos + 12)) # what got added |
@@ -114,7 +121,7 def patchedsize(orig, delta): | |||
|
114 | 121 | outlen += length |
|
115 | 122 | |
|
116 | 123 | if bin != binend: |
|
117 |
raise |
|
|
124 | raise mpatchError("patch cannot be decoded") | |
|
118 | 125 | |
|
119 | 126 | outlen += orig - last |
|
120 | 127 | return outlen |
@@ -11,5 +11,5 Test for CVE-2016-3630 | |||
|
11 | 11 | rev offset length delta linkrev nodeid p1 p2 |
|
12 | 12 | 0 0 19 -1 2 99e0332bd498 000000000000 000000000000 |
|
13 | 13 | 1 19 12 0 3 6674f57a23d8 99e0332bd498 000000000000 |
|
14 | $ hg debugdata a.i 1 2>&1 | grep decoded | |
|
15 | mpatch.mpatchError: patch cannot be decoded | |
|
14 | $ hg debugdata a.i 1 2>&1 | egrep 'Error:.*decoded' | |
|
15 | mercurial.mpatch.mpatchError: patch cannot be decoded |
General Comments 0
You need to be logged in to leave comments.
Login now