Skip to content

Commit 8185b62

Browse files
committed
Fix potential NULL pointer dereference before calling xmlXPathEvalExpression
1 parent b51994d commit 8185b62

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/DS/sds.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,14 @@ static int ds_sds_compose_catalog_has_uri(xmlDocPtr doc, xmlNodePtr catalog, con
791791
xpathCtx->node = catalog;
792792

793793
char *expression = oscap_sprintf("cat:uri[@uri = '%s']", uri);
794+
if (expression == NULL)
795+
{
796+
oscap_seterr(OSCAP_EFAMILY_OSCAP, "Error: Unable to create XPath expression.");
797+
xmlXPathFreeContext(xpathCtx);
794798

799+
return -1;
800+
}
801+
795802
xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(
796803
BAD_CAST expression,
797804
xpathCtx);
@@ -1012,6 +1019,13 @@ static int ds_sds_compose_has_component_ref(xmlDocPtr doc, xmlNodePtr datastream
10121019
xpathCtx->node = datastream;
10131020

10141021
char *expression = oscap_sprintf("*/ds:component-ref[@xlink:href = '#%s' and @id = '%s']", filepath, cref_id);
1022+
if (expression == NULL)
1023+
{
1024+
oscap_seterr(OSCAP_EFAMILY_OSCAP, "Error: Unable to create XPath expression.");
1025+
xmlXPathFreeContext(xpathCtx);
1026+
1027+
return -1;
1028+
}
10151029

10161030
xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(
10171031
BAD_CAST expression,

0 commit comments

Comments
 (0)