guix-devel/gnu/packages/patches/expat-CVE-2015-1283-refix.p...

40 lines
1.3 KiB
Diff
Raw Normal View History

2016-08-01 23:30:52 +02:00
Follow-up upstream fix for CVE-2015-1283 to not rely on undefined
behavior.
2016-08-01 23:30:52 +02:00
Adapted from a patch from Debian (found in Debian package version
2.1.0-6+deb8u2) to apply to upstream code:
https://sources.debian.net/src/expat/2.1.0-6%2Bdeb8u2/debian/patches/CVE-2015-1283-refix.patch/
---
2016-08-01 23:30:52 +02:00
lib/xmlparse.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
2016-08-01 23:30:52 +02:00
index 0f6f4cd..5c70c17 100644
--- a/lib/xmlparse.c
+++ b/lib/xmlparse.c
2016-08-01 23:30:52 +02:00
@@ -1727,7 +1727,8 @@ XML_GetBuffer(XML_Parser parser, int len)
}
if (len > bufferLim - bufferEnd) {
- int neededSize = len + (int)(bufferEnd - bufferPtr);
+ /* Do not invoke signed arithmetic overflow: */
+ int neededSize = (int) ((unsigned)len + (unsigned)(bufferEnd - bufferPtr));
if (neededSize < 0) {
errorCode = XML_ERROR_NO_MEMORY;
2016-08-01 23:30:52 +02:00
return NULL;
@@ -1759,7 +1760,8 @@ XML_GetBuffer(XML_Parser parser, int len)
if (bufferSize == 0)
bufferSize = INIT_BUFFER_SIZE;
do {
- bufferSize *= 2;
+ /* Do not invoke signed arithmetic overflow: */
+ bufferSize = (int) (2U * (unsigned) bufferSize);
} while (bufferSize < neededSize && bufferSize > 0);
2016-08-01 23:30:52 +02:00
if (bufferSize <= 0) {
errorCode = XML_ERROR_NO_MEMORY;
--
2016-08-01 23:30:52 +02:00
2.8.3