[uClibc] Question about sscanf/gcc 3.3.3 and squid

Manuel Novoa III mjn3 at codepoet.org
Wed Mar 30 03:47:39 UTC 2005


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 at alamut.de>
> 

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




More information about the uClibc mailing list