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>master
parent
dcfde2e318
commit
b44c311db7
|
@ -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];
|
||||
|
|
Loading…
Reference in New Issue