Show More
@@ -38,6 +38,7 b' typedef struct {' | |||||
38 | #define MANIFEST_OOM -1 |
|
38 | #define MANIFEST_OOM -1 | |
39 | #define MANIFEST_NOT_SORTED -2 |
|
39 | #define MANIFEST_NOT_SORTED -2 | |
40 | #define MANIFEST_MALFORMED -3 |
|
40 | #define MANIFEST_MALFORMED -3 | |
|
41 | #define MANIFEST_BOGUS_FILENAME -4 | |||
41 |
|
42 | |||
42 | /* get the length of the path for a line */ |
|
43 | /* get the length of the path for a line */ | |
43 | static size_t pathlen(line *l) |
|
44 | static size_t pathlen(line *l) | |
@@ -115,7 +116,13 b' static int find_lines(lazymanifest *self' | |||||
115 | char *prev = NULL; |
|
116 | char *prev = NULL; | |
116 | while (len > 0) { |
|
117 | while (len > 0) { | |
117 | line *l; |
|
118 | line *l; | |
118 | char *next = memchr(data, '\n', len); |
|
119 | char *next; | |
|
120 | if (*data == '\0') { | |||
|
121 | /* It's implausible there's no filename, don't | |||
|
122 | * even bother looking for the newline. */ | |||
|
123 | return MANIFEST_BOGUS_FILENAME; | |||
|
124 | } | |||
|
125 | next = memchr(data, '\n', len); | |||
119 | if (!next) { |
|
126 | if (!next) { | |
120 | return MANIFEST_MALFORMED; |
|
127 | return MANIFEST_MALFORMED; | |
121 | } |
|
128 | } | |
@@ -190,6 +197,11 b' static int lazymanifest_init(lazymanifes' | |||||
190 | PyErr_Format(PyExc_ValueError, |
|
197 | PyErr_Format(PyExc_ValueError, | |
191 | "Manifest did not end in a newline."); |
|
198 | "Manifest did not end in a newline."); | |
192 | break; |
|
199 | break; | |
|
200 | case MANIFEST_BOGUS_FILENAME: | |||
|
201 | PyErr_Format( | |||
|
202 | PyExc_ValueError, | |||
|
203 | "Manifest had an entry with a zero-length filename."); | |||
|
204 | break; | |||
193 | default: |
|
205 | default: | |
194 | PyErr_Format(PyExc_ValueError, |
|
206 | PyErr_Format(PyExc_ValueError, | |
195 | "Unknown problem parsing manifest."); |
|
207 | "Unknown problem parsing manifest."); |
@@ -4,6 +4,7 b' import binascii' | |||||
4 | import itertools |
|
4 | import itertools | |
5 | import silenttestrunner |
|
5 | import silenttestrunner | |
6 | import unittest |
|
6 | import unittest | |
|
7 | import zlib | |||
7 |
|
8 | |||
8 | from mercurial import ( |
|
9 | from mercurial import ( | |
9 | manifest as manifestmod, |
|
10 | manifest as manifestmod, | |
@@ -397,6 +398,29 b' class testmanifestdict(unittest.TestCase' | |||||
397 | def parsemanifest(self, text): |
|
398 | def parsemanifest(self, text): | |
398 | return manifestmod.manifestdict(text) |
|
399 | return manifestmod.manifestdict(text) | |
399 |
|
400 | |||
|
401 | def testObviouslyBogusManifest(self): | |||
|
402 | # This is a 163k manifest that came from oss-fuzz. It was a | |||
|
403 | # timeout there, but when run normally it doesn't seem to | |||
|
404 | # present any particular slowness. | |||
|
405 | data = zlib.decompress( | |||
|
406 | 'x\x9c\xed\xce;\n\x83\x00\x10\x04\xd0\x8deNa\x93~\xf1\x03\xc9q\xf4' | |||
|
407 | '\x14\xeaU\xbdB\xda\xd4\xe6Cj\xc1FA\xde+\x86\xe9f\xa2\xfci\xbb\xfb' | |||
|
408 | '\xa3\xef\xea\xba\xca\x7fk\x86q\x9a\xc6\xc8\xcc&\xb3\xcf\xf8\xb8|#' | |||
|
409 | '\x8a9\x00\xd8\xe6v\xf4\x01N\xe1\n\x00\x00\x00\x00\x00\x00\x00\x00' | |||
|
410 | '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | |||
|
411 | '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | |||
|
412 | '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | |||
|
413 | '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | |||
|
414 | '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | |||
|
415 | '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | |||
|
416 | '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | |||
|
417 | '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | |||
|
418 | '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | |||
|
419 | '\x00\x00\xc0\x8aey\x1d}\x01\xd8\xe0\xb9\xf3\xde\x1b\xcf\x17' | |||
|
420 | '\xac\xbe') | |||
|
421 | with self.assertRaises(ValueError): | |||
|
422 | self.parsemanifest(data) | |||
|
423 | ||||
400 | class testtreemanifest(unittest.TestCase, basemanifesttests): |
|
424 | class testtreemanifest(unittest.TestCase, basemanifesttests): | |
401 | def parsemanifest(self, text): |
|
425 | def parsemanifest(self, text): | |
402 | return manifestmod.treemanifest(b'', text) |
|
426 | return manifestmod.treemanifest(b'', text) |
General Comments 0
You need to be logged in to leave comments.
Login now