Raptor007 / aq2-tng

Action Quake 2: The Next Generation. Raptor007's sandbox for testing changes. When verified stable, this code is pushed to the official aq2-tng repo:
https://github.com/aq2-tng/aq2-tng/tree/bots
4 stars 2 forks source link

Fix segfault IRC_printf passing invalid val type #141

Closed darkshade9 closed 2 years ago

darkshade9 commented 2 years ago

IRC_printf would segfault if ircbot=1 and connected to an IRC server because it doesn't use %i (see https://github.com/Raptor007/aq2-tng/blob/master/source/tng_irc.c#L482-L491), suggested change to %k

Raptor007 commented 2 years ago

Thanks for the fix! I guess the IRC code doesn't get used much for this go to unnoticed for so long.

I was curious how this happened, so I tracked it down to this (very sensible) change made 13 years ago in Maniac's M0.22 code: https://github.com/Raptor007/aq2-tng/blame/12911f8950a736217b2bc00f3b32e2765c7b5f46/source/a_match.c#L271

Aside from crashing on %i (which really a function named "printf" should be able to parse) it was much cleaner than the old code: https://github.com/Raptor007/aq2-tng/blame/484e5b2ba154eed2deb83623e20a005a4ba89f42/source/a_match.c#L270-L283

Ideally the IRC_printf function should be able to parse some basics like %i/%f or even better use something like vsprintf in the default case, but it's probably not worth the effort.