Skip to content

Commit

Permalink
fix unchecked return values from libcurl calls
Browse files Browse the repository at this point in the history
- fail on memory problems with the URL API
- mark an snmprintf call as (void)

Detected by Coverity
  • Loading branch information
bagder committed May 14, 2024
1 parent 2f38b45 commit b5f14a3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions trurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand All @@ -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);
Expand Down

0 comments on commit b5f14a3

Please sign in to comment.