gnu: Add ruby-puma.
[jackhill/guix/guix.git] / gnu / packages / patches / expat-CVE-2015-1283-refix.patch
CommitLineData
119b8398
LF
1Update previous fix for CVE-2015-1283 to not rely on undefined behavior.
2
3Copied from Debian, as found in Debian package version 2.1.0-6+deb8u2.
4
5https://sources.debian.net/src/expat/2.1.0-6%2Bdeb8u2/debian/patches/CVE-2015-1283-refix.patch/
6
7From 29a11774d8ebbafe8418b4a5ffb4cc1160b194a1 Mon Sep 17 00:00:00 2001
8From: Pascal Cuoq <cuoq@trust-in-soft.com>
9Date: Sun, 15 May 2016 09:05:46 +0200
10Subject: [PATCH] Avoid relying on undefined behavior in CVE-2015-1283 fix.
11
12---
13 expat/lib/xmlparse.c | 6 ++++--
14 1 file changed, 4 insertions(+), 2 deletions(-)
15
16diff --git a/lib/xmlparse.c b/lib/xmlparse.c
17index 13e080d..cdb12ef 100644
18--- a/lib/xmlparse.c
19+++ b/lib/xmlparse.c
20@@ -1695,7 +1695,8 @@ XML_GetBuffer(XML_Parser parser, int len
21 }
22
23 if (len > bufferLim - bufferEnd) {
24- int neededSize = len + (int)(bufferEnd - bufferPtr);
25+ /* Do not invoke signed arithmetic overflow: */
26+ int neededSize = (int) ((unsigned)len + (unsigned)(bufferEnd - bufferPtr));
27 /* BEGIN MOZILLA CHANGE (sanity check neededSize) */
28 if (neededSize < 0) {
29 errorCode = XML_ERROR_NO_MEMORY;
30@@ -1729,7 +1730,8 @@ XML_GetBuffer(XML_Parser parser, int len
31 if (bufferSize == 0)
32 bufferSize = INIT_BUFFER_SIZE;
33 do {
34- bufferSize *= 2;
35+ /* Do not invoke signed arithmetic overflow: */
36+ bufferSize = (int) (2U * (unsigned) bufferSize);
37 /* BEGIN MOZILLA CHANGE (prevent infinite loop on overflow) */
38 } while (bufferSize < neededSize && bufferSize > 0);
39 /* END MOZILLA CHANGE */
40--
412.8.2
42