News for hackers. Stuff that matters.
Re:Apple's SSL/TLS bug by apaprocki on Saturday February 22, 2014 @09:30AM (#7282120)
Worth noting that static analysis finds bugs like this immediately. TLS code seems like the perfect candidate to run through static analysis on every checkin. There are products such as Coverity and PVS-Studio that would have immediately flagged this and probably some open-source ones built around LLVM as well (unsure about this one, though). I personally use Coverity and have it hooked up in the same way everyone connects Travis CI.
Re:Apple's SSL/TLS bug by _pmf_ on Saturday February 22, 2014 @01:24PM (#7282972)
> Worth noting that static analysis finds bugs like this immediately.

I'd like to point out the case where Debian maintainers "fixed" a "bug" discovered by static analysis; https://blog.isotoma.com/2008/05/debians-openssl-disaster/.

Re:Apple's SSL/TLS bug by cwzwarich on Saturday February 22, 2014 @09:11PM (#7284625)
Valgrind is dynamic analysis, not static analysis.
Re:Apple's SSL/TLS bug by pjmlp on Saturday February 22, 2014 @10:01AM (#7282208)
There is no excuse to bypass static analysis nowadays. At very least should be part of the continuous integration build.

The problem are the many developers that still think they are perfect and know the full C standard, including undefined parts.

Re:Apple's SSL/TLS bug by eliteraspberrie on Saturday February 22, 2014 @02:22PM (#7283205)
Unfortunately the decision to use static analysis tools would have to come from developers who are comfortable admitting they make mistakes sometimes.

It takes a special kind of ego to write an SSL library with no unit tests, not turn on compiler warnings, and not use static analysis tools.

Re:Apple's SSL/TLS bug by TwoBit on Saturday February 22, 2014 @03:11PM (#7283401)
Re:Apple's SSL/TLS bug by MrBuddyCasino on Sunday February 23, 2014 @06:25AM (#7285597)
Wow. Thats really bad, who would have thought OpenSSL is such a piece of crap? Its about time someone writes a decent alternative!
Re:Apple's SSL/TLS bug by pjmlp on Saturday February 22, 2014 @03:34PM (#7283476)
Very enlightening.
Re:Apple's SSL/TLS bug by pjmlp on Saturday February 22, 2014 @03:02PM (#7283360)
Fully agree, I met quite a few of those egos already.
Re:Apple's SSL/TLS bug by laureny on Saturday February 22, 2014 @10:44AM (#7282371)
That's a rare problem among developers. The more common problem is that developers make mistakes. All of them.

Static analysis, regression tests and turning on all the warnings you possibly can should be mandatory, especially for such critical pieces of code.

Re:Apple's SSL/TLS bug by erichurkman on Saturday February 22, 2014 @12:01PM (#7282638)
And if you are going to disable a specific warning, it should only be for a limited section of code and include a detailed comment about why the warning is superfluous and why the code is safe.
Re:Apple's SSL/TLS bug by pjmlp on Saturday February 22, 2014 @11:26AM (#7282515)
> That's a rare problem among developers.

Many of the C guys I met along my career thought otherwise.

> Static analysis, regression tests and turning on all the warnings you possibly can should be mandatory, especially for such critical pieces of code.

+1

Re:Apple's SSL/TLS bug by teacup50 on Saturday February 22, 2014 @02:11PM (#7283155)
Re:Apple's SSL/TLS bug by joe_bleau on Saturday February 22, 2014 @12:22PM (#7282724)
Yep, PC-lint from Gimpel catches it:

Error -> Warning 527 Unreachable code at token 'ret' (col 12)

Re:Apple's SSL/TLS bug by emmelaich on Saturday February 22, 2014 @05:20PM (#7283882)
Nice. Does PC-lint give a lot of false negatives and positives as well?
Re:Apple's SSL/TLS bug by joe_bleau on Saturday February 22, 2014 @09:24PM (#7284653)
If the code hasn't been linted, expect lots of false positives. I usually have to disable entire classes of less serious warnings to notice the errors, then slowly work through to the less serious stuff.
Re:Apple's SSL/TLS bug by Aissen on Saturday February 22, 2014 @09:37AM (#7282138)
Regarding Adam Langley's comment about -Wall in gcc: -Wextra is what you want to have many more tests analysing your code. I wonder if this would have caught it.
Re:Apple's SSL/TLS bug by throwaway_yy2Di on Saturday February 22, 2014 @10:20AM (#7282277)
A quick test shows neither -Wall nor -Wextra report anything on either gcc or clang. However, clang's -Weverything does complain (it implies -Wunreachable-code).

Confusingly, gcc accepts -Wunreachable-code as a valid option, but then proceeds not to warn anything. (edit): Which is a known bug apparently,

http://gcc.gnu.org/ml/gcc-help/2011-05/msg00360.html

Re:Apple's SSL/TLS bug by oneeyedpigeon on Saturday February 22, 2014 @10:29AM (#7282312)
The real WTF is those Warn flags, then. In what sane world does "extra" mean more than "all", and "all" and "everything" mean different things?
Re:Apple's SSL/TLS bug by acdha on Saturday February 22, 2014 @11:04AM (#7282430)
Excessive fear of backwards compatibility: you make -Wall. People use it. You add a new check which will reject some shoddy code. “What if people complain that their project no longer builds with -Wall? Let's add a new setting…”. Repeat…

I've been wondering how hard it would be to get to the point where the defaults are rigorous and developers have to opt out with specific -Wno-… options.

Re:Apple's SSL/TLS bug by Agathos on Saturday February 22, 2014 @12:01PM (#7282640)
"-Wall" actually means, "all warnings, as of the date we froze the definition of -Wall, which for all you know was 20 years ago, good luck."
Re:Apple's SSL/TLS bug by praseodym on Saturday February 22, 2014 @11:00AM (#7282415)
Apple introduced -Weverything because suddenly changing the scope of gcc's -Wall (which indeed does not include everything) would break a lot of builds.
Re:Apple's SSL/TLS bug by bentcorner on Saturday February 22, 2014 @11:44AM (#7282583)
Is "-Weverything" inclusive of new warnings? Because they're just kicking the can if not. What's next, "-Wreallyeverything"?
Re:Apple's SSL/TLS bug by e28eta on Saturday February 22, 2014 @12:06PM (#7282655)
Yep. Even ones that may not be fully baked, so some people caution against it.

We have it turned on, and about 10 warnings specifically disabled because they were too noisy or not useful for us. It's always interesting upgrading Xcode and seeing what new warnings we get to fix.

Re:Apple's SSL/TLS bug by pjene on Saturday February 22, 2014 @11:41AM (#7282577)
"suddenly" is a funny way to say "over a span of years"....
Re:Apple's SSL/TLS bug by TwoBit on Saturday February 22, 2014 @03:15PM (#7283413)
Microsoft VC++ has a -Wall warning level too, and it really does mean all warnings. Each major version of VC++ potentially introduces new warnings to -Wall.
Re:Apple's SSL/TLS bug by apaprocki on Saturday February 22, 2014 @10:28AM (#7282309)
My personal observation is that while compilers continually get better at identifying straightforward mistakes, they don't have the same capability as a static analysis tool that works across compilation units. That is the real selling point of these tools. Definitely -Weverything/-Wexta plus static analysis for baseline checking.

My other beef is that compilers always add new warnings as options or behind new "catch all" flags like -Weverything that no one knows about. As long as each new warning can be individually disabled, there isn't a huge cost to pay by making much more of them enabled by default. Upgrading to a new compiler version usually requires a tiny bit of work, so adding a few -Wno-* rules for new things you want to disable until the code is clean (or forever) is a small price to pay for all new code getting the checks by default.

Re:Apple's SSL/TLS bug by mitchty on Saturday February 22, 2014 @09:39AM (#7282144)
PVS-Studio might be a bit unlikely however in this particular case.