1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-23 16:48:49 -05:00

tool_writeout: protect fputs() from NULL

When the code was changed to do fputs() instead of fprintf() it got
sensitive for NULL pointers; add checks for that.

Follow-up from 0c1e767e83

Closes #5963
This commit is contained in:
Daniel Stenberg 2020-09-15 15:53:13 +02:00
parent 2cc6857247
commit 0b4c4145aa
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -284,9 +284,8 @@ void ourWriteOut(CURL *curl, struct per_transfer *per, const char *writeinfo)
fputs(per->outs.filename, stream);
break;
case VAR_PRIMARY_IP:
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP,
&stringp))
if((CURLE_OK == curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP,
&stringp)) && stringp)
fputs(stringp, stream);
break;
case VAR_PRIMARY_PORT:
@ -296,9 +295,8 @@ void ourWriteOut(CURL *curl, struct per_transfer *per, const char *writeinfo)
fprintf(stream, "%ld", longinfo);
break;
case VAR_LOCAL_IP:
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_LOCAL_IP,
&stringp))
if((CURLE_OK == curl_easy_getinfo(curl, CURLINFO_LOCAL_IP,
&stringp)) && stringp)
fputs(stringp, stream);
break;
case VAR_LOCAL_PORT:
@ -331,9 +329,8 @@ void ourWriteOut(CURL *curl, struct per_transfer *per, const char *writeinfo)
}
break;
case VAR_SCHEME:
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_SCHEME,
&stringp))
if((CURLE_OK == curl_easy_getinfo(curl, CURLINFO_SCHEME,
&stringp)) && stringp)
fputs(stringp, stream);
break;
case VAR_STDOUT: