This is the mail archive of the glibc-bugs-regex@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug regex/6722] sscanf bug when parsing lines from /proc/net/tcp


------- 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]