##// END OF EJS Templates
mpatch: protect against underflow in mpatch_apply (SEC)...
Augie Fackler -
r38246:1acfc35d stable
parent child Browse files
Show More
@@ -248,7 +248,7 b' int mpatch_apply(char *buf, const char *'
248 char *p = buf;
248 char *p = buf;
249
249
250 while (f != l->tail) {
250 while (f != l->tail) {
251 if (f->start < last || f->end > len) {
251 if (f->start < last || f->end > len || last < 0) {
252 return MPATCH_ERR_INVALID_PATCH;
252 return MPATCH_ERR_INVALID_PATCH;
253 }
253 }
254 memcpy(p, orig + last, f->start - last);
254 memcpy(p, orig + last, f->start - last);
@@ -258,6 +258,9 b' int mpatch_apply(char *buf, const char *'
258 p += f->len;
258 p += f->len;
259 f++;
259 f++;
260 }
260 }
261 if (last < 0) {
262 return MPATCH_ERR_INVALID_PATCH;
263 }
261 memcpy(p, orig + last, len - last);
264 memcpy(p, orig + last, len - last);
262 return 0;
265 return 0;
263 }
266 }
General Comments 0
You need to be logged in to leave comments. Login now