From b5f14a38f3fdd02cd579e884797c95c023fbd177 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 14 May 2024 16:55:02 +0200 Subject: [PATCH] fix unchecked return values from libcurl calls - fail on memory problems with the URL API - mark an snmprintf call as (void) Detected by Coverity --- trurl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/trurl.c b/trurl.c index 9fca1daf..f9ad4851 100644 --- a/trurl.c +++ b/trurl.c @@ -1489,9 +1489,10 @@ static void singleurl(struct option *o, wlen = strlen(w); iinfo->ptr = NULL; } - curl_msnprintf(iterbuf, sizeof(iterbuf), "%.*s%s=%.*s", (int)plen, part, - urlencode ? "" : ":", - (int)wlen, w); + (void)curl_msnprintf(iterbuf, sizeof(iterbuf), + "%.*s%s=%.*s", (int)plen, part, + urlencode ? "" : ":", + (int)wlen, w); setone(uh, iterbuf, o); if(iter->next) { struct iterinfo info; @@ -1510,7 +1511,8 @@ static void singleurl(struct option *o, char *npath; size_t olen; /* extract the current path */ - curl_url_get(uh, CURLUPART_PATH, &opath, 0); + if(curl_url_get(uh, CURLUPART_PATH, &opath, 0)) + errorf(o, ERROR_ITER, "out of memory"); /* does the existing path end with a slash, then don't add one in between */ @@ -1522,7 +1524,8 @@ static void singleurl(struct option *o, apath); if(npath) { /* set the new path */ - curl_url_set(uh, CURLUPART_PATH, npath, 0); + if(curl_url_set(uh, CURLUPART_PATH, npath, 0)) + errorf(o, ERROR_ITER, "out of memory"); } curl_free(npath); curl_free(opath);