diff options
author | Xiang Wang <merle@hardenedlinux.org> | 2021-01-20 17:31:19 +0800 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2021-01-24 11:17:56 +0000 |
commit | 1a21cc70d69d9d8f34d6b1faab1f942f57888585 (patch) | |
tree | 5879d6348537dfe730c3291f8a0ac9dea3539296 /nic3com.c | |
parent | 180079632b15758ca0bbbe5782611bd4573e11d8 (diff) | |
download | flashrom-1a21cc70d69d9d8f34d6b1faab1f942f57888585.tar.gz flashrom-1a21cc70d69d9d8f34d6b1faab1f942f57888585.tar.bz2 flashrom-1a21cc70d69d9d8f34d6b1faab1f942f57888585.zip |
helpers.c: Fix undefined behavior in strndup()
Using strlen() or strdup() inside strndup() is problematic: if the
input string is not null-terminated, these functions can read past the
end of the buffer, which triggers undefined behavior. Rewrite the
function to never read past the provided `maxlen` bound.
Change-Id: Id34127024085879228626fbad59af03268ec5255
Signed-off-by: Xiang Wang <merle@hardenedliux.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/49741
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'nic3com.c')
0 files changed, 0 insertions, 0 deletions