Date: Wed, 12 Dec 2001 15:29:35 -0700 From: Dan Peterson <danp@danp.net> To: Jos Backus <josb@cncdsl.com> Cc: freebsd-hackers@freebsd.org Subject: Re: sscanf(..., "%lld", ...) broken? Message-ID: <20011212152935.A7286@danp.net> In-Reply-To: <20011210201611.GB595@lizzy.bugworks.com>; from josb@cncdsl.com on Mon, Dec 10, 2001 at 12:15:49PM -0801 References: <20011210201611.GB595@lizzy.bugworks.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Jos Backus <josb@cncdsl.com> wrote:
> Is this PR-worthy? I am seeing this in both -stable and -current. The lftp
> author claims it's our bug, not his.
>
> > It seems to me that sscanf on FreeBSD does not correctly handle long
> > long type (%lld). There is another similar report, the reporter says
> > that initializing the variable to 0 before sscanf helps. This indicates
> > a bug in the libc library. You can report a bug to FreeBSD team.
I was the other reporter, and initializing the size_ll variable to 0 does
fix it for me (be sure to do it in both the FTP listing code and the FTP
mirroring code, though). Alexander provided this code to verify that it's a
libc problem (it exits 1 for me under -STABLE):
int main()
{
unsigned long long x=0,x1;
long long y=0,y1;
char buf[128];
x=~x;
sscanf("0","%llu",&x);
if(x!=0) return 1;
y=~y;
sscanf("0","%lld",&y);
if(y!=0) return 1;
x=~x;
sprintf(buf,"%lld %llu",y,x);
sscanf (buf,"%lld %llu",&y1,&x1);
if(x!=x1 || y!=y1)
return 1;
return 0;
}
EPLF listing works fine in lftp-2.4.4 and before without patching which
baffles me (the lftp code still uses sscanf).
--
Dan Peterson <danp@danp.net> http://danp.net
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011212152935.A7286>
