(cherry picked from commit 36ce67f6dcbbc1ac6fca872b99dab9675813c10d)epel9
parent
4a4dfe850e
commit
c1929c8a1a
@ -1,41 +1,36 @@
|
||||
From 8e7c20a1af8776677d7890f30b7a180567701a49 Mon Sep 17 00:00:00 2001
|
||||
From 50f06b3efb638efb0abd95dc62dca05ae67882c2 Mon Sep 17 00:00:00 2001
|
||||
From: Nick Wellnhofer <wellnhofer@aevum.de>
|
||||
Date: Mon, 3 Aug 2020 17:30:41 +0200
|
||||
Subject: [PATCH] Fix integer overflow when comparing schema dates
|
||||
Date: Fri, 7 Aug 2020 21:54:27 +0200
|
||||
Subject: [PATCH] Fix out-of-bounds read with 'xmllint --htmlout'
|
||||
|
||||
Found by OSS-Fuzz.
|
||||
---
|
||||
xmlschemastypes.c | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
Make sure that truncated UTF-8 sequences don't cause an out-of-bounds
|
||||
array access.
|
||||
|
||||
Thanks to @SuhwanSong and the Agency for Defense Development (ADD) for
|
||||
the report.
|
||||
|
||||
diff --git a/xmlschemastypes.c b/xmlschemastypes.c
|
||||
index 4249d700..d6b9f924 100644
|
||||
--- a/xmlschemastypes.c
|
||||
+++ b/xmlschemastypes.c
|
||||
@@ -3691,6 +3691,8 @@ xmlSchemaCompareDurations(xmlSchemaValPtr x, xmlSchemaValPtr y)
|
||||
minday = 0;
|
||||
maxday = 0;
|
||||
} else {
|
||||
+ if (myear > LONG_MAX / 366)
|
||||
+ return -2;
|
||||
/* FIXME: This doesn't take leap year exceptions every 100/400 years
|
||||
into account. */
|
||||
maxday = 365 * myear + (myear + 3) / 4;
|
||||
@@ -4079,6 +4081,14 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
|
||||
if ((x == NULL) || (y == NULL))
|
||||
return -2;
|
||||
Fixes #178.
|
||||
---
|
||||
xmllint.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
+ if ((x->value.date.year > LONG_MAX / 366) ||
|
||||
+ (x->value.date.year < LONG_MIN / 366) ||
|
||||
+ (y->value.date.year > LONG_MAX / 366) ||
|
||||
+ (y->value.date.year < LONG_MIN / 366)) {
|
||||
+ /* Possible overflow when converting to days. */
|
||||
+ return -2;
|
||||
+ }
|
||||
+
|
||||
if (x->value.date.tz_flag) {
|
||||
diff --git a/xmllint.c b/xmllint.c
|
||||
index f6a8e463..c647486f 100644
|
||||
--- a/xmllint.c
|
||||
+++ b/xmllint.c
|
||||
@@ -528,6 +528,12 @@ static void
|
||||
xmlHTMLEncodeSend(void) {
|
||||
char *result;
|
||||
|
||||
if (!y->value.date.tz_flag) {
|
||||
+ /*
|
||||
+ * xmlEncodeEntitiesReentrant assumes valid UTF-8, but the buffer might
|
||||
+ * end with a truncated UTF-8 sequence. This is a hack to at least avoid
|
||||
+ * an out-of-bounds read.
|
||||
+ */
|
||||
+ memset(&buffer[sizeof(buffer)-4], 0, 4);
|
||||
result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer);
|
||||
if (result) {
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", result);
|
||||
--
|
||||
2.28.0.rc2
|
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
From 8e7c20a1af8776677d7890f30b7a180567701a49 Mon Sep 17 00:00:00 2001
|
||||
From: Nick Wellnhofer <wellnhofer@aevum.de>
|
||||
Date: Mon, 3 Aug 2020 17:30:41 +0200
|
||||
Subject: [PATCH] Fix integer overflow when comparing schema dates
|
||||
|
||||
Found by OSS-Fuzz.
|
||||
---
|
||||
xmlschemastypes.c | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
diff --git a/xmlschemastypes.c b/xmlschemastypes.c
|
||||
index 4249d700..d6b9f924 100644
|
||||
--- a/xmlschemastypes.c
|
||||
+++ b/xmlschemastypes.c
|
||||
@@ -3691,6 +3691,8 @@ xmlSchemaCompareDurations(xmlSchemaValPtr x, xmlSchemaValPtr y)
|
||||
minday = 0;
|
||||
maxday = 0;
|
||||
} else {
|
||||
+ if (myear > LONG_MAX / 366)
|
||||
+ return -2;
|
||||
/* FIXME: This doesn't take leap year exceptions every 100/400 years
|
||||
into account. */
|
||||
maxday = 365 * myear + (myear + 3) / 4;
|
||||
@@ -4079,6 +4081,14 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
|
||||
if ((x == NULL) || (y == NULL))
|
||||
return -2;
|
||||
|
||||
+ if ((x->value.date.year > LONG_MAX / 366) ||
|
||||
+ (x->value.date.year < LONG_MIN / 366) ||
|
||||
+ (y->value.date.year > LONG_MAX / 366) ||
|
||||
+ (y->value.date.year < LONG_MIN / 366)) {
|
||||
+ /* Possible overflow when converting to days. */
|
||||
+ return -2;
|
||||
+ }
|
||||
+
|
||||
if (x->value.date.tz_flag) {
|
||||
|
||||
if (!y->value.date.tz_flag) {
|
||||
--
|
||||
2.28.0.rc2
|
||||
|
Loading…
Reference in new issue