diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2025-07-08 13:57:10 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2025-07-08 13:57:10 -0400 |
| commit | 83f9592c4bc0f8e5a6a8e73ba9e3daa1da107262 (patch) | |
| tree | 48ebcc0589fc15ebef7062065d16bd29b2b92d44 /src/lib/core | |
| parent | 5692c689a7b1da67724fc5c3c9bb3f3f1d7df0c9 (diff) | |
| download | stasis-83f9592c4bc0f8e5a6a8e73ba9e3daa1da107262.tar.gz | |
Write error message correctly to the buffer
* If errmsg is NULL, allocate and write string
* If errmsg is not NULL, write string
Diffstat (limited to 'src/lib/core')
| -rw-r--r-- | src/lib/core/download.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/core/download.c b/src/lib/core/download.c index c3f8dca..b021860 100644 --- a/src/lib/core/download.c +++ b/src/lib/core/download.c @@ -41,10 +41,10 @@ long download(char *url, const char *filename, char **errmsg) { CURLcode curl_code = curl_easy_perform(c); SYSDEBUG("curl status code: %d", curl_code); if (curl_code != CURLE_OK) { - if (errmsg) { - strcpy(*errmsg, curl_easy_strerror(curl_code)); + if (!*errmsg) { + *errmsg = strdup(curl_easy_strerror(curl_code)); } else { - fprintf(stderr, "\nCURL ERROR: %s\n", curl_easy_strerror(curl_code)); + strncpy(*errmsg, curl_easy_strerror(curl_code), strlen(curl_easy_strerror(curl_code) + 1)); } goto failed; } |
