public inbox for glibc-bugs-regex@sourceware.org
help / color / mirror / Atom feed
* [Bug regex/6722] New: sscanf bug when parsing lines from /proc/net/tcp
@ 2008-07-04 20:04 lists at roberthogan dot net
  2008-07-07  9:36 ` [Bug regex/6722] " halesh dot s at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: lists at roberthogan dot net @ 2008-07-04 20:04 UTC (permalink / raw)
  To: glibc-bugs-regex

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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-07-08 17:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-04 20:04 [Bug regex/6722] New: sscanf bug when parsing lines from /proc/net/tcp lists at roberthogan dot net
2008-07-07  9:36 ` [Bug regex/6722] " halesh dot s at gmail dot com
2008-07-07 18:49 ` lists at roberthogan dot net
2008-07-07 19:19 ` schwab at suse dot de
2008-07-07 19:43 ` jakub at redhat dot com
2008-07-08  4:10 ` halesh dot s at gmail dot com
2008-07-08  7:46 ` halesh dot s at gmail dot com
2008-07-08  7:54 ` jakub at redhat dot com
2008-07-08 17:53 ` lists at roberthogan dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).