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 lists at roberthogan dot net  2008-07-07 18:48 -------
Apologies, I should have provided the full test case. This should recreate the 
problem. locaddr and remaddr are 32-bit ints.

#include <stdio.h>
# include <sys/types.h>

int main()

{
  FILE *f;
  u_int32_t locaddr, remaddr, uid, inode = 0;
  u_int16_t locport, remport;

  static char big_str[151];

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

fgets(big_str,151,f);

  while (fgets(big_str, 152, f) != NULL) {
  
  
    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("%s", big_str);
  
    printf("%d %x %x %x %x %x\n",locaddr, locport, remaddr, remport, uid, 
inode);
  }

}

-- 


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]