To be honest I'm kinda surprised that even after the 'goto fail' story people still write code in this questionable style(I know this particular issue is not stemming from the lack of curly braces, but still).
To be honest I'm kinda surprised that even after the 'goto fail' story people still write code in this questionable style(I know this particular issue is not stemming from the lack of curly braces, but still).
LibreSSL didn't spring into existence out of whole cloth. It started as a fork of OpenSSL, which goes back to 1998.
The "questionable style" is from legacy code. It would be a massive effort to revise the entire codebase. And if LibreSSL did that, it would make it harder to import changes from OpenSSL and from other forks such as BoringSSL.
When it's a choice between making it easier to import changes or harder to import bugs, I know which one I think is more important when dealing with a security library.
Put another way, if you forked because upstream was crap, not changing because it makes it easier to accept upstream patches is a poor reason not to change something that might benefit from it.
That said, the relatively poor history of OpenSSL and the relatively high quality of software that comes out of the OpenBSD project leads me to think I know what the likely outcome of refactoring code is in this particular scenario.
BoringSSL doesn't use that style: https://boringssl.googlesource.com/boringssl/+/master/ssl/s3...
There's no need to revise the entire codebase either, just fix the lines you touch, and don't introduce new cases like in that commit.
https://github.com/systemd/systemd/commit/61f33134fc9231e07e...
I'm all for blaming legacy but this is unfortunately still a trend.
Safety nets make it seem like you're handling edge cases in a vaguely specified, ad-hoc way, which is prone to forgetting to add the safety net in at least some places, while the nets themselves are easy to mess up as well.
Could this code benefit from more typing perhaps? Automated checking of pre- and postconditions? Are there C (macro) libraries implement that in a usable way?
A better type system would help out a lot here, but it is also possible to write clean C code without this class of bugs. And OpenSSL has some of the worst code I have seen in an open source project (I have seen much worse in commercial projects), so while C has a lot of flaws do not judge it after OpenSSL.
The new "safety net" that libressl added said that if the connection doesn't need to be aborted there was no verification error.
The specific code isn't "goto fail" anyway, it is more akin to a finally block.