From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2151 invoked by alias); 8 Jul 2008 04:10:32 -0000 Received: (qmail 1923 invoked by uid 48); 8 Jul 2008 04:09:50 -0000 Date: Tue, 08 Jul 2008 04:10:00 -0000 Message-ID: <20080708040950.1922.qmail@sourceware.org> From: "halesh dot s at gmail dot com" To: glibc-bugs-regex@sources.redhat.com In-Reply-To: <20080704200314.6722.lists@roberthogan.net> References: <20080704200314.6722.lists@roberthogan.net> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug regex/6722] sscanf bug when parsing lines from /proc/net/tcp X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-regex-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-regex-owner@sourceware.org X-SW-Source: 2008-07/txt/msg00005.txt.bz2 ------- 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 #include 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.