irssi/src
dequis 632b0ce5e6 Add parse_uint function to improve integer overflow handling
Originally found by oss-fuzz (issue 525) in get_ansi_color using ubsan.
After a lot of analysis I'm 99% sure this isn't security relevant so
it's fine to handle this publicly.

The fix is mainly adding a function that does it right and use it
everywhere. This is harder than it seems because the strtol() family of
functions doesn't have the friendliest of interfaces.

Aside from get_ansi_color(), there were other pieces of code that used
the same (out*10+(*in-'0')) pattern, like the parse_size() and
parse_time_interval() functions, which are mostly used for settings.
Those are interesting cases, since they multiply the parsed number
(resulting in more overflows) and they write to a signed integer
parameter (which can accidentally make the uints negative without UB)

Thanks to Pascal Cuoq for enlightening me about the undefined behavior
of parse_size (and, in particular, the implementation-defined behavior
of one of the WIP versions of this commit, where something like signed
integer overflow happened, but it was legal). Also for writing
tis-interpreter, which is better than ubsan to verify these things.
2017-05-18 00:21:11 -03:00
..
core Add parse_uint function to improve integer overflow handling 2017-05-18 00:21:11 -03:00
fe-common Add parse_uint function to improve integer overflow handling 2017-05-18 00:21:11 -03:00
fe-fuzz Fix fe-fuzz nits 2017-01-12 18:11:09 -05:00
fe-none s/INCLUDES/AM_CPPFLAGS/g 2014-06-27 09:06:21 -04:00
fe-text Intentation/whitespace fixes 2017-03-21 10:27:39 -04:00
irc fix dcc get 2017-03-07 23:27:08 +01:00
lib-config Enforce the is_node_list contract in lib-config setters. 2016-11-29 23:08:45 +01:00
perl Don't emit the script destroyed signal before script is actually destroyed 2017-02-28 23:48:56 -05:00
common.h up abi ver 2017-03-14 09:54:28 +01:00
Makefile.am Add frontend for fuzzing 2017-01-07 20:01:07 -05:00