Blame SOURCES/libxml2-2.9.7-CVE-2020-24977.patch
|
|
114ffb |
From 50f06b3efb638efb0abd95dc62dca05ae67882c2 Mon Sep 17 00:00:00 2001
|
|
|
114ffb |
From: Nick Wellnhofer <wellnhofer@aevum.de>
|
|
|
114ffb |
Date: Fri, 7 Aug 2020 21:54:27 +0200
|
|
|
114ffb |
Subject: [PATCH] Fix out-of-bounds read with 'xmllint --htmlout'
|
|
|
114ffb |
|
|
|
114ffb |
Make sure that truncated UTF-8 sequences don't cause an out-of-bounds
|
|
|
114ffb |
array access.
|
|
|
114ffb |
|
|
|
114ffb |
Thanks to @SuhwanSong and the Agency for Defense Development (ADD) for
|
|
|
114ffb |
the report.
|
|
|
114ffb |
|
|
|
114ffb |
Fixes #178.
|
|
|
114ffb |
---
|
|
|
114ffb |
xmllint.c | 6 ++++++
|
|
|
114ffb |
1 file changed, 6 insertions(+)
|
|
|
114ffb |
|
|
|
114ffb |
diff --git a/xmllint.c b/xmllint.c
|
|
|
114ffb |
index f6a8e4636..c647486f3 100644
|
|
|
114ffb |
--- a/xmllint.c
|
|
|
114ffb |
+++ b/xmllint.c
|
|
|
114ffb |
@@ -528,6 +528,12 @@ static void
|
|
|
114ffb |
xmlHTMLEncodeSend(void) {
|
|
|
114ffb |
char *result;
|
|
|
114ffb |
|
|
|
114ffb |
+ /*
|
|
|
114ffb |
+ * xmlEncodeEntitiesReentrant assumes valid UTF-8, but the buffer might
|
|
|
114ffb |
+ * end with a truncated UTF-8 sequence. This is a hack to at least avoid
|
|
|
114ffb |
+ * an out-of-bounds read.
|
|
|
114ffb |
+ */
|
|
|
114ffb |
+ memset(&buffer[sizeof(buffer)-4], 0, 4);
|
|
|
114ffb |
result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer);
|
|
|
114ffb |
if (result) {
|
|
|
114ffb |
xmlGenericError(xmlGenericErrorContext, "%s", result);
|
|
|
114ffb |
--
|
|
|
114ffb |
GitLab
|
|
|
114ffb |
|