File 0001-tree-Fix-integer-overflow-in-xmlBuildQName.patch of Package libqt5-qtdoc
From ad346c9a249c4b380bf73c460ad3e81135c5d781 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Tue, 27 May 2025 12:53:17 +0200
Subject: [PATCH] tree: Fix integer overflow in xmlBuildQName
This issue affects memory safety and might receive a CVE ID later.
Fixes #926.
---
tree.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/qtwebengine/src/3rdparty/chromium/third_party/libxml/src/tree.c b/qtwebengine/src/3rdparty/chromium/third_party/libxml/src/tree.c
index e23571316..7a82ee23c 100644
--- a/qtwebengine/src/3rdparty/chromium/third_party/libxml/src/tree.c
+++ b/qtwebengine/src/3rdparty/chromium/third_party/libxml/src/tree.c
@@ -221,16 +221,18 @@ xmlGetParameterEntityFromDtd(const xmlDtd *dtd, const xmlChar *name) {
xmlChar *
xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix,
xmlChar *memory, int len) {
- int lenn, lenp;
+ size_t lenn, lenp;
xmlChar *ret;
- if (ncname == NULL) return(NULL);
+ if ((ncname == NULL) || (len < 0)) return(NULL);
if (prefix == NULL) return((xmlChar *) ncname);
lenn = strlen((char *) ncname);
lenp = strlen((char *) prefix);
+ if (lenn >= SIZE_MAX - lenp - 1)
+ return(NULL);
- if ((memory == NULL) || (len < lenn + lenp + 2)) {
+ if ((memory == NULL) || ((size_t) len < lenn + lenp + 2)) {
ret = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
if (ret == NULL) {
xmlTreeErrMemory("building QName");