weston/shared
Bryce Harrington 6351fb08c2 config-parser: Catch negative numbers assigned to unsigned config values
strtoul() has a side effect that when given a string representing a
negative number, it returns a negated version as the value, and does not
flag an error.  IOW, strtoul("-42", &val) sets val to 42.  This could
potentially result in unintended surprise behaviors, such as if one were
to inadvertantly set a config param to -1 expecting that to disable it,
but with the result of setting the param to 1 instead.

Catch this by using strtol() and then manually check for the negative
value.  This logic is modelled after Wayland's strtouint().

Note that this change unfortunately reduces the range of parseable
numbers from [0,UINT_MAX] to [0,INT_MAX].  The current users of
weston_config_section_get_uint() are anticipating numbers far smaller
than either of these limits, so the change is believed to have no impact
in practice.

Also add a test case for negative numbers that catches this error
condition.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-12 15:50:05 -07:00
..
cairo-util.c Moved helper macro to a discrete include file. 2015-06-15 17:11:45 -07:00
cairo-util.h cairo-util: return theme location from frame_touch_down 2015-12-08 13:04:34 -06:00
config-parser.c config-parser: Catch negative numbers assigned to unsigned config values 2016-07-12 15:50:05 -07:00
config-parser.h shared: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:18 -07:00
file-util.c shared: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:18 -07:00
file-util.h shared: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:18 -07:00
frame.c cairo-util: return theme location from frame_touch_down 2015-12-08 13:04:34 -06:00
helpers.h Unified multiple definitions of container_of() macro. 2015-06-15 17:11:58 -07:00
image-loader.c configure: Make jpeglib an optional dependency. 2016-03-07 12:05:52 -08:00
image-loader.h shared: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:18 -07:00
matrix.c shared: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:18 -07:00
matrix.h shared: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:18 -07:00
option-parser.c option-parser: Require integer option string values to be base-10 2016-07-08 17:44:10 -07:00
os-compatibility.c log: Open log file CLOEXEC so child processes don't get the fd 2015-07-16 19:28:36 -07:00
os-compatibility.h log: Open log file CLOEXEC so child processes don't get the fd 2015-07-16 19:28:36 -07:00
platform.h platform: explicitly cast the return value of weston_platform_get_egl_proc_address 2016-03-08 23:23:26 -08:00
timespec-util.h compositor,shared: add millihz_to_nsec() 2015-07-16 13:55:05 +03:00
xalloc.c Remove a wrong closing “extern "C"” in shared/xalloc.c 2016-07-11 13:22:37 -07:00
xalloc.h shared: Print .c file/line number in x* routines 2016-03-17 14:17:02 +02:00
zalloc.h shared: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:18 -07:00