Attention is currently required from: Nikolai Artemiev.
Evan Benn would like Nikolai Artemiev to review this change.
ps25f.c: Fix UB on shift
dev_id, a u8, was shifted left 24. After promotion to int, this results
in shifting into the sign bit, which is undefined behaviour. Cast to
uint32 to prevent the promotion to signed int.
BUG=None
BRANCH=None
TEST=None
Change-Id: I88188ef2ba2af919eeae9ba08916374d31d8b989
Signed-off-by: Evan Benn <evanbenn@chromium.org>
---
M s25f.c
1 file changed, 22 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/27/68127/1
diff --git a/s25f.c b/s25f.c
index 67715ed..1133ef8 100644
--- a/s25f.c
+++ b/s25f.c
@@ -380,10 +380,10 @@
*/
uint32_t model_id =
- dev_id[1] << 24 |
- dev_id[2] << 16 |
- dev_id[4] << 8 |
- dev_id[5] << 0;
+ (uint32_t)dev_id[1] << 24 |
+ (uint32_t)dev_id[2] << 16 |
+ (uint32_t)dev_id[4] << 8 |
+ (uint32_t)dev_id[5] << 0;
if (dev_id[0] == flash->chip->manufacture_id && model_id == flash->chip->model_id)
return 1;
To view, visit change 68127. To unsubscribe, or for help writing mail filters, visit settings.