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: Tue, 08 Jul 2008 04:10:00 -0000 [thread overview]
Message-ID: <20080708040950.1922.qmail@sourceware.org> (raw)
In-Reply-To: <20080704200314.6722.lists@roberthogan.net>
------- Additional Comments From halesh dot s at gmail dot com 2008-07-08 04:09 -------
(In reply to comment #4)
> Either use %8x:%4hx and kill the bogus casts, or you need to assign to
> int/unsigned int temporaries and copy to the short vars afterwards.
I have not changed the testcase as u mentioned, instead i exchanged the
declaration order of ports...Now its working fine..
Please check the testcase
#include <stdio.h>
#include <sys/types.h>
int main()
{
u_int32_t locaddr, remaddr, uid, inode = 0;
/* changed the order of declaration in testcase provided by robert*/
u_int16_t remport, locport;
FILE *f;
char big_str[256];
f = fopen("/proc/net/tcp", "r");
fgets(big_str,256,f);
printf("%s\n", big_str);
while(fgets(big_str,256,f) != NULL) {
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:%x LocPort:%x RemAddr:%x RemPort:%x uid:%d
inode:%d\n",locaddr, locport, remaddr, remport, uid, inode);
}
}
O/P is
........
........
53: C865582B:8116 CD65582B:0016 01 00000000:00000000 02:000082E4 00000000
0 0 3258616 2 195aca80 202 40 0 2 -1
LocAddr:c865582b LocPort:8116 RemAddr:cd65582b RemPort:16 uid:0 inode:3258616
........
........
Results are fine now.
It depends upon alignment of 16 bit variables or what???
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at redhat dot com,
| |schwab at suse dot de
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.
next prev parent reply other threads:[~2008-07-08 4:10 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 ` [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 [this message]
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=20080708040950.1922.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).