public inbox for glibc-bugs-regex@sourceware.org
help / color / mirror / Atom feed
From: "halesh dot s at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs-regex@sources.redhat.com
Subject: [Bug regex/6722] sscanf bug when parsing lines from /proc/net/tcp
Date: Mon, 07 Jul 2008 09:36:00 -0000	[thread overview]
Message-ID: <20080707093558.26248.qmail@sourceware.org> (raw)
In-Reply-To: <20080704200314.6722.lists@roberthogan.net>


------- Additional Comments From halesh dot s at gmail dot com  2008-07-07 09:35 -------
Hi Robert,

Please check the below testcase..

$cat test.c
#include <stdio.h>
int main()
{

        FILE *f;
        int locaddr, locport, remaddr, remport, uid, inode;
        char big_str[256];

        f = fopen("/proc/net/tcp", "r");

        fgets(big_str,256,f);
        printf("%s\n", big_str);

        fgets(big_str,256,f);
        printf("%s\n", big_str);
        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);

        printf("LocAddr:%d LocPort:%x RemAddr:%x RemPort:%x uid:%d inode:%d
\n",locaddr, locport, remaddr, remport, uid, inode);
}


$ gcc -o test test.c

$ ./test
  sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   
uid  timeout inode                             

   0: 0100007F:1780 00000000:0000 0A 00000000:00000000 00:00000000 00000000   
504        0 5488802 1 0df2da80 3000 0 0 2 -1  

LocAddr:100007f LocPort:1780 RemAddr:0 RemPort:0 uid:504 inode:5488802

Local port gets stored correctly using sscanf.
I have checked with glibc 2.3 and glibc 2.7. I was not able to reproduce.
I have checkd for all the enties in tcp file in a loop and worked fine.

Please revert back with the problem scenario if my understanding is not correct.

-Thanks,
 Halesh

-- 


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.


  reply	other threads:[~2008-07-07  9:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-04 20:04 [Bug regex/6722] New: " lists at roberthogan dot net
2008-07-07  9:36 ` halesh dot s at gmail dot com [this message]
2008-07-07 18:49 ` [Bug regex/6722] " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080707093558.26248.qmail@sourceware.org \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs-regex@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).