mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-29 14:50:59 +01:00
CLEANUP: hpack: be careful about integer promotion from uint8_t
As reported in issue #1635, there's a subtle sign change when shifting a uint8_t value to the left because integer promotion first turns any smaller type to signed int *even if it was unsigned*. A warning was reported about uint8_t shifted left 24 bits that couldn't fit in int due to this. It was verified that the emitted code didn't change, as expected, but at least this allows to silence the code checkers. There's no need to backport this.
This commit is contained in:
parent
eb2a2da67c
commit
17b4687a89
@ -1446,7 +1446,10 @@ int huff_dec(const uint8_t *huff, int hlen, char *out, int olen)
|
||||
next = 0;
|
||||
|
||||
if (huff + 4 <= huff_end) {
|
||||
next = (huff[0] << 24) + (huff[1] << 16) + (huff[2] << 8) + huff[3];
|
||||
next = ((uint32_t)huff[0] << 24) +
|
||||
((uint32_t)huff[1] << 16) +
|
||||
((uint32_t)huff[2] << 8) +
|
||||
(uint32_t)huff[3];
|
||||
huff += 4;
|
||||
}
|
||||
else {
|
||||
@ -1454,10 +1457,10 @@ int huff_dec(const uint8_t *huff, int hlen, char *out, int olen)
|
||||
* distinguish shifted bits from a really inserted
|
||||
* EOS.
|
||||
*/
|
||||
next = (((huff + 0 < huff_end) ? huff[0] : 0x00) << 24) +
|
||||
(((huff + 1 < huff_end) ? huff[1] : 0x00) << 16) +
|
||||
(((huff + 2 < huff_end) ? huff[2] : 0x00) << 8) +
|
||||
((huff + 3 < huff_end) ? huff[3] : 0x00);
|
||||
next = (((huff + 0 < huff_end) ? (uint32_t)huff[0] : 0x00) << 24) +
|
||||
(((huff + 1 < huff_end) ? (uint32_t)huff[1] : 0x00) << 16) +
|
||||
(((huff + 2 < huff_end) ? (uint32_t)huff[2] : 0x00) << 8) +
|
||||
((huff + 3 < huff_end) ? (uint32_t)huff[3] : 0x00);
|
||||
huff = huff_end;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user