Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/32854
Change subject: util/romcc: Use 64 bit integers when shifting ......................................................................
util/romcc: Use 64 bit integers when shifting
'used_indicies' is 64 bits wide, so use a fixed-width type to make that clear. As such, 'index' can have a value of up to 63, so use a 64 bit integer when doing the shifts to prevent overflow.
Found-by: Coverity Scan CID 1287090 Signed-off-by: Jacob Garber jgarber1@ualberta.ca Change-Id: Ibd089df6be60c8ea46da11e5e83cd58b2e2c54d6 --- M util/romcc/romcc.c 1 file changed, 5 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/32854/1
diff --git a/util/romcc/romcc.c b/util/romcc/romcc.c index 43be171..d1a2655 100644 --- a/util/romcc/romcc.c +++ b/util/romcc/romcc.c @@ -14111,7 +14111,7 @@ struct block *block; struct triple *old_result, *first, *ins; size_t count, idx; - unsigned long used_indicies; + uint64_t used_indicies; int i, max_index; #define MAX_INDICIES (sizeof(used_indicies)*CHAR_BIT) #define ID_BITS(X) ((X) & (TRIPLE_FLAG_LOCAL -1)) @@ -14217,11 +14217,11 @@ if (index >= MAX_INDICIES) { internal_error(state, ins, "index unexpectedly large"); } - if (used_indicies & (1 << index)) { + if (used_indicies & ((uint64_t)1 << index)) { internal_error(state, ins, "index previously used?"); } /* Remember which indicies have been used */ - used_indicies |= (1 << index); + used_indicies |= ((uint64_t)1 << index); if (index > max_index) { max_index = index; } @@ -14249,7 +14249,7 @@ } info[ID_BITS(ins->id)].index = index; /* Remember which indicies have been used */ - used_indicies |= (1 << index); + used_indicies |= ((uint64_t)1 << index); if (index > max_index) { max_index = index; } @@ -14263,7 +14263,7 @@ for(i = 0; i <= max_index; i++) { struct triple *var; var = 0; - if (used_indicies & (1 << i)) { + if (used_indicies & ((uint64_t)1 << i)) { for(set = vars; set; set = set->next) { int index; index = info[ID_BITS(set->member->id)].index;
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32854 )
Change subject: util/romcc: Use 64 bit integers when shifting ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/#/c/32854/1/util/romcc/romcc.c File util/romcc/romcc.c:
https://review.coreboot.org/#/c/32854/1/util/romcc/romcc.c@14220 PS1, Line 14220: if (used_indicies & ((uint64_t)1 << index)) { braces {} are not necessary for single statement blocks
Hello David Hendricks, build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32854
to look at the new patch set (#2).
Change subject: util/romcc: Use 64 bit integers when shifting ......................................................................
util/romcc: Use 64 bit integers when shifting
'used_indices' is 64 bits wide, so use a fixed-width type to make that clear. As such, 'index' can have a value of up to 63, so use a 64 bit integer when doing the shifts to prevent overflow.
Found-by: Coverity Scan CID 1287090 Signed-off-by: Jacob Garber jgarber1@ualberta.ca Change-Id: Ibd089df6be60c8ea46da11e5e83cd58b2e2c54d6 --- M util/romcc/romcc.c 1 file changed, 5 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/32854/2
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32854 )
Change subject: util/romcc: Use 64 bit integers when shifting ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/#/c/32854/2/util/romcc/romcc.c File util/romcc/romcc.c:
https://review.coreboot.org/#/c/32854/2/util/romcc/romcc.c@14220 PS2, Line 14220: if (used_indices & ((uint64_t)1 << index)) { braces {} are not necessary for single statement blocks
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32854 )
Change subject: util/romcc: Use 64 bit integers when shifting ......................................................................
Patch Set 2: Code-Review+2
Patrick Georgi has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/32854 )
Change subject: util/romcc: Use 64 bit integers when shifting ......................................................................
util/romcc: Use 64 bit integers when shifting
'used_indices' is 64 bits wide, so use a fixed-width type to make that clear. As such, 'index' can have a value of up to 63, so use a 64 bit integer when doing the shifts to prevent overflow.
Found-by: Coverity Scan CID 1287090 Signed-off-by: Jacob Garber jgarber1@ualberta.ca Change-Id: Ibd089df6be60c8ea46da11e5e83cd58b2e2c54d6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/32854 Reviewed-by: Patrick Georgi pgeorgi@google.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M util/romcc/romcc.c 1 file changed, 5 insertions(+), 5 deletions(-)
Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved
diff --git a/util/romcc/romcc.c b/util/romcc/romcc.c index c6507dc..97cc219 100644 --- a/util/romcc/romcc.c +++ b/util/romcc/romcc.c @@ -14111,7 +14111,7 @@ struct block *block; struct triple *old_result, *first, *ins; size_t count, idx; - unsigned long used_indices; + uint64_t used_indices; int i, max_index; #define MAX_INDICES (sizeof(used_indices)*CHAR_BIT) #define ID_BITS(X) ((X) & (TRIPLE_FLAG_LOCAL -1)) @@ -14217,11 +14217,11 @@ if (index >= MAX_INDICES) { internal_error(state, ins, "index unexpectedly large"); } - if (used_indices & (1 << index)) { + if (used_indices & ((uint64_t)1 << index)) { internal_error(state, ins, "index previously used?"); } /* Remember which indices have been used */ - used_indices |= (1 << index); + used_indices |= ((uint64_t)1 << index); if (index > max_index) { max_index = index; } @@ -14249,7 +14249,7 @@ } info[ID_BITS(ins->id)].index = index; /* Remember which indices have been used */ - used_indices |= (1 << index); + used_indices |= ((uint64_t)1 << index); if (index > max_index) { max_index = index; } @@ -14263,7 +14263,7 @@ for(i = 0; i <= max_index; i++) { struct triple *var; var = 0; - if (used_indices & (1 << i)) { + if (used_indices & ((uint64_t)1 << i)) { for(set = vars; set; set = set->next) { int index; index = info[ID_BITS(set->member->id)].index;