From 4de0e626d0b07b5fb32bfa64f47521c0ca7b2f2a Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Thu, 7 Apr 2022 13:52:32 +0800 Subject: [PATCH] Revert "netdb: fix access within misaligned address error" This reverts commit 3f94828f6b53f641b42e94d48a032cf24aff5b0e. Signed-off-by: zhanghongyu --- libs/libc/netdb/lib_dnsquery.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libs/libc/netdb/lib_dnsquery.c b/libs/libc/netdb/lib_dnsquery.c index a68371866b..6b160380e7 100644 --- a/libs/libc/netdb/lib_dnsquery.c +++ b/libs/libc/netdb/lib_dnsquery.c @@ -336,7 +336,6 @@ static int dns_recv_response(int sd, FAR union dns_addr_u *addr, int naddr, FAR struct dns_answer_s *ans; FAR struct dns_header_s *hdr; FAR struct dns_question_s *que; - struct dns_question_s bak; uint16_t nquestions; uint16_t nanswers; uint16_t temp; @@ -440,13 +439,12 @@ static int dns_recv_response(int sd, FAR union dns_addr_u *addr, int naddr, /* Validate query type and class */ que = (FAR struct dns_question_s *)nameptr; - memcpy(&bak, que, sizeof(struct dns_question_s)); /* N.B. Unaligned access may occur here */ temp = HTONS(DNS_CLASS_IN); - if (memcmp(&bak.type, &qinfo->rectype, sizeof(uint16_t)) != 0 || - memcmp(&bak.class, &temp, sizeof(uint16_t)) != 0) + if (memcmp(&que->type, &qinfo->rectype, sizeof(uint16_t)) != 0 || + memcmp(&que->class, &temp, sizeof(uint16_t)) != 0) { nerr("ERROR: DNS response with wrong question\n"); return -EBADMSG;