From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [resend][PATCH] fs: use kernel's hex_to_bin() method Date: Tue, 4 Jan 2011 16:14:39 -0800 Message-ID: <20110104161439.f30ab73c.akpm@linux-foundation.org> References: <1291978505-29076-1-git-send-email-andy.shevchenko@gmail.com> <20110104152100.29d0da02.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: linux-kernel@vger.kernel.org, Alexander Viro , linux-fsdevel@vger.kernel.org, Mimi Zohar , "Serge E. Hallyn" , David Howells , James Morris To: Andy Shevchenko Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Wed, 5 Jan 2011 01:58:56 +0200 Andy Shevchenko wrote: > On Wed, Jan 5, 2011 at 1:21 AM, Andrew Morton 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?