Introduction
Introduction Statistics Contact Development Disclaimer Help
fix a crash when tag could be uninitialized and not set to a fixed buffer tagna…
git clone git://git.codemadness.org/webdump
Log
Files
Refs
README
LICENSE
---
commit 115f7e68eeccd7f1030fc631c52bab35692c6973
parent 64010b2be4bc3845ef07db25f8621c7894fe64bb
Author: Hiltjo Posthuma <[email protected]>
Date: Wed, 22 May 2024 19:12:44 +0200
fix a crash when tag could be uninitialized and not set to a fixed buffer tagna…
Reported by pi31415 when he was testing webdump on a binary ZIP file, thanks!
Diffstat:
M webdump.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/webdump.c b/webdump.c
@@ -1540,6 +1540,8 @@ printlinkrefs(void)
static void
incnode(void)
{
+ size_t i;
+
curnode++;
if (curnode >= MAX_NODE_DEPTH)
@@ -1553,6 +1555,11 @@ incnode(void)
memset(&nodes[ncapnodes], 0, sizeof(*nodes) * NODE_CAP_INC);
memset(&nodes_links[ncapnodes], 0, sizeof(*nodes_links) * NODE…
+ for (i = ncapnodes; i < ncapnodes + NODE_CAP_INC; i++) {
+ nodes[i].tag.displaytype = DisplayInline;
+ nodes[i].tag.name = nodes[i].tagname; /* assign to use…
+ }
+
ncapnodes += NODE_CAP_INC; /* greedy alloc */
}
}
@@ -1987,8 +1994,6 @@ xmltagstart(XMLParser *p, const char *t, size_t tl)
cur = &nodes[curnode];
memset(cur, 0, sizeof(*cur)); /* clear / reset node */
/* tag defaults */
- cur->tag.displaytype = DisplayInline;
- cur->tag.name = cur->tagname; /* assign fixed-size buffer */
strlcpy(cur->tagname, t, sizeof(cur->tagname));
/* force to lowercase */
@@ -2416,9 +2421,6 @@ main(int argc, char **argv)
nodes = ecalloc(ncapnodes, sizeof(*nodes));
nodes_links = ecalloc(ncapnodes, sizeof(*nodes_links));
- /* top-most document root needs initialization */
- nodes[0].tag.name = "";
-
parser.xmlattrstart = xmlattrstart;
parser.xmlattr = xmlattr;
parser.xmlattrentity = xmlattrentity;
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.