Browse Source

TT#14008 fix unaligned 64-bit memory access

Change-Id: I429afb528c68c78a1a4755e52a466e1282beffc2
mr10.4
Richard Fuchs 4 years ago
parent
commit
b2ae39a67f
1 changed files with 8 additions and 2 deletions
  1. +8
    -2
      daemon/stun.c

+ 8
- 2
daemon/stun.c View File

@ -113,6 +113,12 @@ struct software {
/* XXX add const in functions */ /* XXX add const in functions */
static uint64_t be64toh_unaligned(const char *s) {
uint64_t u;
memcpy(&u, s, sizeof(u));
return be64toh(u);
}
static int stun_attributes(struct stun_attrs *out, str *s, uint16_t *unknowns, struct header *req) { static int stun_attributes(struct stun_attrs *out, str *s, uint16_t *unknowns, struct header *req) {
struct tlv *tlv; struct tlv *tlv;
int len, type, uc; int len, type, uc;
@ -170,7 +176,7 @@ static int stun_attributes(struct stun_attrs *out, str *s, uint16_t *unknowns, s
return -1; return -1;
if (attr.len != 8) if (attr.len != 8)
return -1; return -1;
out->tiebreaker = be64toh(*((uint64_t *) attr.s));
out->tiebreaker = be64toh_unaligned(attr.s);
out->controlled = 1; out->controlled = 1;
break; break;
@ -179,7 +185,7 @@ static int stun_attributes(struct stun_attrs *out, str *s, uint16_t *unknowns, s
return -1; return -1;
if (attr.len != 8) if (attr.len != 8)
return -1; return -1;
out->tiebreaker = be64toh(*((uint64_t *) attr.s));
out->tiebreaker = be64toh_unaligned(attr.s);
out->controlling = 1; out->controlling = 1;
break; break;


Loading…
Cancel
Save