This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug regex/6722] New: sscanf bug when parsing lines from /proc/net/tcp
- From: "lists at roberthogan dot net" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 4 Jul 2008 20:03:15 -0000
- Subject: [Bug regex/6722] New: sscanf bug when parsing lines from /proc/net/tcp
- Reply-to: sourceware-bugzilla at sourceware dot org
Using:
len = sscanf(big_str, "%*d: %8x:%4x %8x:%4x"
" %*2x %*8x:%*8x %*2x:%*8x %*8x %d %*d %u \n",
&locaddr, (unsigned int *) &locport, &remaddr, (unsigned int *) &remport,
&uid, &inode);
on
8: 00000000:008B 00000000:0000 0A 00000000:00000000 00:00000000 00000000
0 0 9678 1 ec772480 750 0 0 2 -1
(i.e. a line from /proc/net/tcp)
leaves locport (which should be the contents of 008B) at 0.
To work around this problem I have had to do the following:
len = sscanf(big_str, "%*d: %*8x:%*4x %*8x:%*4x"
" %*2x %*8x:%*8x %*2x:%*8x %*8x %d %*d %*u \n",
&uid);
len += sscanf(big_str, "%*d: %*8x:%*4x %8x:%4x"
" %*2x %*8x:%*8x %*2x:%*8x %*8x %*d %*d %*u \n",
&remaddr, (unsigned int *) &remport);
len += sscanf(big_str, "%*d: %8x:%4x \n",
&locaddr, &locport);
len += sscanf(big_str, "%*d: %*8x:%*4x %*8x:%*4x"
" %*2x %*8x:%*8x %*2x:%*8x %*8x %*d %*d %u \n",
&inode);
(The 4 calls are the first series I tried that worked. The first combinations
of 2 or 3 calls I used resulted in one or other of the variables being
clobbered to 0.)
Host type: i486-slackware-linux-gnu
System: Linux darkstar 2.6.24.4-smp #1 SMP Wed Apr 9 15:27:38 CDT 2008 i686
Intel(R) Celeron(R) CPU 2.40GHz GenuineIntel GNU/Linux
Architecture: i686
Addons: linuxthreads
Build CFLAGS: -g -O2 -march=i486 -mcpu=i686
Build CC: i486-slackware-linux-gcc
Compiler version: 3.3.3
Kernel headers: UTS_RELEASE
Symbol versioning: yes
Build static: yes
Build shared: yes
Build pic-default: no
Build profile: yes
Build omitfp: no
Build bounded: no
Build static-nss: no
--
Summary: sscanf bug when parsing lines from /proc/net/tcp
Product: glibc
Version: 2.3.2
Status: NEW
Severity: normal
Priority: P2
Component: regex
AssignedTo: drepper at redhat dot com
ReportedBy: lists at roberthogan dot net
CC: glibc-bugs-regex at sources dot redhat dot com,glibc-
bugs at sources dot redhat dot com,lists at roberthogan
dot net
GCC build triplet: i486-slackware-linux-gcc
GCC host triplet: i486-slackware-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=6722
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.