There is an important lesson to be learned here about coding standards. This particular bug would have been obvious if either:
IMO, all-out banning goto is too extreme, but enforcing the second one is a good idea and it an be automated as part of a test framework.
Personally, I’m very against optional syntax, saving a few lines of code is not worth this bug.
Agreed. Fancy character-saving syntax tricks are about ego and programmer pissing matches. I say: Save that stuff for the obfuscated code contest. If you want to work for me or with me, then your cleverness had better be directed towards furthering our mutual goals. Code should be written for easy readability, not for showing off your knowledge of the ins and outs of the language.
[Comment removed by author]
Infuriating that a terrible design choice can now masquerade as an philosophical blog post.
I’m less concerned with Apples coding standards than I am by the fact they don’t appear to have a single negative unit test to check that a wrong cert is detected.
From the original article:
A test case could have caught this, but it’s difficult because it’s so deep into the handshake. One needs to write a completely separate TLS stack, with lots of options for sending invalid handshakes. In Chromium we have a patched version of TLSLite to do this sort of thing but I cannot recall that we have a test case for exactly this. (Sounds like I know what my Monday morning involves if not.)
Good point. I wonder if this is good news. Did anyone discover this by accident and exploit it?
I spent a while as an embedded engineer, where we made heavy use of goto
and braceless ifs, particularly for the construct
as opposed to long if (condition_a) && (condition_b) ... statements.
if (condition_a) && (condition_b) ...
I don’t really see the benefit there. It’s not like the number of symbols in the source means much for the compiled code.
It is interesting that the bug seems to be the same on iOS and OSX, yet there’s no patch for OSX. Especially since this has gone unnoticed for months, you’d think they would wait to get a Mac patch ready before disclosing.
This feels like a case study for why code review matters.
In this case, I think solid code guidelines + mechanizing them would be a better solution.
There’s no guarantee that this would have been caught in review. This is a job for a linter.
Does reviewing code guarantee anything? I’m not denying that a linter would be ideal, but I feel like spotting duplication like this is something the human eye is good at doing.
Computers are definitely better though. Taking humans out of everything is the goal isn’t it? :)