On Sat, 6 Apr 2002, Dr Andreas F Muller wrote:

> 
> --- LPRng-3.8.10/src/common/linksupport.c       Mon Apr  1 19:54:51 2002
> +++ LPRng-3.8.10-patched/src/common/linksupport.c       Sat Apr  6 12:55:14 2002
> @@ -1462,7 +1462,7 @@
>  #if !defined(INADDR_NONE)
>  #define INADDR_NONE (-1)
>  #endif
> -       if( inet_addr( strptr ) != INADDR_NONE ){
> +       if( inet_addr( strptr ) != (in_addr_t)INADDR_NONE ){
>                 ((unsigned long *)addr)[0] = inet_addr( strptr );
>                 return(1);
>         }
> 


On my linux system no such thing as in_addr_t.  Comparing to 0xffffffffUL
should be safe.

Appart from that:


Seing this code, though, I got suspicious about the cast to (unsigned
long *): what would happen on systems where longs are 64 bits and
not 32 bits?  If the system is little endian you would copy an addition
4 byts of binary zeroes, but on big endian system you would copy 4 binary
zeroes to addr followed by the 4 bytes of the internet address.

Anyone done a porting on big endian 64bit systems?  64bit Solaris should
qualify.

You might consider to create a temporary structure of type in_addr, move
the result from inet_addr() to the s_addr member of that structure and
them memcpy the structure to the area pointed to by addr.  Then you don't
need to call inet_addr more than once, too, although I don't think this is
a very expensive function.

Or, if you trust that uit32_t is defined somewhere, you can cast to
(uint32_t *) instead.  Some systems may have u_int32_t instead, and 
some have neither, so this may not be portable everywhere.


If those systems do HAVE_INET_ATON that problem would become a non-issue.


Villy


-----------------------------------------------------------------------------
YOU MUST BE A LIST MEMBER IN ORDER TO POST TO THE LPRNG MAILING LIST
The address you post from MUST be your subscription address

If you need help, send email to [EMAIL PROTECTED] (or lprng-requests
or lprng-digest-requests) with the word 'help' in the body.  For the impatient,
to subscribe to a list with name LIST,  send mail to [EMAIL PROTECTED]
with:                           | example:
subscribe LIST <mailaddr>       |  subscribe lprng-digest [EMAIL PROTECTED]
unsubscribe LIST <mailaddr>     |  unsubscribe lprng [EMAIL PROTECTED]

If you have major problems,  send email to [EMAIL PROTECTED] with the word
LPRNGLIST in the SUBJECT line.
-----------------------------------------------------------------------------

Reply via email to