Fix armhf (#1315)
* Fix unaligned memory accesses with get_u_int64_t at armhf see: https://bugs.debian.org/993627 * Use get_u_int64_t to avoid unaligned memory access at armhf see: https://bugs.debian.org/993627 * Update src/include/ndpi_define.h.in Drop const type from get_u_int64_t, from lnslbrty Co-authored-by: Bernhard Übelacker <bernhardu@mailbox.org> Co-authored-by: Toni <matzeton@googlemail.com>
This commit is contained in:
co-authored by
Bernhard Übelacker
Toni
parent
5ed1930a93
commit
eac7024489
@@ -319,7 +319,16 @@
|
||||
#define get_u_int8_t(X,O) (*(u_int8_t *)((&(((u_int8_t *)X)[O]))))
|
||||
#define get_u_int16_t(X,O) (*(u_int16_t *)((&(((u_int8_t *)X)[O]))))
|
||||
#define get_u_int32_t(X,O) (*(u_int32_t *)((&(((u_int8_t *)X)[O]))))
|
||||
#if defined(__arm__)
|
||||
static inline u_int64_t get_u_int64_t(const u_int8_t* X, int O)
|
||||
{
|
||||
u_int64_t tmp;
|
||||
memcpy(&tmp, X + O, sizeof(tmp));
|
||||
return tmp;
|
||||
}
|
||||
#else
|
||||
#define get_u_int64_t(X,O) (*(u_int64_t *)((&(((u_int8_t *)X)[O]))))
|
||||
#endif // __arm__
|
||||
|
||||
/* new definitions to get little endian from network bytes */
|
||||
#define get_ul8(X,O) get_u_int8_t(X,O)
|
||||
|
||||
@@ -196,14 +196,7 @@ int quic_len(const uint8_t *buf, uint64_t *value)
|
||||
*value = ntohl(*(uint32_t *)buf) & 0x3FFFFFFF;
|
||||
return 4;
|
||||
case 3:
|
||||
{
|
||||
u_int64_t n;
|
||||
|
||||
/* Necessary as simple cast crashes on ARM */
|
||||
memcpy(&n, buf, sizeof(u_int64_t));
|
||||
|
||||
*value = ndpi_ntohll(n) & 0x3FFFFFFFFFFFFFFF;
|
||||
}
|
||||
*value = ndpi_ntohll(get_u_int64_t(buf, 0)) & 0x3FFFFFFFFFFFFFFF;
|
||||
return 8;
|
||||
default: /* No Possible */
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user