diff options
author | Leah Rowe <leah@libreboot.org> | 2025-01-27 04:09:48 +0000 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-01-27 04:09:48 +0000 |
commit | b2d6393ed5fe110f446b22902b840336253f4faf (patch) | |
tree | e2d5e9d724782cbaf4a31eda453fe4ab83f2569a | |
parent | 063fef14d3457fb5324848183fb49d5d47391e54 (diff) |
util/nvmutil swap(): ensure that no overflow occurs
it wouldn't occur, on the current logic, but i wasn't
comfortable having the starting point (on little endian)
being higher than the checked endpoint, in case of
possible integer overflow as a result of future
modifications.
this is therefore a pre-emptive bug fix, because it doesn't
yet fix a bug, but it prevents a bug from being introduced.
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r-- | util/nvmutil/nvmutil.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index f8eb3844..729f2830 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -441,7 +441,7 @@ swap(int partnum) /* swaps bytes in words, not pointers. */ size_t w, x; uint8_t *n = (uint8_t *) gbe[partnum]; - for (w = nf * ((uint8_t *) &e)[0], x = 1; w < NVM_SIZE; + for (w = NVM_SIZE * ((uint8_t *) &e)[0], x = 1; w < NVM_SIZE; w += 2, x += 2) { n[w] ^= n[x]; n[x] ^= n[w]; |