b=810478; fix missing null termination of buffer that's used via str* functions later on; r=glandium
authorVladimir Vukicevic <vladimir@pobox.com>
Tue, 13 Nov 2012 14:21:08 -0500
changeset 113117 419e74e5f2d729dd9ea29c3da39ea5f3a03fe7fc
parent 113116 1c065e36b49d3c7150e13ca6d8df9c9b42daceaf
child 113118 a40e1319765636fcc29c0826b8029436b01380a5
push id23853
push userryanvm@gmail.com
push dateTue, 13 Nov 2012 23:58:05 +0000
treeherdermozilla-central@b8d6333847e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs810478
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
b=810478; fix missing null termination of buffer that's used via str* functions later on; r=glandium
mozglue/android/APKOpen.cpp
--- a/mozglue/android/APKOpen.cpp
+++ b/mozglue/android/APKOpen.cpp
@@ -638,26 +638,30 @@ static void * mozload(const char * path,
 #ifdef MOZ_CRASHREPORTER
 static void *
 extractBuf(const char * path, Zip *zip)
 {
   Zip::Stream s;
   if (!zip->GetStream(path, &s))
     return NULL;
 
-  void * buf = malloc(s.GetUncompressedSize());
+  // allocate space for a trailing null byte
+  void * buf = malloc(s.GetUncompressedSize() + 1);
   if (buf == (void *)-1) {
     __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't alloc decompression buffer for %s", path);
     return NULL;
   }
   if (s.GetType() == Zip::Stream::DEFLATE)
     extractLib(s, buf);
   else
     memcpy(buf, s.GetBuffer(), s.GetUncompressedSize());
 
+  // null terminate it
+  ((unsigned char*) buf)[s.GetUncompressedSize()] = 0;
+
   return buf;
 }
 #endif
 
 static int mapping_count = 0;
 static char *file_ids = NULL;
 
 #define MAX_MAPPING_INFO 32