coreboot/tests/commonlib
Yu-Ping Wu 078a5a0e7c commonlib/bsd/string: Fix pointer overflow for strnlen()
When `maxlen` is large (such as SIZE_MAX), the `end` pointer will
overflow, causing strnlen() to incorrectly return 0.

To not make the implementation over-complicated, fix the problem by
using a counter.

BUG=b:359951393
TEST=make unit-tests -j
BRANCH=none

Change-Id: Ic9d983b11391f5e05c2bceb262682aced5206f94
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83914
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Mario Scheithauer <mario.scheithauer@siemens.com>
2024-08-15 18:16:23 +00:00
..
bsd commonlib/bsd/string: Fix pointer overflow for strnlen() 2024-08-15 18:16:23 +00:00
device_tree-test.c treewide: Move device_tree to commonlib 2024-06-22 04:02:04 +00:00
list-test.c treewide: Move list.h to commonlib 2024-02-24 11:49:46 +00:00
Makefile.mk treewide: Move device_tree to commonlib 2024-06-22 04:02:04 +00:00
rational-test.c tests/commonlib/rational-test: Use test group runner wrapper 2022-09-07 22:24:31 +00:00
region-test.c tests: Fix tests code and comments style 2022-01-14 14:29:29 +00:00