If pk is NULL, the backend would segfault when accessing ->algo and the
authorHeikki Linnakangas <[email protected]>
Wed, 20 Oct 2010 19:20:33 +0000 (22:20 +0300)
committerHeikki Linnakangas <[email protected]>
Wed, 20 Oct 2010 19:25:12 +0000 (22:25 +0300)
following NULL check was never reached.

This problem was found by Coccinelle (null_ref.cocci from coccicheck).

Marti Raudsepp

contrib/pgcrypto/pgp-pubenc.c

index de729476f592b4d1f4d71fa47d574d7ab9eb9688..7db6ce1ee9d511a69b5793eaa5d253dad4c22b88 100644 (file)
@@ -199,7 +199,7 @@ pgp_write_pubenc_sesskey(PGP_Context * ctx, PushFilter * dst)
    PGP_PubKey *pk = ctx->pub_key;
    uint8       ver = 3;
    PushFilter *pkt = NULL;
-   uint8       algo = pk->algo;
+   uint8       algo;
 
    if (pk == NULL)
    {
@@ -207,6 +207,8 @@ pgp_write_pubenc_sesskey(PGP_Context * ctx, PushFilter * dst)
        return PXE_BUG;
    }
 
+   algo = pk->algo;
+
    /*
     * now write packet
     */