goto fail
code:c
static OSStatus SSLVerifySignedServerKeyExchange(SSLContext* ctx, bool isRsa, SSLBuffer signedParams, uint8_t* signature, uint16_t signatureLen) {
OSStatus err;
// ...
if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail; // conditonary goto fail
goto fail; // always goto fail
if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0) // unreachable
goto fail;
// ...
fail:
SSLFreeBuffer(&signedHashes);
SSLFreeBuffer(&hashCtx);
return err;
}
名前の割に原因は goto よりも if 文の仕様の方が比重が大きい。Summer498.icon
こんな ↓ 書き方をしたら
code:c
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
こう ↓ 見えてしまう。
code:c
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
{
goto fail;
goto fail;
}
しかし、実際はこう ↓ である。
code:c
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
{
goto fail; // conditonary goto fail
}
goto fail; // always goto fail