]> 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:15:41 +0000 (20:15 -0500)
commitf8442f0217de90347444ece0c9c79e5d6646ed79
tree88c42e603972087df52a6948c29a15959b1b0e79
parentd0611f43c8b6a09bfadc5a60c9a923c49247da9c
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