2016-08-01 23:30:52 +02:00
|
|
|
Follow-up upstream fix for CVE-2015-1283 to not rely on undefined
|
|
|
|
behavior.
|
2016-05-18 19:26:17 +02:00
|
|
|
|
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:
|
2016-05-18 19:26:17 +02:00
|
|
|
|
|
|
|
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 ++++--
|
2016-05-18 19:26:17 +02:00
|
|
|
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
|
2016-05-18 19:26:17 +02:00
|
|
|
--- 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)
|
2016-05-18 19:26:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2016-05-18 19:26:17 +02:00
|
|
|
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-05-18 19:26:17 +02:00
|
|
|
--
|
2016-08-01 23:30:52 +02:00
|
|
|
2.8.3
|
2016-05-18 19:26:17 +02:00
|
|
|
|