diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2020-04-06 17:33:01 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-06 17:33:01 +0200 | 
| commit | 9eaeaee1c763289350e74ebf131eb18c2665b585 (patch) | |
| tree | 7b5db349ef184767e731cda971ca01c9d6e19f7d /pimd | |
| parent | b71f5218db1e5eb6479691ffa2684308b2beecbe (diff) | |
| parent | c181a7d5baa2b63fa9433cf3b5c77393473bc58e (diff) | |
Merge pull request #6159 from qlyoung/fix-pim-tlv-unaligned-pointer-access
pimd: fix unaligned pointer access
Diffstat (limited to 'pimd')
| -rw-r--r-- | pimd/pim_tlv.h | 14 | 
1 files changed, 12 insertions, 2 deletions
diff --git a/pimd/pim_tlv.h b/pimd/pim_tlv.h index 657675b312..ef764656d3 100644 --- a/pimd/pim_tlv.h +++ b/pimd/pim_tlv.h @@ -48,8 +48,18 @@ typedef uint32_t pim_hello_options;  #define PIM_OPTION_UNSET(options, option_mask) ((options) &= ~(option_mask))  #define PIM_OPTION_IS_SET(options, option_mask) ((options) & (option_mask)) -#define PIM_TLV_GET_UINT16(buf) ntohs(*(const uint16_t *)(buf)) -#define PIM_TLV_GET_UINT32(buf) ntohl(*(const uint32_t *)(buf)) +#define PIM_TLV_GET_UINT16(buf)                                                \ +	({                                                                     \ +		uint16_t _tmp;                                                 \ +		memcpy(&_tmp, (buf), sizeof(uint16_t));                        \ +		ntohs(_tmp);                                                   \ +	}) +#define PIM_TLV_GET_UINT32(buf)                                                \ +	({                                                                     \ +		uint32_t _tmp;                                                 \ +		memcpy(&_tmp, (buf), sizeof(uint32_t));                        \ +		ntohl(_tmp);                                                   \ +	})  #define PIM_TLV_GET_TYPE(buf) PIM_TLV_GET_UINT16(buf)  #define PIM_TLV_GET_LENGTH(buf) PIM_TLV_GET_UINT16(buf)  #define PIM_TLV_GET_HOLDTIME(buf) PIM_TLV_GET_UINT16(buf)  | 
