Skip to content

Commit 48b19a8

Browse files
committed
xml: Use safe_emalloc() correctly
Fortunately, libxml won't allow _at this point in time_ to have more than INT_MAX/5 attributes, so this doesn't cause issues right now. However, if this limit is ever raised then it can cause an integer overflow which will cause a heap overflow. So future-proof this code by properly using safe_emalloc(). Closes GH-20472.
1 parent 37e61a0 commit 48b19a8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ext/xml/compat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ _start_element_handler_ns(void *user, const xmlChar *name, const xmlChar *prefix
111111

112112
if (attributes != NULL) {
113113
xmlChar *qualified_name_attr = NULL;
114-
attrs = safe_emalloc((nb_attributes * 2) + 1, sizeof(int *), 0);
114+
attrs = safe_emalloc(nb_attributes, 2 * sizeof(int *), sizeof(int *));
115115

116116
for (i = 0; i < nb_attributes; i += 1) {
117117

0 commit comments

Comments
 (0)