[Cryptography] GOTO Considered Harmful

Patrick Chkoreff patrick at rayservers.net
Fri Feb 28 16:36:25 EST 2014


John Ioannidis wrote, On 02/28/2014 02:13 PM:

> I assume you are being sarcastic? The new code is even more awful.

You give no specifics, so I assume you object to the use of "||=".
Here's a new version which avoids ||=, and also avoids using the
assignment operator inside an expression:

  http://fexl.com/goto-considered-harmful

Note well:  All I have done is refactor Apple's code into a form that
does not involve "goto".  If each of my refactoring steps was correct,
then the resulting code should have exactly the same behavior as the
original.  That means *the bug is still there*, except now it's easier
to spot.

Also, if anyone complains about some corner case in the code where err
== 0 is returned erroneously, then great.  That exact same behavior also
occurs in Apple's original code, and I congratulate you on finding yet
another bug in *their* code.

I say all this just to forestall any retorts along the lines of "Hey,
your code has bugs too!"  Anyone who says that is missing the point of
my exercise.  Again:  if did the refactoring properly, then my code is
logically equivalent to Apple's code -- so any bug you find in my code
is also a bug in Apple's code.  Please understand that.

I have also added a third piece of code at the bottom which entirely
removes the egregious bug already found in Apple's code.


-- Patrick



More information about the cryptography mailing list