]> git.gir.st - ircpipe.git/commit
fix segfault on D-line
authorTobias Girstmair <t@thi3nkpad.localdomain>
Sat, 25 May 2024 13:11:10 +0000 (15:11 +0200)
committerTobias Girstmair <t@thi3nkpad.localdomain>
Sat, 25 May 2024 13:11:10 +0000 (15:11 +0200)
commit1fe98d3a0ad40dfcf78119415cc787c1f8538d0d
treec3e2ba3f5a253e9faf15ba06d4618a4ae41754ba
parenta1327d2143fcc5a33ecb5ca5aba356226ee6a247
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