Skip to content

Fix misalignment issues in TLVEncoder macros ENCODE_U16, ENCODE_U24

Guido Casati requested to merge TLV_Encoder_Fixes into develop

This MR resolves undefined behavior runtime errors related to misaligned memory access. E.g.

openair3/NAS/COMMON/IES/FGSMobileIdentity.c:193:3: runtime error: store to misaligned address 0x608000021e2b for type 'uint16_t', which requires 2 byte alignment 0x608000021e2b: note: pointer points here 00 f1 ...

  • ENCODE_U24: safely encode 24-bit values into a buffer by using memcpy to copy 3 bytes in network byte order (big-endian).
  • ENCODE_U16: safely encodes a 16-bit value into a buffer, handling misalignment by memcpy 2 bytes to buffer in network byte order (big-endian).

Merge request reports