]> git.gir.st - ircpipe.git/commit
fix segfault on D-line
authorTobias Girstmair <tobi@isticktoit.net>
Sat, 25 May 2024 13:11:10 +0000 (15:11 +0200)
committerTobias Girstmair <tobi@isticktoit.net>
Sat, 25 May 2024 13:11:10 +0000 (15:11 +0200)
commit90dd75f3e48e90421505f0dc66568907c17fb24b
treec3e2ba3f5a253e9faf15ba06d4618a4ae41754ba
parentc91498c0a2ee8bcc7dbce501c75389edc4b7d4dd
fix segfault on D-line

when connecting to irc.efnet.nl we get banned after RPL_WELCOME. the
whole (looong) MOTD loads, then we get ERR_YOUREBANNEDCREEP and a fatal
ERROR and the server closes the connection.
this bug manifested, when setting '-j', that poll (ircpipe.c:246)
returns revents == POLLHUP|POLLIN (while we expected only POLLIN). when
read(2)ing from the now-closed socket, we then read 0 bytes. in
irc_answer (ircpipe.c:260), strtok_r then returns NULL on the first
invocation (which again we did not expect, as we did not expect an empty
buffer to get passed). then we tried to look at the first character of
the string, dereferencing NULL and causing a SIGSEGV.

the solution is of course to check that return value of read(2) is > 0.
this is equivalent to aborting on POLLHUP; the comment in irc_poll() has
been adjusted to reflect this as well.
ircpipe.c
Imprint / Impressum