summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManoj Gupta <manojgupta@google.com>2019-10-25 13:48:50 -0700
committerManoj Gupta <manojgupta@chromium.org>2019-10-28 22:16:59 +0000
commit86ed3884efe1bee509f2e94e2f718955f923e1bd (patch)
tree8f658dc10c578328af4e747a0b3b2d40b6fde40b
parent9c35c41b6c2f515714d609eb1458c50e89f2be48 (diff)
downloadvboot-86ed3884efe1bee509f2e94e2f718955f923e1bd.tar.gz
firmware: Fix more UBSAN left shift errors.
Follow up commit to CL:1867970. Shifting a uint8_t left by 24 promotes to an int, not an unsigned int (and shifts into the sign bit are undefined). Probably doesn't make a difference in assembly but still doesn't hurt to fix. Courtesy of UBSAN. BRANCH=None BUG=chromium:1015908 TEST=No more shift errors in unit test Change-Id: I10060df6b23da81388db34973b831c09c8d61bff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1881475 Tested-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
-rw-r--r--firmware/2lib/2rsa.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/firmware/2lib/2rsa.c b/firmware/2lib/2rsa.c
index 5d84ecd6..16edc26e 100644
--- a/firmware/2lib/2rsa.c
+++ b/firmware/2lib/2rsa.c
@@ -145,7 +145,8 @@ static void modpow(const struct vb2_public_key *key, uint8_t *inout,
/* Convert from big endian byte array to little endian word array. */
for (i = 0; i < (int)key->arrsize; ++i) {
uint32_t tmp =
- (inout[((key->arrsize - 1 - i) * 4) + 0] << 24) |
+ ((uint32_t)inout[((key->arrsize - 1 - i) * 4) + 0]
+ << 24) |
(inout[((key->arrsize - 1 - i) * 4) + 1] << 16) |
(inout[((key->arrsize - 1 - i) * 4) + 2] << 8) |
(inout[((key->arrsize - 1 - i) * 4) + 3] << 0);