aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-04-19 11:00:26 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-04-19 11:00:26 +0000
commit381f77756dc6c6e15ca4b8fbda35c0f3e3cde26c (patch)
treeb57a2fc7387312a0d49b490b82de4a3b5c0b14a9 /lib
parenta386562d9a3a351abd567a620a93e4926ce68944 (diff)
pack_hostent does not handle 64 bit pointers correctly.
A Bjørn Reese patch.
Diffstat (limited to 'lib')
-rw-r--r--lib/hostip.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/hostip.c b/lib/hostip.c
index e3daab1ff..a085ece04 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -377,10 +377,12 @@ static struct hostent* pack_hostent(char* buf, struct hostent* orig)
bufptr += len;
/* we align on even 64bit boundaries for safety */
-#define MEMALIGN(x) (((unsigned long)(x)&0xfffffff8)+8)
+#define MEMALIGN(x) ((x)+(8-(((unsigned long)(x))&0x7)))
/* This must be aligned properly to work on many CPU architectures! */
- copy->h_aliases = (char**)MEMALIGN(bufptr);
+ bufptr = MEMALIGN(bufptr);
+
+ copy->h_aliases = (char**)bufptr;
/* Figure out how many aliases there are */
for (i = 0; orig->h_aliases[i] != NULL; ++i);
@@ -402,7 +404,7 @@ static struct hostent* pack_hostent(char* buf, struct hostent* orig)
copy->h_length = orig->h_length;
/* align it for (at least) 32bit accesses */
- bufptr = (char *)MEMALIGN(bufptr);
+ bufptr = MEMALIGN(bufptr);
copy->h_addr_list = (char**)bufptr;