coreboot/tests
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
..
acpi tests: Rename Makefiles from .inc to .mk 2024-01-26 12:43:08 +00:00
commonlib commonlib/bsd/string: Fix pointer overflow for strnlen() 2024-08-15 18:16:23 +00:00
console tests: Rename Makefiles from .inc to .mk 2024-01-26 12:43:08 +00:00
data/lib lib/device_tree: Add some FDT helper functions 2024-05-21 13:44:47 +00:00
device tests: Rename Makefiles from .inc to .mk 2024-01-26 12:43:08 +00:00
drivers tests/drivers/efivars: Remove duplicated <limits.h> 2024-07-03 20:21:06 +00:00
helpers tests/lib: Factor out file related functions 2024-05-21 13:44:39 +00:00
include tests/lib: Factor out file related functions 2024-05-21 13:44:39 +00:00
lib commonlib/bsd: Add strlen() and strnlen() functions 2024-08-14 03:09:03 +00:00
mock tests: Fix tests code and comments style 2022-01-14 14:29:29 +00:00
stubs tree: Use <stdio.h> for snprintf 2024-05-29 10:33:54 +00:00
Makefile.common tests/lib: Factor out file related functions 2024-05-21 13:44:39 +00:00
Makefile.mk tests: Rename Makefiles from .inc to .mk 2024-01-26 12:43:08 +00:00