You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/06/10 05:12:33 UTC

[GitHub] [incubator-nuttx] Virus-V commented on a change in pull request #3889: net/dns:fix unaligned access in dns query

Virus-V commented on a change in pull request #3889:
URL: https://github.com/apache/incubator-nuttx/pull/3889#discussion_r648854382



##########
File path: libs/libc/netdb/lib_dnsquery.c
##########
@@ -439,8 +440,11 @@ static int dns_recv_response(int sd, FAR union dns_addr_u *addr, int naddr,
   ninfo("Question: type=%04x, class=%04x\n",
         ntohs(que->type), ntohs(que->class));
 
-  if (que->type  != qinfo->rectype ||
-      que->class != HTONS(DNS_CLASS_IN))
+  /* N.B. Unaligned access may occur here */
+
+  temp = HTONS(DNS_CLASS_IN);
+  if (memcmp(&que->type, &qinfo->rectype, sizeof(uint16_t)) != 0 ||

Review comment:
       No, DNS request/response struct are packed, changing buffer type does not work.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org