about summary refs log tree commit diff
path: root/pkgs/development/libraries/expat
diff options
context:
space:
mode:
authorJames Cook <james.cook@utoronto.ca>2015-07-27 22:36:15 -0700
committerJames Cook <james.cook@utoronto.ca>2015-07-27 22:36:15 -0700
commitfba4a950685023bc792422665b2dbe9934ebc9c6 (patch)
treee435cf25dc57ee5d8d26d4c16d23fdb5a1461070 /pkgs/development/libraries/expat
parent208bd8242d5dab6929d8651810a38f970412b010 (diff)
downloadnixlib-fba4a950685023bc792422665b2dbe9934ebc9c6.tar
nixlib-fba4a950685023bc792422665b2dbe9934ebc9c6.tar.gz
nixlib-fba4a950685023bc792422665b2dbe9934ebc9c6.tar.bz2
nixlib-fba4a950685023bc792422665b2dbe9934ebc9c6.tar.lz
nixlib-fba4a950685023bc792422665b2dbe9934ebc9c6.tar.xz
nixlib-fba4a950685023bc792422665b2dbe9934ebc9c6.tar.zst
nixlib-fba4a950685023bc792422665b2dbe9934ebc9c6.zip
expat: patch for CVE-2015-1283 from Mozilla
Diffstat (limited to 'pkgs/development/libraries/expat')
-rw-r--r--pkgs/development/libraries/expat/CVE-2015-1283.patch77
-rw-r--r--pkgs/development/libraries/expat/default.nix2
2 files changed, 79 insertions, 0 deletions
diff --git a/pkgs/development/libraries/expat/CVE-2015-1283.patch b/pkgs/development/libraries/expat/CVE-2015-1283.patch
new file mode 100644
index 000000000000..33b975912d40
--- /dev/null
+++ b/pkgs/development/libraries/expat/CVE-2015-1283.patch
@@ -0,0 +1,77 @@
+Found at https://hg.mozilla.org/releases/mozilla-esr31/rev/2f3e78643f5c on 2015-07-27.  Modified: replaced path parser/expat/lib/xmlparse.c with lib/xmlparse.c.
+diff --git a/lib/xmlparse.c b/lib/xmlparse.c
+--- a/lib/xmlparse.c
++++ b/lib/xmlparse.c
+@@ -1646,29 +1646,40 @@ XML_ParseBuffer(XML_Parser parser, int l
+   XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position);
+   positionPtr = bufferPtr;
+   return result;
+ }
+ 
+ void * XMLCALL
+ XML_GetBuffer(XML_Parser parser, int len)
+ {
++/* BEGIN MOZILLA CHANGE (sanity check len) */
++  if (len < 0) {
++    errorCode = XML_ERROR_NO_MEMORY;
++    return NULL;
++  }
++/* END MOZILLA CHANGE */
+   switch (ps_parsing) {
+   case XML_SUSPENDED:
+     errorCode = XML_ERROR_SUSPENDED;
+     return NULL;
+   case XML_FINISHED:
+     errorCode = XML_ERROR_FINISHED;
+     return NULL;
+   default: ;
+   }
+ 
+   if (len > bufferLim - bufferEnd) {
+-    /* FIXME avoid integer overflow */
+     int neededSize = len + (int)(bufferEnd - bufferPtr);
++/* BEGIN MOZILLA CHANGE (sanity check neededSize) */
++    if (neededSize < 0) {
++      errorCode = XML_ERROR_NO_MEMORY;
++      return NULL;
++    }
++/* END MOZILLA CHANGE */
+ #ifdef XML_CONTEXT_BYTES
+     int keep = (int)(bufferPtr - buffer);
+ 
+     if (keep > XML_CONTEXT_BYTES)
+       keep = XML_CONTEXT_BYTES;
+     neededSize += keep;
+ #endif  /* defined XML_CONTEXT_BYTES */
+     if (neededSize  <= bufferLim - buffer) {
+@@ -1687,17 +1698,25 @@ XML_GetBuffer(XML_Parser parser, int len
+     }
+     else {
+       char *newBuf;
+       int bufferSize = (int)(bufferLim - bufferPtr);
+       if (bufferSize == 0)
+         bufferSize = INIT_BUFFER_SIZE;
+       do {
+         bufferSize *= 2;
+-      } while (bufferSize < neededSize);
++/* BEGIN MOZILLA CHANGE (prevent infinite loop on overflow) */
++      } while (bufferSize < neededSize && bufferSize > 0);
++/* END MOZILLA CHANGE */
++/* BEGIN MOZILLA CHANGE (sanity check bufferSize) */
++      if (bufferSize <= 0) {
++        errorCode = XML_ERROR_NO_MEMORY;
++        return NULL;
++      }
++/* END MOZILLA CHANGE */
+       newBuf = (char *)MALLOC(bufferSize);
+       if (newBuf == 0) {
+         errorCode = XML_ERROR_NO_MEMORY;
+         return NULL;
+       }
+       bufferLim = newBuf + bufferSize;
+ #ifdef XML_CONTEXT_BYTES
+       if (bufferPtr) {
+
+
+
+
diff --git a/pkgs/development/libraries/expat/default.nix b/pkgs/development/libraries/expat/default.nix
index 9a49225d1723..05cfeaee4232 100644
--- a/pkgs/development/libraries/expat/default.nix
+++ b/pkgs/development/libraries/expat/default.nix
@@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "11pblz61zyxh68s5pdcbhc30ha1b2vfjd83aiwfg4vc15x3hadw2";
   };
 
+  patches = [ ./CVE-2015-1283.patch ];
+
   meta = with stdenv.lib; {
     homepage = http://www.libexpat.org/;
     description = "A stream-oriented XML parser library written in C";