Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 8 Feb 2013 14:18:07 -0600
From: "jfoug" <jfoug@....net>
To: <john-dev@...ts.openwall.com>
Subject: RE: C for dummies

From: magnum [mailto:john.magnum@...hmail.com] 
>
>This question stems from an OpenCL problem we just solved off list.
>
>In common.c we have several lines like this:
>
>char itoa16u[16] = "0123456789ABCDEF";
>
>Is this a bug or not? That string literal is 17 bytes if you ask me. In the
OpenCL format we were debugging, this caused major problems.
>
>I am 100% autodidact, so I am not sure the above way of writing it is
definitely wrong or not (my guess is it is wrong). Personally I would write
it with empty braces (btw I'd also use const). OTOH if it's that bad, I'm
puzzled no compiler or tool complained about it.

That is a bug.  I have had to make 'changes' for other build environments,
when taking code from Jtr.  I am not really sure HOW it builds properly in
Jtr.

I would much rather see this as 
const char itoa16u[] = "0123456789ABCDEF";

OR 
const char itoa16u[16] =
{'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};	

if we had to maintain sizeof(itoa16u) == 16 for something.

I also do not know why compilers were not complaining. When I cut those
lines out and put them into other packages, (like the recent wpapcap2john
project), I did get compiler errors about too many elements, and had to
change the var declaration.

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ