зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
e8cd2193b5
Коммит
3d10b528b0
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче