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 07:46:00 -0000	[thread overview]
Message-ID: <20080708074612.27160.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 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 <stdio.h>
#include <sys/types.h>

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.


  parent reply	other threads:[~2008-07-08  7:46 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
2008-07-08  7:46 ` halesh dot s at gmail dot com [this message]
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=20080708074612.27160.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).