Apple SSL Bug In iOS Also Affects OS X 140
Trailrunner7 writes "The certificate-validation vulnerability that Apple patched in iOS yesterday also affects Mac OS X up to 10.9.1, the current version. Several security researchers analyzed the patch and looked at the code in question in OS X and found that the same error exists there as in iOS. Researcher Adam Langley did an analysis of the vulnerable code in OS X and said that the issue lies in the way that the code handles a pair of failures in a row. The bug affects the signature verification process in such a way that a server could send a valid certificate chain to the client and not have to sign the handshake at all, Langley found. Some users are reporting that Apple is rolling out a patch for his vulnerability in OS X, but it has not shown up for all users as yet. Langley has published a test site that will show OS X users whether their machines are vulnerable."
Hmm... (Score:4, Funny)
The researcher who found the bug is Adam Langley. CIA headquarters is in Langley, Virginia.
Coincidence? I think not!
Re: (Score:2)
The researcher who found the bug is Adam Langley. CIA headquarters is in Langley, Virginia.
Coincidence? I think not!
Adam Langley is an anagram of "A lang madly e". Clearly this is the product of some leet Canadian insider who has gone rouge with this disclosure. Time to put on a new layer of tinfoil.
Re: (Score:2)
The researcher who found the bug is Adam Langley. CIA headquarters is in Langley, Virginia.
Coincidence? I think not!
Adam Langley is an anagram of "A lang madly e". Clearly this is the product of some leet Canadian insider who has gone rouge with this disclosure. Time to put on a new layer of tinfoil.
Mascara, even!
Re: (Score:2)
Must be a lumberjack.
Re: (Score:2)
The researcher who found the bug is Adam Langley. CIA headquarters is in Langley, Virginia.
Coincidence? I think not!
Adam Langley is an anagram of "A lang madly e". Clearly this is the product of some leet Canadian insider who has gone rouge with this disclosure. Time to put on a new layer of tinfoil.
Mascara, even!
I dunno, it's making me see red...
Feature (Score:1)
>> The researcher who found the bug is Adam Langley. ...
>> Bug removes SSL
it's a feature, not a bug.
https://pbs.twimg.com/media/Bh... [twimg.com]
Lets see how far back... (Score:2, Insightful)
Let see how far back Apple will patch this thing, if they leave Snow Leopard (10.6) out for the wolves or not.
In the past under Jobs, only the last two OS X versions got security updates. He was a real prick about trying to force people to upgrade to their latest bloated your machine so you have to buy a new one prematurely crap.
Re:Lets see how far back... (Score:5, Insightful)
Snow Leopard (10.6) is not vulnerable to this bug, since Apple did not switch from OpenSSL to their own SSL/TLS library back then yet. Just verified on my 10.6 box (to verify visit https://www.imperialviolet.org:1266/ )
On the other hand, iOS 6.1.5 is - and now I have a choice of using insecure iPhone or upgrading to 7.x. For now I've switched from Safari to a 3rd party browser that does not have this bug - but email is still vulnerable and so can be other components. That said, I have little trust in SSL even when it works as designed, so I won't lose much sleep over this.
Re: (Score:2)
Snow Leopard (10.6) is not vulnerable to this bug, since Apple did not switch from OpenSSL to their own SSL/TLS library back then yet. Just verified on my 10.6 box (to verify visit https://www.imperialviolet.org... [imperialviolet.org] )
On the other hand, iOS 6.1.5 is - and now I have a choice of using insecure iPhone or upgrading to 7.x.
Or, perhaps upgrading to iOS 6.1.6 [apple.com] which corrects that bug.
Re: (Score:1)
If you are able to upgrade to iOS 7, you are not able to upgrade to 6.1.6.
Re: (Score:2)
If you are able to upgrade to iOS 7, you are not able to upgrade to 6.1.6.
Ugh. I didn't realize that. That's just...short-sighted.
Re: (Score:2)
Which is yet another reason I keep seperate work and home devices. If they aren’t going to keep up with security patches and the device is comprimized, it only affects “their” stuff, not mine.
Re: (Score:3)
iOS 6.1.6 is not available for iPhone 5. It is only available for devices for which there is no iOS 7, unfortunately. First thing I checked.
Re: (Score:3, Interesting)
No, that's not correct at all. First, it doesn't affect 10.8.5, either, which blows that theory. Second, Secure Transport was introduced way back in 10.2, and has been used for Foundation and Core Foundation SSL negotiation since at least 10.4, according to various security vulnerability reports (and probably earlier). In other words, this has absolutely nothing to do with
Re: (Score:3)
It is correct and, if you have 10.6 handy - you can verify that under that system Safari is using OpenSSL. To do so, simply move /usr/lib/libssl.*.dylib elsewhere and try to run Safari. It will fail due to missing libraries.
On 10.9 Safari will happily run with OpenSSL libraries removed.
You are welcome to dig through otool -L output to find how it's linked up, but the fact remains - Safari was switched over from OpenSSL to homegrown crypto sometime after 10.6.
Re: (Score:2)
Even if you're right, the fact remains that security researchers have shown that the bug in question didn't exist in Secure Transport as of the 10.8.5 sources. Because Secure Transport is open source, you can verify that yourself if you don't believe me.
Re: (Score:2)
Why did they switch? I haven't been able to find out from the articles I read.
Re: (Score:2)
I'm pretty thick. Why isn't a "moving target" a good thing when you're talking about security?
Is OpenSSL open source? That would make it more trustworthy, wouldn't it?
Not long ago I wouldn't even have thought about these things, but with some formerly trusted players putting back doors and exploitable weaknesses into their products for the sake of the NSA, I figure I better ask some questions.
Re: (Score:1)
Not-invented-here-syndrome.
Actually, the official story is that OpenSSL didn't maintain ABI compatibility across versions to Apple's satisfaction. Of course, instead of just forking or maintaining patches against OpenSSL, they decided to implement their own SSL stack from scratch.
Something like this was inevitable. Apple's crypto and SSL stack can't hold a candle to OpenSSLs in terms of features and algorithms. And while everybody agrees that OpenSSL is ugly code, it's code that's been hammered on for nearl
Re: (Score:1)
This looks like it needs a simple explanation; purists will be offended by some of what I'm going to write, but in general it's right.
The API (Application Programming Interface) specifies the very particular ways that one set of code (a library) can be addressed by other programs. It's a translation layer between the library and the programs that use the library. The library itself can be updated over and over without changing the API: if OpenSSL changes some detail of how a crypto routine works, that doe
Re: (Score:2)
When they refer to it as a moving target, they probably mean that the stuff they're trying to build on top of it breaks far too often because there's too much change.
Moving target for security = good.
Moving target for foundation to build on = not as good.
Re: (Score:2)
If you don't want 7.x you can use 6.1.6 which got released to fix this
Re: (Score:3)
Not on all devices. AC posted this so it got lost in the filters: If you are able to upgrade to iOS 7, you are not able to upgrade to 6.1.6.
Re: (Score:2)
Slashdotted.
Re: (Score:1)
I just checked with https://www.imperialviolet.org... [imperialviolet.org] And I got the message "Safari can't open that page because Safari can't established a secure connection to the server". I am running Mac OS 10.8.4 so does that mean I am safe?
Re: (Score:2)
Yes.
Re: (Score:2, Troll)
So that they wouldn't be affected by bugs in OpenSSL?
The idea that it's a bad idea to roll your own security features because you're probably not a security expert is not something that is necessarily applicable to an organization as large as Apple, which can certainly afford to employ as many security researchers as it needs to to match the security knowledge of other common security tool organizations.
Further, a world in which there is only one (hopefully well-researched) implementation of critical securi
Re: (Score:2)
The idea that it's a bad idea to roll your own security features because you're probably not a security expert is not something that is necessarily applicable to an organization as large as Apple, which can certainly afford to employ as many security researchers as it needs to to match the security knowledge of other common security tool organizations.
...but apparently cannot afford the engineers needed to write a thorough test suite for just about anything.
Re: (Score:1)
Instead they're affected by bugs in their own implementation. Worse, the footprint of their implementation compares to something like OpenSSL is so small that their problems are likely to remain under the surface until they surface suddenly and bite them in the ass: with Open Source, all bugs are shallow.
Their implementation is open source. So, I call bullshit on your assertion.
Given that they open sourced their implementation, and didn't use OpenSSL, I'd bet heavily that there's some requirement that they have that OpenSSL did not, and would not fulfil.
Re: (Score:1)
So I'll just keep asking, because no one can provide an answer: why would you do that?!
As has been mentioned in this thread several times –because OpenSSL kept repeatedly making bin-compat breaking changes to their API. The result was that they could not ship up-to-date versions of OpenSSL, and hence were open to all kinds of security vulnerabilities that way. Their solution was to change to an API that they knew could be consistent.
Re: (Score:2)
Their solution was to change to an API that they knew could be consistent.
Of course. Rolling your own SSL stack is so much more efficient a use of engineers time than backporting patches.
Re: (Score:2)
"Their solution was to change to an API that they knew could be consistent."
Of course. Rolling your own SSL stack is so much more efficient a use of engineers time than backporting patches.
Non-sequiteur. Back-porting patches does not stabilise the OpenSSL API between versions.
Re: (Score:2)
Yes but it does secure your old versions so you can continue using them.
Re: (Score:2)
10.8.5 isn't even effected, why would any previous version be? This is strictly an iOS 6.x, iOS 7.x and Mac OS X 10.9.x bug.
Re: (Score:2)
Apple has consistently been opposed to long term legacy use. Anyone pissed off by this is completely irrational. iPad 1 was an April 2010 device, which Apple had an expected life for of 2-3 years.
You don't like rapid upgrades Microsoft will be happy for your tablet business.
Re: (Score:2)
The iPad 1 came with 256MB of RAM. Current iPads have 1GB or RAM.
Desktop OSs can still work on older machines, because they use the HD as virtual RAM when real RAM runs out. Mobile OSs, including iOS don't have virtual ram, as thrashing flash memory is destructive. So if the real RAM available is not big enough to support the OS usage, and the usage of a single current app, then it's incompatible.
A few years ago Apple made the mistake of releasing an iOS version and allowing it on the 3GS. But because of th
Informative discussion thread (Score:5, Informative)
Re: (Score:1)
:( But I *really* don't want iOS 7. I think this is all planned by Apple to move remaining holdouts to the current iOS. Fuck.
Re: (Score:1)
iOS 7 is the worst mobile OS I have ever seen.
If you are an iPhone, iPad user I recommend not to upgrade to it.
The UI is the absolute ugliest thing I can imagine, many superb iOS applications like the address book or the Calendar or the Notes application look like utter shit.
The standard usability with swipes of a finger or multiple, fingers is completely messed up. The pad or the phone does most of the time not what you want, and if you want to do something special, like killing a process: it simply does
Re: (Score:1)
Re: (Score:2)
There are finally affordable real Windows (8.1) tablets out. I just got a Dell Venue 8 Pro for $300 at Walmart.
Meh, it's a low end netbook without a keyboard. I'm still waiting for anyone besides Apple to produce something with decent resolution. 1280x800 is a bit low in an 8" tablet for trying to do MS Office (which also sucks if you don't have a mouse and keyboard. But still it's an affordable option if you don't want the limitations of Android, can't afford an iPad mini, and don't mind crappy windows 8.
NSA (Score:5, Interesting)
Some bloggers and commentators online (no mainstream media news sites... yet) have suggested that this bug was introduced by the NSA based on the fact that Snowden's leaked slides showed evidence that the NSA had developed and was working on further ways of targeting and compromising secured iOS traffic.
We know the NSA compromised RSA through Dual EC_DRBG. It's not hard to imagine they wanted to compromise SSL/TLS on Apple platforms.
The bug was found via internal code review according to the credits for discovery, which means nobody else has disclosed they knew about this in the wild (so this is an exposed zero day crypto exploit on both OS X and iOS platforms).
This link is informative - the kicker is he properly indented but obviously duplicated and incorrect "goto fail;"
https://www.imperialviolet.org... [imperialviolet.org]
static OSStatus ...
SSLVerifySignedServerKeyExchange(SSLContext *ctx, bool isRsa, SSLBuffer signedParams,
uint8_t *signature, UInt16 signatureLen)
{
OSStatus err;
if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0) ...
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
goto fail;
fail:
SSLFreeBuffer(&signedHashes);
SSLFreeBuffer(&hashCtx);
return err;
}
Maybe this came out due to bad coding practices, but the kind of bug where the code visually looks ok on the surface, compiles and passes without compiler warnings, and works fine aside from allow the comprise is very suspect.
And at the minimum the NSA has been exploiting this rather than alerting people. Our government needs to stop weakening computer security and go back to working for the people, not against them.
Re: (Score:1)
Uh, wouldn't such code generate " never executed" warnings for everything after the dupe goto??
Re:NSA (Score:5, Insightful)
This is a fundamental problem all the traitorous NSA behavior has created - every time something like this comes up, we're going to wonder if THEY are behind it. Problem is, that way lies madness... we can never really know.
1) It could very well be an innocent coding error. Heck, I could see myself doing this one with the slip of the fingers in BBEdit. I probably HAVE done it at some point in time.
2) It could be an intentional bug slipped in by someone on NSA's payroll.
3) Or, it could be even more nefarious. Perhaps NSA has known about this, but thought the use case was too restricting. So they kept quiet until they were able to slip a more broadly exploitable hole in the development code (or, alternatively, something the compiler can slip into your output). Then, to force everyone to update, they reveal this older bug. We all update, and BAM! They've got us.
We can't really know, anymore.
Re: (Score:2)
This is a fundamental problem all the traitorous NSA behavior has created - every time something like this comes up, we're going to wonder if THEY are behind it. Problem is, that way lies madness... we can never really know.
1) It could very well be an innocent coding error. Heck, I could see myself doing this one with the slip of the fingers in BBEdit. I probably HAVE done it at some point in time.
2) It could be an intentional bug slipped in by someone on NSA's payroll.
3) Or, it could be even more nefarious. Perhaps NSA has known about this, but thought the use case was too restricting. So they kept quiet until they were able to slip a more broadly exploitable hole in the development code (or, alternatively, something the compiler can slip into your output). Then, to force everyone to update, they reveal this older bug. We all update, and BAM! They've got us.
We can't really know, anymore.
As Henry Kissinger is reputed to have said, "Even paranoiacs have enemies...."
Re: (Score:2)
"DEA and NSA Team Up to Share Intelligence, Leading to Secret Use of Surveillance in Ordinary Investigations"
https://www.eff.org/deeplinks/... [eff.org]
Intentional bug slipped in might get noticed outside the more bespoke high end machine encoding production efforts of the 1960-70's.
Software teams are big, staff from varied countries, backgrounds, skill sets, review, in-house (unknown) next gen automated testing software - a person making rep
Re: (Score:2)
2) It could be an intentional bug slipped in by someone on NSA's payroll..
Who says that 'someone' is on their payroll?
Re: (Score:2)
This particular problem started me thinking along those lines - I believe I'll start practicing that as well in whatever language I'm writing. Both perl and (especially) JavaScript allow this in one form or another.
Re:NSA (Score:4, Interesting)
This bug looks like the sort of bugs that can come from merging between different code branches in very large codebases. A duplicated line, or a missing line, is a common merge-conflict resolution, *especially* where essentially the same code was added in both branches and then merged together. As an example, if this was a refactor of an existing function that was made similarly in two branches, but a little extra trailing whitespace was clipped in only one branch, then you could get a duplicate line out of an automerge operation.
Re: (Score:2)
Re: (Score:2)
This is exactly why I NEVER EVER use multiline if statements without braces.
Re: (Score:2)
Nobody does intentionally. Because there's no such thing.
It's single statement if blocks without braces that people should be avoiding as a matter of style.
Re: (Score:2)
Single line if statement:
if (condition) statement;
Multi-line if statement without braces:
if (condition)
statement;
Multi-line if statement with braces:
if (condition)
{
statement;
}
There is no good excuse for choosing multi-line without braces over the one with braces.
Re: (Score:2)
OK, so we're saying nearly the same thing. Only I wouldn't accept your first example either.
Re: (Score:2)
Re: (Score:2)
Should be easy enough to figure out from a properly maintained public repo log. Just how opensource is the apple SSL kit?
Re: (Score:2)
It's pretty darn open: http://opensource.apple.com/so... [apple.com]
Re: (Score:1)
IMHO This should have been caught in the developer's IDE as a dead code warning.
p.s. This should have also been caught by automated code coverage tests.
Re: (Score:2)
This is a C Standard Bug (Score:4, Informative)
Re: (Score:3)
I never saw a bug related to braces, this bug neither is.
If at all the bug is (difficult to spot) because of a wrong indentation.
Bottom line the bug is absolutely obvious. You read the code from top to bottom and you see the bug, or you don't has nothing to do with braces or indentation.
It is the old C versus Python argument. The argument makes no sense. Either you can read the code and comprehend it or you cant.
No compiler, bracing or anything else can prevent it.
Re: (Score:3)
You may claim the bug is obvious and yet it slipped through to production. So rather than bring up the blame-log on the indvidual developer - programmers make mistakes and enforcing coding standards such as indentation or braces help in identifying errors where errant coders fail.
If indeed Apple does have a coding standard, then this one slipped through. Using an IDE to pretty-print the code according to the coding standard, prior to checkin, would have revealed the inconsistency of indentation in the dupli
Re: (Score:3)
I would say the main problem with this style of coding is the use of gotos.
Well, most programmers laugh at me and call me unproductive when I spend roughly an hour every morning to visually check every change comming from the version control system. Meanwhile however most organizations use tools like fisheye and do a planned review on the changes.
I don't know if demanding more braces help. I think in this particular code every condition in the ifs should be refactored into a function returning a boolean. Th
Re: (Score:2)
Either you can read the code and comprehend it or you cant.
If that were true, no competent coder would ever have bugs in his code.
It's like this sentence... Count the number of Fs.
FINISHED FILES ARE THE RE-
SULT OF YEARS OF SCIENTIF-
IC STUDY COMBINED WITH
THE EXPERIENCE OF YEARS.
Most people, despite their fluency of the English language will miscount the number of Fs.
Enforced braces, compilers that are indentation aware, and better detection of unreachable code would would all reduce the number of times that errors of the type in the SSL bug occur. That's an indisput
Re: (Score:2)
Ah, your point about the unreachable code, that makes sense. ... I blame it on the stupidity to chain if's and use gotos instead of writing one if with one else branch. ;) I wonder why you think it is so difficlut to count them?
The rest is a matter of taste
Well, regarding your F count: the last line of your 'poem' contains none
Re: (Score:2)
The last line contains one F. See, it's not so easy, is it?
The vast majority of people will count 3 Fs in the text at the first attempt. Yet there are 6 Fs.
And nobody bother claiming they got 6 Fs first time. Your bragging, true or false, won't change the point that understanding a language doesn't mean one can parse it perfectly every time.
Re: (Score:2)
THE EXPERIENCE OF YEARS
There is no F.
Well, I don't know if it is a language parsing problem.
I started programming with Basic. To gotos right behind each other are always wrong. So for me it was simple.
I don't brag, I simply state that having braces likely had not prevented the error. As your example with the F ... some people are bad with { and }
Re: (Score:2)
THE EXPERIENCE OF YEARS
There is no F.
So you got it wrong again. Here's a clue. What's the second letter of "OF"?
I rest my case.
Re: (Score:2)
You are rigt, there is an F :)
Pretty interesting, indeed.
I only found it a few hours ago, or rather I did not, I only found it by googeling "count the Fs" problem.
The solution had it highlighted in a different colour, otherwise I had not seen it.
I moved my finger from letter to letter and still I did not see the F in the of, surprisingly, I saw the F in the other of, pretty strange.
(How ever I wonder why that should be IQ related, two web sites covering that topic said so)
Re: (Score:3)
Lint tools can catch this sort of unconditional goto which one would hope is never used intentionally by goto afficionados.
Re: (Score:2)
Compiler warnings or source code analysis tools are often ignored though, sadly, as an afterthought or distraction.
Re: (Score:2)
Not in reputable software teams. Generally the flags are set to report warnings as errors. And nothing with a warning would make it into a mainline build.
There are occasions when a warning is unavoidable. But then that requires positive action to use use pragma to turn the warning off and back on again around the offending line. And that should be commented as to why. It can't be ignored.
Re: (Score:2)
I am a member of the C and C++ standards committees. I'm sorry to tell you your proposal is inane, and were it to come up I wilk veto it.
Re: (Score:2)
Watch as the dinosaurs refuse to evolve.
Re: (Score:1)
This same argument can be made about all kinds of things that compilers warn about. But yet, compilers warn. Why? Because any competent programmer will admit that they are not perfect, and use every tool they can to help prevent their own mistakes. At least an option to warn about missing braces like this would help avoid silly mistakes like this that *do* creep into code.
Re: (Score:2)
Your argument isn't working. In the wild, iOS and OSX have been exploited because somebody failed to notice this error. This is a thing that actually happened. Doesn't really matter whose fault it is and if they are all morons, what matters is whether we can we make it less likely.
I would propose that a Python-like static analyser might be able to catch this sort of thing, provided you don't get too fancy with macros. The fact is, virtually everybody has standardized on indentation for if statements as
Re: (Score:1)
So use a fucking editor that indents things correctly (ie. not Emacs or Vi). You would literally never have these sorts of errors if your editor doesn't allow free-form indentation. You are editing a program, not free-form text, there is absolutely no excuse for freeform indentation outside of comments, and even there it is generally bad form.
How does this work? (Score:2)
So how does "Researcher Adam Langley" get access to the code in order to do "an analysis of the vulnerable code in OS X"?
Do these experts have access to the source via some agreement with the vendor?
Re: (Score:1)
opensource.apple.com
Re: (Score:2, Insightful)
No.
Just access:
http://opensource.apple.com/so... [apple.com]
So I guess that it can have been exploited for some time.
Test fail (Score:2)
At mine, the test site at https://www.imperialviolet.org:1266/ [imperialviolet.org] does not even load. Firefox says:
Secure Connection Failed An error occurred during a connection to www.imperialviolet.org:1266. A PKCS #11 module returned CKR_DEVICE_ERROR, indicating that a problem has occurred with the token or slot. (Error code: sec_error_pkcs11_device_error)
Re: (Score:2)
I get
The webpage at https://www.imperialviolet.org... [imperialviolet.org] might be temporarily down or it may have moved permanently to a new web address.
Error code: ERR_FAILED
Obligatory (Score:1)
"You're bracketing it wrong."
Nobody has mentioned the obvious (Score:1)
Why on *earth* does this code have G*T*'s in it! !!!!
Re:Apple (Score:4, Funny)
I bet your mom gives out root access to the world.
Re: (Score:2)
Re: (Score:2)
No, it was a stupid coding standards error
if (x)
goto error;
goto error;
if (y)
goto error;
error:
return
if the coding standards required braces around the code block like this
if (x)
{
goto error;
goto error;
}
it would have eliminated the effects of this coding error
Re: Considering Apple admitted.... (Score:1)
If the language would require the braces it would even be better...
Re: (Score:2)
If the language would require the braces it would even be better...
You mean like this?
if (0)
{ goto fail; }
{ goto fail; }
exit(0);
Re: (Score:2)
If you like, yes. Because that usage would be certain to have people looking closely to see what the fuck is going on.
Re: (Score:2)
Except when you consider the possibility that this was introduced with a code merging utility with line number issues, and no human actually looked at the code for a good while.
Honestly I don't see how having two indented lines under an unbraced if sticks ouy any less. It certainly jumps off the page for me.
Re: (Score:2)
That's even more alarming. This is not just "Widget A", this is the main TLS implementation in the operating system. You just don't do automatic code merges without looking at the result. Seriously.
Re: (Score:2)
No, it was a stupid coding standards error
Which is just what you would do to have plausible deniability. :-P
Re: (Score:2)
Because bugs exist testing must not?
Re: (Score:2)
That wasn't a programming class, it was brainwashing by CS people. There's nothing wrong with goto itself.
It makes perfect sense to use if you have a function that does initialization, a number of processing steps and ends with cleanup. If any of the steps fail you can jump directly to the cleanup code. This is particularly useful in C where you lack exceptions. If you don't use goto's you tend to get much more heavily indented code riddled with conditionals and code duplication. When handled properly a got
Re: (Score:1)
OK - I didn't see this post before I posted. Apologies - someone did mention the obvious ;-)
Re: (Score:2)
I haven't posted on Slashdot for a while, but I find it necessary to point this out.
IMO it _is_ a problem with goto.
The code was structured like this: .. //hey - a redundant goto!
if(err=aFunctionReturningZeroOnSuccessOrErrorCode()) != 0) goto cleanup;
if(err=anotherFunctionReturningZeroOnSuccessOrErrorCode()) != 0) goto cleanup;
err = oneLastFunctionReturningZeroOnSuccessOrErrorCode();
if(err != 0) { doSomeLogging(); goto cleanup; }
cleanup: freeStuff(); return err;
It could have been written completely without