]> Kevux Git Server - fll/commit
Security: use signed integers for string lengths and array lenghts by default
authorKevin Day <thekevinday@gmail.com>
Thu, 18 Jul 2019 01:11:17 +0000 (20:11 -0500)
committerKevin Day <thekevinday@gmail.com>
Thu, 18 Jul 2019 01:11:17 +0000 (20:11 -0500)
commitfdd73abcff7454f66738094f2cd7a2914bd32da0
treea632f32a891fca5e294e6ab29b483f0687cb42e8
parentf19f497e53eaf75b04b28d672070fbeaad83f945
Security: use signed integers for string lengths and array lenghts by default

Standard functions, such as strnlen(), appear to operate on signed integers instead of unsigned.
Not being able to handle unsigned integers provides unknown behavior that could lead to potential security vulnerabilities.
Future versions of this project will likely need to abandon these methods for more flexible alternatives.

Example problem:
  sources/c/console.c:36:23: warning: 'strnlen' specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
     36 |       string_length = strnlen(argv[location], f_console_max_size);

That is 2^63 instead of the expected 2^64.

The array lengths were converted to signed as well.
level_0/f_strings/c/strings.h
level_0/f_types/c/types.h