diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-15 00:30:12 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-15 00:30:12 +0000 |
| commit | d5c363d20607134538a0a12a9f0c88135c50b372 (patch) | |
| tree | 10b747af33b979a6a72c5f3034ff2934549a99d2 /config/data/grub | |
| parent | 36851df55fd4dbbb0fba13196883a1293d1f8f6f (diff) | |
util/nvmutil: safer xstrxcmp() - overflow fix
if a points to a buffer shorter than maxlen,
and the string is not null-terminated early,
the loop may read may overflow
e.g.
char buf[3] = {'a', 'b', 'c'};
xstrxcmp(buf, "abc", 50);
this is undefined behaviour, and a bug. C allows
reading past arrays only if the memory exists,
but we can't guarantee that
to fix it, we check the condition for return,
namely NULL character, before using the character
again. This avoids reading further from a multiple
times so we exit as soon as we encounter NULL
this also avoids multiple reads from memory, though
a compiler would optimise that anyway
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'config/data/grub')
0 files changed, 0 insertions, 0 deletions
