net: pkt: Add explicit casts to uint32_t when bitshifting uint8_t val
Cast uint8_t variable to uint32_t explicitly to avoid implicit cast to int, and thus potentially undefined behavior, reported by UBSAN: net_pkt.c:1946:17: runtime error: left shift of 239 by 24 places cannot be represented in type 'int' Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
7949789ce8
commit
31b79a93af
@ -1943,7 +1943,8 @@ int net_pkt_read_be32(struct net_pkt *pkt, uint32_t *data)
|
||||
|
||||
ret = net_pkt_read(pkt, d32, sizeof(uint32_t));
|
||||
|
||||
*data = d32[0] << 24 | d32[1] << 16 | d32[2] << 8 | d32[3];
|
||||
*data = (uint32_t)d32[0] << 24 | (uint32_t)d32[1] << 16 |
|
||||
(uint32_t)d32[2] << 8 | (uint32_t)d32[3];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user