IES_DECODE_U16 macro: load from 16-bit aligned address
The IES_DECODE_U16 macro loads a 16 bit integer from an arbitrary
address; this can lead to reads from misaligned addresses, and undefined
behavior sanitizer warns, like, e.g., so:
openair3/NAS/COMMON/IES/ProtocolConfigurationOptions.c:62:5: runtime error: load of misaligned address 0x7f3c24032c01 for type 'uint16_t', which requires 2 byte alignment
To fix this, first use memcpy() to load to a 16-bit aligned address,
then do the actual decoding.
This commit is contained in:
committed by
Laurent THOMAS
parent
71bd10b4a2
commit
e94f59edb1
@@ -62,8 +62,12 @@
|
||||
#define IES_DECODE_U8(bUFFER, dECODED, vALUE) \
|
||||
DECODE_U8(bUFFER + dECODED, vALUE, dECODED)
|
||||
|
||||
#define IES_DECODE_U16(bUFFER, dECODED, vALUE) \
|
||||
DECODE_U16(bUFFER + dECODED, vALUE, dECODED)
|
||||
#define IES_DECODE_U16(bUFFER, dECODED, vALUE) \
|
||||
do { \
|
||||
uint16_t val; \
|
||||
memcpy(&val, bUFFER + dECODED, sizeof(val)); \
|
||||
DECODE_U16(&val, vALUE, dECODED); \
|
||||
} while (0)
|
||||
|
||||
#define IES_DECODE_U24(bUFFER, dECODED, vALUE) \
|
||||
DECODE_U24(bUFFER + dECODED, vALUE, dECODED)
|
||||
|
||||
Reference in New Issue
Block a user