##// END OF EJS Templates
manifest: also reject obviously-too-short lines when parsing lines...
Augie Fackler -
r40636:f27f8e9e default
parent child Browse files
Show More
@@ -39,6 +39,7 b' typedef struct {'
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 #define MANIFEST_BOGUS_FILENAME -4
42 #define MANIFEST_TOO_SHORT_LINE -5
42
43
43 /* get the length of the path for a line */
44 /* get the length of the path for a line */
44 static size_t pathlen(line *l)
45 static size_t pathlen(line *l)
@@ -126,6 +127,15 b' static int find_lines(lazymanifest *self'
126 if (!next) {
127 if (!next) {
127 return MANIFEST_MALFORMED;
128 return MANIFEST_MALFORMED;
128 }
129 }
130 if ((next - data) < 22) {
131 /* We should have at least 22 bytes in a line:
132 1 byte filename
133 1 NUL
134 20 bytes of hash
135 so we can give up here.
136 */
137 return MANIFEST_TOO_SHORT_LINE;
138 }
129 next++; /* advance past newline */
139 next++; /* advance past newline */
130 if (!realloc_if_full(self)) {
140 if (!realloc_if_full(self)) {
131 return MANIFEST_OOM; /* no memory */
141 return MANIFEST_OOM; /* no memory */
@@ -202,6 +212,11 b' static int lazymanifest_init(lazymanifes'
202 PyExc_ValueError,
212 PyExc_ValueError,
203 "Manifest had an entry with a zero-length filename.");
213 "Manifest had an entry with a zero-length filename.");
204 break;
214 break;
215 case MANIFEST_TOO_SHORT_LINE:
216 PyErr_Format(
217 PyExc_ValueError,
218 "Manifest had implausibly-short line.");
219 break;
205 default:
220 default:
206 PyErr_Format(PyExc_ValueError,
221 PyErr_Format(PyExc_ValueError,
207 "Unknown problem parsing manifest.");
222 "Unknown problem parsing manifest.");
General Comments 0
You need to be logged in to leave comments. Login now