From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27370 invoked by alias); 8 Jul 2008 07:46:56 -0000 Received: (qmail 27161 invoked by uid 48); 8 Jul 2008 07:46:12 -0000 Date: Tue, 08 Jul 2008 07:46:00 -0000 Message-ID: <20080708074612.27160.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/msg00006.txt.bz2 ------- Additional Comments From halesh dot s at gmail dot com 2008-07-08 07:46 ------- (In reply to comment #4) > Well, locaddr and remaddr are 32-bit ints, but locport and remport are not; > the testcase doesn't only violate aliasing rules, but with the 32-bit write > to 16-bit memory locations also clobbers unrelated memory on the stack. > 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. > We can avoide cloberring of 16 bit hex vairables by using %hx, How to avoide the same when using u_int8_t variables. We cant use %hx for u_int8_t as its only upto short int - 16 bits. Please check the below testcase #include #include int main() { int cur = 123; u_int8_t var1; u_int8_t var2; scanf("%x", &var1); scanf("%x", &var2); printf("var1 = %x\n", var1); printf("var2 = %x\n", var2); printf("cur = %d\n", cur); } O/P is... 1 2 var1 = 0 ** var2 = 2 cur = 0 ** How to avoide the clobbering while using of 8 bit hex?? Any idea abt this?? -- 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.