Date: Wed, 29 Dec 2004 23:59:32 +0100 (CET) From: Pawel Malachowski <pawmal-posting@freebsd.lublin.pl> To: FreeBSD-gnats-submit@FreeBSD.org Cc: venglin@freebsd.lublin.pl Subject: bin/75638: sscanf %lld broken on 4.x Message-ID: <20041229225932.5AB3A347116@shellma.zin.lublin.pl> Resent-Message-ID: <200412292300.iBTN0kLY022533@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 75638
>Category: bin
>Synopsis: sscanf %lld broken on 4.x
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Dec 29 23:00:46 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator: Paweł Małachowski
>Release: FreeBSD 4.11-STABLE i386
>Organization:
ZiN
>Environment:
System: FreeBSD 4.11-STABLE #20: Sat Dec 18 19:32:41 CET 2004
>Description:
sscanf(s, "%lld", &l) will not set l to valid value if l was previously
not zero.
For example, ports/net-mgmt/iftop `max-bandwidth' option is broken on 4.x because of this.
>How-To-Repeat:
#include <stdio.h>
void main(void) {
char *s = "10";
long long l;
int rc = 0;
rc = sscanf(s, "%lld", &l);
fprintf(stderr, "rc %d, s %s, l %lld\n", rc, s, l);
}
output on 4.x:
rc 1, s 10, l -4629710020483743734
output on 5.3:
rc 1, s 10, l 10
>Fix:
Workaround: set lld value to zero before using it with sscanf (noticed by venglin).
#include <stdio.h>
void main(void) {
char *s = "10";
long long l = 0;
int rc = 0;
rc = sscanf(s, "%lld", &l);
fprintf(stderr, "rc %d, s %s, l %lld\n", rc, s, l);
}
output on 4.x:
rc 1, s 10, l 10
>Release-Note:
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041229225932.5AB3A347116>
