Debian Codegraph @

debian/patches/0001-initialize-xmlValidCtxt.patch

raw
1 From 5a6c6afdf1d87cb13699064647cfb24cc9131fe5 Mon Sep 17 00:00:00 2001
2 From: Alexander Bluhm <[email protected]>
3 Date: Mon, 21 Nov 2022 18:37:25 +0100
4 Subject: [PATCH] initialize xmlValidCtxt
5
6 The variable cvp is stored on the stack and is uninitialized. So
7 the field ctxt->flags in valid.c xmlIsStreaming() contains random
8 data. The logic of xmlIsStreaming() can do an invalid cast and
9 pointer dereference pctxt->parseMode and may crash there. Use
10 memset() to pass correct zero flags in xmlValidCtxt cvp variable
11 down to xmlValidateDocument().
12 ---
13 LibXML.xs | 17 ++---------------
14 1 file changed, 2 insertions(+), 15 deletions(-)
15
16 Bug-Debian: https://bugs.debian.org/1072012
17
18 diff --git a/LibXML.xs b/LibXML.xs
19 index 70bb24e..b5b0b95 100644
20 --- a/LibXML.xs
21 +++ b/LibXML.xs
22 @@ -4025,18 +4025,11 @@ is_valid(self, ...)
23 CODE:
24 INIT_ERROR_HANDLER;
25
26 + memset(&cvp, 0, sizeof(cvp));
27 cvp.userData = saved_error;
28 cvp.error = (xmlValidityErrorFunc)LibXML_validity_error_ctx;
29 cvp.warning = (xmlValidityWarningFunc)LibXML_validity_warning_ctx;
30
31 - /* we need to initialize the node stack, because perl might
32 - * already have messed it up.
33 - */
34 - cvp.nodeNr = 0;
35 - cvp.nodeTab = NULL;
36 - cvp.vstateNr = 0;
37 - cvp.vstateTab = NULL;
38 -
39 PmmClearPSVI(self);
40 PmmInvalidatePSVI(self);
41 if (items > 1) {
42 @@ -4065,16 +4058,10 @@ validate(self, ...)
43 CODE:
44 INIT_ERROR_HANDLER;
45
46 + memset(&cvp, 0, sizeof(cvp));
47 cvp.userData = saved_error;
48 cvp.error = (xmlValidityErrorFunc)LibXML_validity_error_ctx;
49 cvp.warning = (xmlValidityWarningFunc)LibXML_validity_warning_ctx;
50 - /* we need to initialize the node stack, because perl might
51 - * already have messed it up.
52 - */
53 - cvp.nodeNr = 0;
54 - cvp.nodeTab = NULL;
55 - cvp.vstateNr = 0;
56 - cvp.vstateTab = NULL;
57
58 PmmClearPSVI(self);
59 PmmInvalidatePSVI(self);
60 --
61 2.43.0
62