diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-09-15 15:53:13 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-09-15 15:55:05 +0200 |
commit | 0009c8629d458001a23eaac83ba3e4257d252bd7 (patch) | |
tree | 8120ffb74c0224514581defeb246c2911d90df0c | |
parent | 8854b9284b5a14b3b5b2e64a72f3b5c3165a726a (diff) | |
download | curl-bagder/writeout-torture.tar.gz |
tool_writeout: protect fputs() from NULLbagder/writeout-torture
When the code was changed to do fputs() instead of fprintf() it got
sensitive for NULL pointers; add checks for that.
Follow-up from 0c1e767e83ec66
-rw-r--r-- | src/tool_writeout.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/tool_writeout.c b/src/tool_writeout.c index 63d2cd003..393e16861 100644 --- a/src/tool_writeout.c +++ b/src/tool_writeout.c @@ -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: |