]> sjero.net Git - wget/blobdiff - src/host.c
[svn] Updated long_to_string(); enhanced opt.downloaded to use
[wget] / src / host.c
index f741cdc737eac47e7a9fbf86a3d194c8fe09270b..1ff8150f60c07fa63209fb5867222adcf781c536 100644 (file)
@@ -144,10 +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.  It
-        appears to work on 64-bit machines too.  */
-      memcpy (where, &addr, 4);
+      /* 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
+      offset = sizeof (unsigned long) - 4;
+#endif
+      memcpy (where, (char *)&addr + offset, 4);
       return 1;
     }
   /* Since all else has failed, let's try gethostbyname().  Note that
@@ -395,7 +400,7 @@ sufmatch (const char **list, const char *what)
   for (i = 0; list[i]; i++)
     {
       for (j = strlen (list[i]), k = lw; j >= 0 && k >= 0; j--, k--)
-       if (tolower (list[i][j]) != tolower (what[k]))
+       if (TOLOWER (list[i][j]) != TOLOWER (what[k]))
          break;
       /* The domain must be first to reach to beginning.  */
       if (j == -1)