1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] Committed host.c patch from <dpk8i3za97.fsf_-_@mraz.iskon.hr>.

This commit is contained in:
hniksic 2000-04-14 02:31:21 -07:00
parent 0a8054755c
commit 094481c386
2 changed files with 12 additions and 18 deletions

View File

@ -1,3 +1,8 @@
2000-04-12 Hrvoje Niksic <hniksic@iskon.hr>
* host.c (store_hostaddress): Instead of shifting ADDR, start
copying from the correct address.
2000-04-12 Hrvoje Niksic <hniksic@iskon.hr> 2000-04-12 Hrvoje Niksic <hniksic@iskon.hr>
* http.c (gethttp): Don't free REQUEST -- it was allocated with * http.c (gethttp): Don't free REQUEST -- it was allocated with

View File

@ -144,26 +144,15 @@ store_hostaddress (unsigned char *where, const char *hostname)
/* If we have the numeric address, just store it. */ /* If we have the numeric address, just store it. */
if ((int)addr != -1) if ((int)addr != -1)
{ {
/* This works on both little and big endian architecture, as /* ADDR is in network byte order, meaning the code works on
inet_addr returns the address in the proper order. */ 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 #ifdef WORDS_BIGENDIAN
if (sizeof (addr) == 8) offset = sizeof (unsigned long) - 4;
{
/* We put the shift amount in a variable because it quiets gcc -Wall's
warning on 32-bit-address systems: "warning: left shift count >=
width of type". The optimizer should constant-fold away this
variable (you'd think the warning would come back with maximum
optimization turned on, but it doesn't, on gcc 2.8.1, at least).
Not sure if there's a cleaner way to get rid of the warning -- can
this code be surrounded by an #ifdef that's never active on 32-bit
systems? Is there no way to check at configure-time whether we'll
ever potentially encounter a 64-bit address? */
int shift_amount = 32;
addr <<= shift_amount;
}
#endif #endif
memcpy (where, &addr, 4); memcpy (where, (char *)&addr + offset, 4);
return 1; return 1;
} }
/* Since all else has failed, let's try gethostbyname(). Note that /* Since all else has failed, let's try gethostbyname(). Note that