Skip to content

tool_writeout: protect fputs() from NULL - #5963

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/writeout-torture
Closed

bagder wants to merge 1 commit into
masterfrom
bagder/writeout-torture

Conversation

@bagder

@bagder bagder commented Sep 15, 2020

Copy link
Copy Markdown
Member

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

Follow-up from 0c1e767

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

Follow-up from 0c1e767

@cvengler cvengler left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has a performance impact. I would check for stringp first before running curl_easy_getinfo. Otherwise curl_easy_getinfo gets executed every time even if it was not necessary.

So change it to this please:

                if(stringp && (CURLE_OK == curl_easy_getinfo(curl, CURLINFO_LOCAL_IP,
                                                  &stringp)))

Sorry for the bad formatting. Did this in the browser...

@bagder

bagder commented Sep 15, 2020 •

Copy link
Copy Markdown
Member Author

Look again: the pointer is extracted with the curl_easy_getinfo call, checking it before that is no good. Besides, this pattern of checks is already used on other lines of this function that uses fputs() but was missed when the code introduced more fputs() calls...

@cvengler

Copy link
Copy Markdown

Ok didn't knew that! I haven't actually looked at the function name my review was a reflex

@bagder bagder closed this in 0b4c414 Sep 15, 2020
@bagder
bagder deleted the bagder/writeout-torture branch September 15, 2020 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants