[Cryptography] The GOTO Squirrel! [was GOTO Considered Harmful]
Patrick Chkoreff
patrick at rayservers.net
Tue Mar 4 08:17:45 EST 2014
Eric Young wrote, On 03/03/2014 07:53 AM:
> The way I now handle errors in my bignum library is to have an error
> flag in the context that is always passed to functions. It is checked
> on function entry, if there is an error, this is returned, else do the
> function.
>
> So
>
> if ((ret = bn_mul(bn_ctx,r,a,b)) != 0) goto err;
> if ((ret = bn_add(bn_ctx,r,r,c)) != 0) goto err;
> err:
> /* cleanup */
> return(ret);
>
> becomes
>
> bn_mul(bn_ctx,r,a,b);
> bn_add(bn_ctx,r,r,c);
> ret = bn_ctx->error;
> /* cleanup */
> return(ret);
You know, I was thinking about this error-code chaining technique, and
how it enables writing straight-line code, in light of the
SSLVerifySignedServerKeyExchange function. (Source code at
http://fexl.com/goto-considered-harmful).
It occurred to me that I don't see how the hashOut value influences any
of the parameters passed to sslRawVerify. I suppose there's some
connection via pointer aliasing, but I don't immediately see it.
What am I missing here?
-- Patrick
More information about the cryptography
mailing list