Light has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/62764 )
Change subject: ich_desriptors.c: Assert unsigned types >=0 on to prevent underflow error ......................................................................
ich_desriptors.c: Assert unsigned types >=0 on to prevent underflow error
Unsigned types show undefined behaviour if they are subtracting with value greater than their own (mostly it wraps to the max value). Using this value for left shifting could be even more dangerous.
Change-Id: I5921cc571f3dca5188ca1973dba6ececbcbe2f39 Signed-off-by: Aarya Chaumal aarya.chaumal@gmail.com --- M ich_descriptors.c 1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/64/62764/1
diff --git a/ich_descriptors.c b/ich_descriptors.c index 8914dfc..0f48e19 100644 --- a/ich_descriptors.c +++ b/ich_descriptors.c @@ -17,6 +17,7 @@
#include "hwaccess_physmap.h" #include "ich_descriptors.h" +#include <assert.h>
#ifdef ICH_DESCRIPTORS_FROM_DUMP_ONLY #include <stdio.h> @@ -503,9 +504,12 @@ desc->master.mstr[i].read & (1 << j) ? 'r' : ' ', desc->master.mstr[i].write & (1 << j) ? 'w' : ' '); for (; j < num_regions; j++) + { + assert(j>=12); msg_pdbg2(" %c%c ", desc->master.mstr[i].ext_read & (1 << (j - 12)) ? 'r' : ' ', desc->master.mstr[i].ext_write & (1 << (j - 12)) ? 'w' : ' '); + } msg_pdbg2("\n"); } } else if (cs == CHIPSET_C620_SERIES_LEWISBURG) {