You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
49 lines
1.5 KiB
From 1771ddb83fe8a8cb38e7bee212bdfa3d1927cfc5 Mon Sep 17 00:00:00 2001
|
|
From: Jim Fehlig <jfehlig@suse.com>
|
|
Date: Tue, 7 Jan 2020 11:52:23 -0700
|
|
Subject: [PATCH 13/19] Check return value of asprintf
|
|
|
|
Example from coverity scan
|
|
|
|
vhostmd-1.1/vhostmd/util.c: scope_hint: In function 'vu_append_string'
|
|
vhostmd-1.1/vhostmd/util.c:484:7: warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result]
|
|
asprintf(&cp, "%s,%s", *dest, str);
|
|
|
|
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
|
---
|
|
vhostmd/util.c | 3 ++-
|
|
vhostmd/vhostmd.c | 3 ++-
|
|
2 files changed, 4 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/vhostmd/util.c b/vhostmd/util.c
|
|
index 317dbc6..d7ce3fc 100644
|
|
--- a/vhostmd/util.c
|
|
+++ b/vhostmd/util.c
|
|
@@ -488,7 +488,8 @@ int vu_append_string(char **dest, xmlChar * str)
|
|
char *cp;
|
|
|
|
if (*dest) {
|
|
- asprintf(&cp, "%s,%s", *dest, str);
|
|
+ if (asprintf(&cp, "%s,%s", *dest, str) < 0)
|
|
+ return -1;
|
|
free(*dest);
|
|
*dest = cp;
|
|
}
|
|
diff --git a/vhostmd/vhostmd.c b/vhostmd/vhostmd.c
|
|
index 7e29e6f..7374ec9 100644
|
|
--- a/vhostmd/vhostmd.c
|
|
+++ b/vhostmd/vhostmd.c
|
|
@@ -259,7 +259,8 @@ static int parse_group_metric(xmlDocPtr xml ATTRIBUTE_UNUSED,
|
|
vu_log(VHOSTMD_WARN, "parse_group_metric: node path not found");
|
|
return -1;
|
|
}
|
|
- asprintf(&cp, "%s/variable", path);
|
|
+ if (asprintf(&cp, "%s/variable", path) < 0)
|
|
+ goto error;
|
|
|
|
obj = xmlXPathEval( BAD_CAST cp, ctxt);
|
|
if ((obj == NULL) || (obj->type != XPATH_NODESET)) {
|
|
--
|
|
2.32.0
|
|
|