Problem in SQUID 1.0beta11 on Linux/AXP

From: Nigel Metheringham <Nigel.Metheringham@dont-contact.us>
Date: Mon, 03 Jun 1996 17:25:47 +0100

A minor code change in dnsserver.c between beta7 and beta11 broke
squid on Linux/AXP (ie 64 bit DEC alpha processor).

Basically the code is now doing something like this:-

        if (inet_addr(buf) != -1) {

this test is never false, since inet_addr returns a 32 bit value in a
64 bit variable, so it can never be -1.

Someone who knows more of this than I wrote...

David Mosberger-Tang <davidm@AZStarNet.com> said:
} inet_addr() returns INADDR_NONE in case of failure. It is wrong to
} test for -1 (the Linux man-page is incorrect in this respect). OSF/1
} declare inet_addr() to return an "unsigned int" which works around
} the problem, but it is apparently inconsistent with one of the POSIX
} standards. The correct way to test the return value of inet_addr is:

} if (inet_addr(ip) == INADDR_NONE)

} or, if you insist on using -1 instead of INADDR_NONE:

} if ((int32_t) inet_addr(ip) == -1)

} An even better solution is to use inet_aton():

} if (!inet_aton (ip, NULL))

} because this will work even in the case "ip" specifies a local
} broadcast address.

        Nigel.

-- 
[ Nigel.Metheringham@theplanet.net   - Unix Applications Engineer ]
[ *Views expressed here are personal and not supported by PLAnet* ]
[ PLAnet Online : The White House          Tel : +44 113 251 6012 ]
[ Melbourne Street, Leeds LS2 7PS UK.      Fax : +44 113 2345656  ]
Received on Mon Jun 03 1996 - 09:26:21 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:32:28 MST