bug 1581986 - fix undefined shift behavior in md4 implementation r=kjacobs

Using left shift on a uint8_t promotes it to a signed integer. If the shift is
large enough that the sign bit gets affected, we have undefined behavior. This
patch fixes this by first casting to uint32_t.

Differential Revision: https://phabricator.services.mozilla.com/D46820

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dana Keeler 2019-09-23 19:17:52 +00:00
Родитель e8cd2193b5
Коммит 3d10b528b0
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -64,8 +64,8 @@ static void b2w(uint32_t* out, const uint8_t* in, uint32_t len) {
bpend = in + len;
for (; bp != bpend; bp += 4, ++wp) {
*wp = (uint32_t)(bp[0]) | (uint32_t)(bp[1] << 8) | (uint32_t)(bp[2] << 16) |
(uint32_t)(bp[3] << 24);
*wp = (uint32_t)bp[0] | ((uint32_t)bp[1] << 8) | ((uint32_t)bp[2] << 16) |
((uint32_t)bp[3] << 24);
}
}