Bug 1184500 - Improve handling of index names in MAR files. r=rstrong, a=2.0+
authorStephen Pohl <spohl.mozilla.bugs@gmail.com>
Sat, 18 Jul 2015 18:42:15 -0700
changeset 204939 69dcc68fad52
parent 204938 367b6867e3ff
child 204940 89f995897f40
push id860
push userryanvm@gmail.com
push dateTue, 21 Jul 2015 00:49:53 +0000
treeherdermozilla-b2g32_v2_0@69dcc68fad52 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong, 2
bugs1184500
milestone32.0
Bug 1184500 - Improve handling of index names in MAR files. r=rstrong, a=2.0+
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);
 }