1From 5b2d07a72670513e41b481a9d922c983a64027ca Mon Sep 17 00:00:00 2001
2From: Nick Wellnhofer <wellnhofer@aevum.de>
3Date: Sat, 20 Aug 2022 17:00:50 +0200
4Subject: [PATCH] Use xmlStrlen in *CtxtReadDoc
5
6xmlStrlen handles buffers larger than INT_MAX more gracefully.
7
8Reference:https://github.com/GNOME/libxml2/commit/5b2d07a72670513e41b481a9d922c983a64027ca
9Conflict:NA
10---
11 HTMLparser.c | 7 ++-----
12 parser.c     | 6 ++----
13 2 files changed, 4 insertions(+), 9 deletions(-)
14
15diff --git a/HTMLparser.c b/HTMLparser.c
16index a4168f3..e0b32fe 100644
17--- a/HTMLparser.c
18+++ b/HTMLparser.c
19@@ -7087,13 +7087,10 @@ htmlDocPtr
20 htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar * cur,
21                const char *URL, const char *encoding, int options)
22 {
23-    const char *buf;
24-
25     if (cur == NULL)
26         return (NULL);
27-    buf = (const char *) cur;
28-    return (htmlCtxtReadMemory(ctxt, buf, strlen(buf), URL, encoding,
29-                               options));
30+    return (htmlCtxtReadMemory(ctxt, (const char *) cur, xmlStrlen(cur), URL,
31+                               encoding, options));
32 }
33 
34 /**
35diff --git a/parser.c b/parser.c
36index fbeb7af..23b031d 100644
37--- a/parser.c
38+++ b/parser.c
39@@ -15374,12 +15374,10 @@ xmlDocPtr
40 xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur,
41                const char *URL, const char *encoding, int options)
42 {
43-    const char *buf;
44-
45     if (cur == NULL)
46         return (NULL);
47-    buf = (const char *) cur;
48-    return (xmlCtxtReadMemory(ctxt, buf, strlen(buf), URL, encoding, options));
49+    return (xmlCtxtReadMemory(ctxt, (const char *) cur, xmlStrlen(cur), URL,
50+                              encoding, options));
51 }
52 
53 /**
54-- 
552.27.0
56
57