This is the mail archive of the
glibc-bugs-regex@sourceware.org
mailing list for the glibc project.
[Bug regex/6722] sscanf bug when parsing lines from /proc/net/tcp
- From: "lists at roberthogan dot net" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs-regex at sources dot redhat dot com
- Date: 7 Jul 2008 18:48:41 -0000
- Subject: [Bug regex/6722] sscanf bug when parsing lines from /proc/net/tcp
- References: <20080704200314.6722.lists@roberthogan.net>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- 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.