瀏覽代碼

Fix byte alignment issue

Nick Peng 6 年之前
父節點
當前提交
aaca1c013b
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5 5
      src/dns.c

+ 5 - 5
src/dns.c

@@ -622,15 +622,15 @@ int dns_add_SOA(struct dns_packet *packet, dns_rr_type type, char *domain, int t
 	ptr += strnlen(soa->mname, DNS_MAX_CNAME_LEN - 1) + 1;
 	safe_strncpy((char *)ptr, soa->rname, DNS_MAX_CNAME_LEN);
 	ptr += strnlen(soa->rname, DNS_MAX_CNAME_LEN - 1) + 1;
-	*((unsigned int *)ptr) = soa->serial;
+	memcpy(ptr, &soa->serial, sizeof(unsigned int));
 	ptr += 4;
-	*((unsigned int *)ptr) = soa->refresh;
+	memcpy(ptr, &soa->refresh, sizeof(unsigned int));
 	ptr += 4;
-	*((unsigned int *)ptr) = soa->retry;
+	memcpy(ptr, &soa->retry, sizeof(unsigned int));
 	ptr += 4;
-	*((unsigned int *)ptr) = soa->expire;
+	memcpy(ptr, &soa->expire, sizeof(unsigned int));
 	ptr += 4;
-	*((unsigned int *)ptr) = soa->minimum;
+	memcpy(ptr, &soa->minimum, sizeof(unsigned int));
 	ptr += 4;
 	len = ptr - data;