Re: [resend][PATCH] fs: use kernel's hex_to_bin() method
From: Andrew Morton
Date: Tue Jan 04 2011 - 19:14:59 EST
On Wed, 5 Jan 2011 01:58:56 +0200
Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:
> On Wed, Jan 5, 2011 at 1:21 AM, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> 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?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/