Bug 1184500 - Improve handling of index names in MAR files. r=rstrong, a=lmandel
authorStephen Pohl <spohl.mozilla.bugs@gmail.com>
Sat, 18 Jul 2015 18:42:15 -0700
changeset 275387 b654784a57e25d72c00faa180c768279616d2e04
parent 275386 01fff103d1fcc62591874c5666da4d5477b58bb9
child 275388 c8499fa138a9b7eac6b03d4509302a8a05fef5ac
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong, lmandel
bugs1184500
milestone40.0
Bug 1184500 - Improve handling of index names in MAR files. r=rstrong, a=lmandel
modules/libmar/src/mar_read.c
--- a/modules/libmar/src/mar_read.c
+++ b/modules/libmar/src/mar_read.c
@@ -91,16 +91,20 @@ static int mar_consume_index(MarFile *ma
   name = *buf;
   /* find namelen; must take care not to read beyond buf_end */
   while (**buf) {
     if (*buf == buf_end)
       return -1;
     ++(*buf);
   }
   namelen = (*buf - name);
+  /* must ensure that namelen is valid */
+  if (namelen < 0) {
+    return -1;
+  }
   /* consume null byte */
   if (*buf == buf_end)
     return -1;
   ++(*buf);
 
   return mar_insert_item(mar, name, namelen, offset, length, flags);
 }