Fixed READSHORT/LONG to avoid bus error on sparc

This commit is contained in:
Erik Ekman 2006-06-08 18:50:40 +00:00
parent f2f163adbd
commit b93577fbc0
2 changed files with 8 additions and 4 deletions

6
dns.c
View file

@ -83,10 +83,12 @@ readname(char *packet, char *dst, char *src)
#define READNAME(packet, dst, src) (src) += readname((packet), (dst), (src)); #define READNAME(packet, dst, src) (src) += readname((packet), (dst), (src));
#define READSHORT(dst, src) \ #define READSHORT(dst, src) \
(dst) = ntohs(*(short*)(src)); (src)+=2; memcpy(&dst, src, 2); \
(dst) = ntohs(dst); (src)+=2;
#define READLONG(dst, src) \ #define READLONG(dst, src) \
(dst) = ntohl(*(long*)(src)); (src)+=4; memcpy(&dst, src, 2); \
(dst) = ntohl(dst); (src)+=4;
#define READDATA(dst, src, len) \ #define READDATA(dst, src, len) \
memcpy((dst), (src), (len)); (src)+=(len); memcpy((dst), (src), (len)); (src)+=(len);

6
dnsd.c
View file

@ -89,10 +89,12 @@ readname(char *packet, char *dst, char *src)
#define READNAME(packet, dst, src) (src) += readname((packet), (dst), (src)); #define READNAME(packet, dst, src) (src) += readname((packet), (dst), (src));
#define READSHORT(dst, src) \ #define READSHORT(dst, src) \
(dst) = ntohs(*(short*)(src)); (src)+=2; memcpy(&dst, src, 2); \
(dst) = ntohs(dst); (src)+=2;
#define READLONG(dst, src) \ #define READLONG(dst, src) \
(dst) = ntohl(*(long*)(src)); (src)+=4; memcpy(&dst, src, 2); \
(dst) = ntohl(dst); (src)+=4;
#define READDATA(dst, src, len) \ #define READDATA(dst, src, len) \
memcpy((dst), (src), (len)); (src)+=(len); memcpy((dst), (src), (len)); (src)+=(len);