diff options
author | Manoj Gupta <manojgupta@google.com> | 2019-10-25 13:48:50 -0700 |
---|---|---|
committer | Manoj Gupta <manojgupta@chromium.org> | 2019-10-28 22:16:59 +0000 |
commit | 86ed3884efe1bee509f2e94e2f718955f923e1bd (patch) | |
tree | 8f658dc10c578328af4e747a0b3b2d40b6fde40b /firmware/2lib/2rsa.c | |
parent | 9c35c41b6c2f515714d609eb1458c50e89f2be48 (diff) | |
download | vboot-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>
Diffstat (limited to 'firmware/2lib/2rsa.c')
-rw-r--r-- | firmware/2lib/2rsa.c | 3 |
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); |