linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, Mimi Zohar <zohar@us.ibm.com>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	David Howells <dhowells@redhat.com>,
	James Morris <jmorris@namei.org>
Subject: Re: [resend][PATCH] fs: use kernel's hex_to_bin() method
Date: Tue, 4 Jan 2011 16:14:39 -0800	[thread overview]
Message-ID: <20110104161439.f30ab73c.akpm@linux-foundation.org> (raw)
In-Reply-To: <AANLkTi=FpimZ=KS7Qgf8PyZ5jG4_74UG6vA9V+CX6MYD@mail.gmail.com>

On Wed, 5 Jan 2011 01:58:56 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Wed, Jan 5, 2011 at 1:21 AM, Andrew Morton <akpm@linux-foundation.org> wrote:
> 
> > After which we can change your patch thusly:
> >
> > --- a/fs/binfmt_misc.c~fs-binfmt_miscc-use-kernels-hex_to_bin-method-fix
> > +++ a/fs/binfmt_misc.c
> > @@ -244,9 +244,7 @@ static int unquote(char *from)
> >
> >        while ((c = *s++) != '\0') {
> >                if (c == '\\' && *s == 'x') {
> > -                       s++;
> > -                       *p = hex_to_bin(*s++) << 4;
> > -                       *p++ |= hex_to_bin(*s++);
> > +                       s = (char *)hex2bin(p, s + 1, 1);
> We need to update both p and s.
> 
> In case of '\xAA\xBB' you have result -> '0xBB'.
> Am I wrong?
> 
> >                        continue;
> >                }
> >                *p++ = c;

I'm more into shopping and nagging at people than this programming
thingy.  Sigh.

--- a/fs/binfmt_misc.c~fs-binfmt_miscc-use-kernels-hex_to_bin-method-fix-fix
+++ a/fs/binfmt_misc.c
@@ -243,11 +243,10 @@ static int unquote(char *from)
 	char c = 0, *s = from, *p = from;
 
 	while ((c = *s++) != '\0') {
-		if (c == '\\' && *s == 'x') {
-			s = (char *)hex2bin(p, s + 1, 1);
-			continue;
-		}
-		*p++ = c;
+		if (c == '\\' && *s == 'x')
+			s = (char *)hex2bin(p++, s + 1, 1);
+		else
+			*p++ = c;
 	}
 	return p - from;
 }
_


How does one test this thing?

  reply	other threads:[~2011-01-05  0:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-10 10:55 [resend][PATCH] fs: use kernel's hex_to_bin() method Andy Shevchenko
2011-01-04 23:21 ` Andrew Morton
2011-01-04 23:58   ` Andy Shevchenko
2011-01-05  0:14     ` Andrew Morton [this message]
2011-01-05  9:51     ` David Howells
2011-01-05  9:54 ` David Howells

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=20110104161439.f30ab73c.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=jmorris@namei.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=zohar@us.ibm.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 NNTP newsgroup(s).