News for hackers. Stuff that matters.

WaltSellers

Re:About the security content of iOS 7.0.6 on Thursday February 27, 2014 @12:25AM (#7310536)
Was there a more fundamental problem in the assumptions of the code?

The state of the operation is "success" (err==zero) until some step changes the state to "failure" (non-zero).

The state should be assumed to be "failure" until the last step changes it to "success".

Re:About the security content of iOS 7.0.6 on Wednesday February 26, 2014 @10:55PM (#7310313)
From a different point of view, part of the problem is the undefined state of the code at the "fail" label.

Execution will arrive there somehow, but the 'how' is unclear. The word "fail" implies you should reach that point only if there was an error, but that is a bad assumption in this case.

If the real answer to 'how did we get here?' was checked, then the bug could not hide in the undefined behavior. This would not allow a dangling goto to result in a false positive. A false negative will get someone's attention when their web page doesn't load.

Something like this could remove the undefined state:

      goto pass;
  fail:
    if ( err == 0 ) {
    	assert( err != 0 ); // BUG! variable must contain an error number
    	err = kSomeAppropriateErrorNumber;
    }
  pass:
    SSLFreeBuffer(&signedHashes);
    SSLFreeBuffer(&hashCtx);
    return err;
Re:About the security content of iOS 7.0.6 on Wednesday February 26, 2014 @10:39PM (#7310247)
What about these?

  - don't leave local variables uninitialized.
  - don't try to hand-optimize lines unnecessarily. 
  - don't mix assignments into boolean expressions. (Which is really an unneeded optimization.)
Re:About the security content of iOS 7.0.6 on Wednesday February 26, 2014 @10:35PM (#7310220)
At that point the variable 'err' is still zero (noErr). So the function returns noErr, the caller thinks everything is good, and the communication is allowed.
Re:About the security content of iOS 7.0.6 on Wednesday February 26, 2014 @10:27PM (#7310179)
Even if there were braces, the bug would still exist if the extra goto was outside the braces.

It might be more noticeable, but then, the original bug existed because no one noticed.