]> sjero.net Git - wget/blobdiff - src/host.c
[svn] Updated long_to_string(); enhanced opt.downloaded to use
[wget] / src / host.c
index 03a56fe57cd07a46dee12da1b352363d0e56d75e..1ff8150f60c07fa63209fb5867222adcf781c536 100644 (file)
@@ -144,13 +144,15 @@ store_hostaddress (unsigned char *where, const char *hostname)
   /* If we have the numeric address, just store it.  */
   if ((int)addr != -1)
     {
-      /* This works on both little and big endian architecture, as
-        inet_addr returns the address in the proper order.  */
+      /* ADDR is in network byte order, meaning the code works on
+         little and big endian 32-bit architectures without change.
+         On big endian 64-bit architectures we need to be careful to
+         copy the correct four bytes.  */
+      int offset = 0;
 #ifdef WORDS_BIGENDIAN
-      if (sizeof (addr) == 8)
-       addr <<= 32;
+      offset = sizeof (unsigned long) - 4;
 #endif
-      memcpy (where, &addr, 4);
+      memcpy (where, (char *)&addr + offset, 4);
       return 1;
     }
   /* Since all else has failed, let's try gethostbyname().  Note that