mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
Without explicit casts, each buf byte was promoted to a 32-bit signed
int before shifting. For NR Cell Identity (36-bit, per 3GPP TS 38.423
§9.2.2.9), this causes two problems:
- Shifting buf[0] left by 28 can push bits into or past the sign bit,
producing undefined/implementation-defined behavior.
- The 32-bit intermediate result is too narrow to hold a 36-bit value,
causing silent truncation before the OR-reduction.
Fix by casting each byte to uint64_t prior to the shift, ensuring all
intermediate expressions are evaluated in a 64-bit unsigned domain and
all 36 bits are preserved without overflow.