[prev in list] [next in list] [prev in thread] [next in thread] 

List:       uclibc
Subject:    [uClibc] Question about sscanf/gcc 3.3.3 and squid
From:       mjn3 () codepoet ! org (Manuel Novoa III)
Date:       2005-03-29 20:47:41
Message-ID: 20050330034739.GA1185 () codepoet ! org
[Download RAW message or body]

I rewrote the scanf functions about a year and a half ago.
The versions prior to that were broken in several ways.

Manuel


On Wed, Mar 30, 2005 at 01:16:27AM +0200, Arne Bernin wrote:
> Hi all!
> 
> i have a tricky problem here while trying to compile
> squid (2.5Stable5) against uclibc 0.9.20 (yes, i know,
> its old ;-) using gcc3.3.
> 
> squid uses a function to decide whether it likes 
> an ip address used in acls using a function
> safe_inet_addr. this should return 1 in case
> the address is ok. But it fails, using an address
> of "0.0.0.0" causes sscanf to return 5...
> But it works, if i put the printf line ("the magic
> code") in there. I was not able to reproduce it
> with a small program just using safe_inet_addr,
> so i assume, this is some kind of gcc related bug ?
> or has it something to do with uclibc ??
> Maybe i should mention that the function calling
> safe_inet_addr calls a sscanf on the address itself,
> which returns 4 like it should...
> I just don't really understand what is happening here,
> so maybe someone can give me a hint.
> 
> 
> int
> safe_inet_addr(const char *buf, struct in_addr *addr)
> {
>     static char addrbuf[32];
>     int a1 = 0, a2 = 0, a3 = 0, a4 = 0;
>     struct in_addr A;
>     char x;
>     /* the magic line: without it, sscanf fails*/
>     printf("buf=%s\n",buf);
> 
>     if (sscanf(buf, "%d.%d.%d.%d%c", &a1, &a2, &a3, &a4, &x) != 4)
>         return 0;
>     if (a1 < 0 || a1 > 255)
>         return 0;
>     if (a2 < 0 || a2 > 255)
>         return 0;
>     if (a3 < 0 || a3 > 255)
>         return 0;
>     if (a4 < 0 || a4 > 255)
>         return 0;
> 
> 
> thanks for any help,
>                       arne
> 
> 
> -- 
> Arne Bernin <arne@alamut.de>
> 

> _______________________________________________
> uClibc mailing list
> uClibc@uclibc.org
> http://uclibc.org/mailman/listinfo/uclibc

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic