lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20110919153810.ba0be83a.akpm@google.com>
Date:	Mon, 19 Sep 2011 15:38:10 -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 1/5] lib: add unpack_hex_byte()

On Mon, 19 Sep 2011 18:35:08 -0400
Mimi Zohar <zohar@...ux.vnet.ibm.com> wrote:

> > Wouldn't it be better to fix hex2bin() so that it returns -1 on error?
> 
> Yes, that was the original idea, but in order to return a result, it
> needs to validate the input.  The above code, or something similar,
> needs to exist somewhere, either in the new function or in hex2bin().
> Would something like this be any better?
> 
> int hex2bin(u8 *dst, const char *src, size_t count)
> {
> 	while (count--) {
>                 int hi = hex_to_bin(*src++);
>                 int lo = hex_to_bin(*src++);
> 
>                 if ((hi < 0) || (lo < 0))
>                         return -1;
> 
>                 *dst++ = (hi << 4) | lo;
>         }
> 	return 0;
> }
> 
> 
> > Then the above function becomes a one-liner:
> > 
> > 	return hex2bin(dst, src, 2);
> 
> Why bother?  With something like this, there isn't a need for the new
> function.  :-)

OK.

> > Finally, the name is poor.  It starts with "unpack_", so it belongs to
> > the "unpack" subsystem.  There's no such thing.  Something like
> > hex_byte_to_bin() would be better.
> 
> agreed.  It was suppose to parallel the existing pack_hex_byte().

hex_byte_pack() :)
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ