[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20110919142043.83684050.akpm@google.com>
Date: Mon, 19 Sep 2011 14:20:43 -0700
From: Andrew Morton <akpm@...gle.com>
To: Mimi Zohar <zohar@...ux.vnet.ibm.com>
Cc: linux-security-module@...r.kernel.org,
Andy Shevchenko <andy.shevchenko@...il.com>,
Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
David Safford <safford@...son.ibm.com>,
"Nicholas A. Bellinger" <nab@...ux-iscsi.org>,
target-devel@...r.kernel.org, linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [RFC][PATCH 2/5] lib: add error checking to hex2bin
On Fri, 16 Sep 2011 08:50:27 -0400
Mimi Zohar <zohar@...ux.vnet.ibm.com> wrote:
> --- a/lib/hexdump.c
> +++ b/lib/hexdump.c
> @@ -38,14 +38,17 @@ EXPORT_SYMBOL(hex_to_bin);
> * @dst: binary result
> * @src: ascii hexadecimal string
> * @count: result length
> + *
> + * Returns true on success, false in case of bad input.
> */
> -void hex2bin(u8 *dst, const char *src, size_t count)
> +bool hex2bin(u8 *dst, const char *src, size_t count)
> {
> while (count--) {
> - *dst = hex_to_bin(*src++) << 4;
> - *dst += hex_to_bin(*src++);
> - dst++;
> + if (!unpack_hex_byte(dst++, src))
> + return false;
> + src += 2;
> }
> + return true;
> }
> EXPORT_SYMBOL(hex2bin);
Again, this is very unconventional for kernel code, and it's for no good
reason. Please, stick with 0/-1 unless there's a good reason to diverge
from that.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists