Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set host to an empty string on error #769

Merged
merged 2 commits into from Oct 13, 2017

Conversation

Projects
None yet
4 participants
@horgh
Copy link
Member

commented Oct 9, 2017

While investigating #317, I noticed that it was possible we would access
an uninitialized buffer due to failing to check the return value of
net_ip2host(). This is done in several places. To make such uses safe,
set the host buffer to an empty string on error. It is possible callers
could be improved by handling the error in each spot, but this gives us
some safety.

Set host to an empty string on error
While investigating #317, I noticed that it was possible we would access
an uninitialized buffer due to failing to check the return value of
net_ip2host(). This is done in several places. To make such uses safe,
set the host buffer to an empty string on error. It is possible callers
could be improved by handling the error in each spot, but this gives us
some safety.
@josephbisch

This comment has been minimized.

Copy link
Member

commented Oct 9, 2017

LGTM

return 0;
}

// For callers that do not check our return value and pass in an

This comment has been minimized.

Copy link
@LemonBoy

LemonBoy Oct 10, 2017

Member

The comment is quite out of place and is better suited to the commit message.
I'd just add host[0] = '\0' before the return inet_ntop and be done with this.

Always initialize the host string
This also removes a wordy comment
@horgh

This comment has been minimized.

Copy link
Member Author

commented Oct 11, 2017

Thanks for checking it out! I updated the change. A lot simpler!

@ailin-nemui ailin-nemui merged commit 7b97edf into irssi:master Oct 13, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

ailin-nemui added a commit to ailin-nemui/irssi that referenced this pull request Dec 7, 2017

@ailin-nemui ailin-nemui added this to the 1.0.5 milestone Jan 10, 2018

lkundrak pushed a commit to lkundrak/irssi that referenced this pull request Feb 16, 2018

Merge pull request irssi#769 from horgh/horgh/error-check-server-connect
Set host to an empty string on error

(cherry picked from commit 437fbef)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.