on 11/13/01 7:13 AM, Bob Dalgleish at [EMAIL PROTECTED]
wrote:
> I upgraded Perl to 5.6.1 last week. I then installed Bundle::libnet, using
> CPAN. The test for libnet failed in config.t with this error:
>
> not ok 4 # ... should return -1 without a valid hostname
>
> looking at the code, it is a test of Socket::inet_aton(), which translates
> an address to a 32-bit integer. It is supposed to return 'undef' when passed
> a bad address; it does not.
It is specific to Mac OS X. The function called inet_aton() should,
theoretically, return a failure code when handed an empty string, but does
not. Comparing with a Compaq-Tru64 computer nearby which does return a
failure code, I concluded that there was a discrepancy. In fact, the
Socket.xs code included with the Perl package had an implementation of
inet_aton which exhibited the same problem :-}
The fix is to add an error check in Socket.xs. Following is the contextual
difference between the revised, working copy and the original. Use the
'patch(1)' program to fix it.
*** ext/Socket/Socket.xs Sun Nov 25 08:21:26 2001
--- ext/Socket/Socket.xs.orig Sat Nov 24 10:28:45 2001
***************
*** 916,922 ****
{
struct in_addr ip_address;
struct hostent * phe;
! int ok = host && *host && inet_aton(host, &ip_address);
if (!ok && (phe = gethostbyname(host))) {
Copy( phe->h_addr, &ip_address, phe->h_length, char );
--- 916,922 ----
{
struct in_addr ip_address;
struct hostent * phe;
! int ok = inet_aton(host, &ip_address);
if (!ok && (phe = gethostbyname(host))) {
Copy( phe->h_addr, &ip_address, phe->h_length, char );