News for hackers. Stuff that matters.
Re:Was the iOS SSL Flaw Deliberate? by ape4 on Thursday February 27, 2014 @09:36AM (#7312366)
I prefer always using brace brackets for if's...

if (cond) { goto fail; }

instead of:

if (cond) goto fail;

Re:Was the iOS SSL Flaw Deliberate? by xroche on Thursday February 27, 2014 @09:43AM (#7312411)
Yes, and this is actually a sane coding rule. Without it, badly written macros (using several ;-separated lines for example) will cause subtle bugs like this one.
Re:Was the iOS SSL Flaw Deliberate? by simias on Thursday February 27, 2014 @10:10AM (#7312543)
I would argue that in this case the problem lies in the macro, not the lack of braces. You can't program defensively against broken macros.

I've seen quite a lot of discussion surrounding the coding style around this "goto fail" vulnerability, but IMO that's missing the forest for the tree. If this coding error was truly a mistake (which I tend to believe) it was probably the result of a bogus copy/paste. Shit happens, no matter the coding style.

In my opinion the real problem is: why wasn't this code properly tested and audited? For crypto code it borders on gross negligence.

In particular, I disagree with TFA that "The flaw is subtle, and hard to spot while scanning the code". When you're used to read properly indented C code the 2nd "goto fail" with its weird indentation jumps to the eye IMO. Also the fact that the same statement is repeated twice in exactly the same way. I'm used to reading a lot of kernel code using the same kind of error handling and it really stands out IMO.