cleanup: avoid unsafe typecasts

Avoid the risk of reading 16bit data from an unaligned address by using
a macro that is adapted for this.
pull/3/head
Daniel Stenberg 14 years ago
parent 70b726c334
commit 2d5ed6400b
  1. 2
      ares_parse_mx_reply.c
  2. 6
      ares_parse_srv_reply.c

@ -134,7 +134,7 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen,
mx_last = mx_curr;
vptr = aptr;
mx_curr->priority = ntohs (*((unsigned short *)vptr));
mx_curr->priority = DNS__16BIT(vptr);
vptr += sizeof(unsigned short);
status = ares_expand_name (vptr, abuf, alen, &mx_curr->host, &len);

@ -139,11 +139,11 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,
srv_last = srv_curr;
vptr = aptr;
srv_curr->priority = ntohs (*((unsigned short *)vptr));
srv_curr->priority = DNS__16BIT(vptr);
vptr += sizeof(unsigned short);
srv_curr->weight = ntohs (*((unsigned short *)vptr));
srv_curr->weight = DNS__16BIT(vptr);
vptr += sizeof(unsigned short);
srv_curr->port = ntohs (*((unsigned short *)vptr));
srv_curr->port = DNS__16BIT(vptr);
vptr += sizeof(unsigned short);
status = ares_expand_name (vptr, abuf, alen, &srv_curr->host, &len);

Loading…
Cancel
Save