crypto/rsa/rsa_pmeth.c:284: error: NULL_DEREFERENCE
  pointer `null` is dereferenced by call to `pkey_rsa_verifyrecover()` at line 284, column 17.
Showing all 24 steps of the trace


crypto/rsa/rsa_pmeth.c:272:1: start of procedure pkey_rsa_verify()
270.   }
271.   
272. > static int pkey_rsa_verify(EVP_PKEY_CTX *ctx,
273.                              const unsigned char *sig, size_t siglen,
274.                              const unsigned char *tbs, size_t tbslen)

crypto/rsa/rsa_pmeth.c:276:5: 
274.                              const unsigned char *tbs, size_t tbslen)
275.   {
276. >     RSA_PKEY_CTX *rctx = ctx->data;
277.       RSA *rsa = ctx->pkey->pkey.rsa;
278.       size_t rslen;

crypto/rsa/rsa_pmeth.c:277:5: 
275.   {
276.       RSA_PKEY_CTX *rctx = ctx->data;
277. >     RSA *rsa = ctx->pkey->pkey.rsa;
278.       size_t rslen;
279.       if (rctx->md) {

crypto/rsa/rsa_pmeth.c:279:9: Taking true branch
277.       RSA *rsa = ctx->pkey->pkey.rsa;
278.       size_t rslen;
279.       if (rctx->md) {
               ^
280.           if (rctx->pad_mode == RSA_PKCS1_PADDING)
281.               return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen,

crypto/rsa/rsa_pmeth.c:280:13: Taking false branch
278.       size_t rslen;
279.       if (rctx->md) {
280.           if (rctx->pad_mode == RSA_PKCS1_PADDING)
                   ^
281.               return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen,
282.                                 sig, siglen, rsa);

crypto/rsa/rsa_pmeth.c:283:13: Taking true branch
281.               return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen,
282.                                 sig, siglen, rsa);
283.           if (rctx->pad_mode == RSA_X931_PADDING) {
                   ^
284.               if (pkey_rsa_verifyrecover(ctx, NULL, &rslen, sig, siglen) <= 0)
285.                   return 0;

crypto/rsa/rsa_pmeth.c:284:17: 
282.                                 sig, siglen, rsa);
283.           if (rctx->pad_mode == RSA_X931_PADDING) {
284. >             if (pkey_rsa_verifyrecover(ctx, NULL, &rslen, sig, siglen) <= 0)
285.                   return 0;
286.           } else if (rctx->pad_mode == RSA_PKCS1_PSS_PADDING) {

crypto/rsa/rsa_pmeth.c:224:1: start of procedure pkey_rsa_verifyrecover()
  222.   }
  223.   
  224. > static int pkey_rsa_verifyrecover(EVP_PKEY_CTX *ctx,
  225.                                     unsigned char *rout, size_t *routlen,
  226.                                     const unsigned char *sig, size_t siglen)

crypto/rsa/rsa_pmeth.c:229:5: 
  227.   {
  228.       int ret;
  229. >     RSA_PKEY_CTX *rctx = ctx->data;
  230.   
  231.       if (rctx->md) {

crypto/rsa/rsa_pmeth.c:231:9: Taking true branch
  229.       RSA_PKEY_CTX *rctx = ctx->data;
  230.   
  231.       if (rctx->md) {
                 ^
  232.           if (rctx->pad_mode == RSA_X931_PADDING) {
  233.               if (!setup_tbuf(rctx, ctx))

crypto/rsa/rsa_pmeth.c:232:13: Taking true branch
  230.   
  231.       if (rctx->md) {
  232.           if (rctx->pad_mode == RSA_X931_PADDING) {
                     ^
  233.               if (!setup_tbuf(rctx, ctx))
  234.                   return -1;

crypto/rsa/rsa_pmeth.c:233:18: 
  231.       if (rctx->md) {
  232.           if (rctx->pad_mode == RSA_X931_PADDING) {
  233. >             if (!setup_tbuf(rctx, ctx))
  234.                   return -1;
  235.               ret = RSA_public_decrypt(siglen, sig,

crypto/rsa/rsa_pmeth.c:138:1: start of procedure setup_tbuf()
    136.   }
    137.   
    138. > static int setup_tbuf(RSA_PKEY_CTX *ctx, EVP_PKEY_CTX *pk)
    139.   {
    140.       if (ctx->tbuf)

crypto/rsa/rsa_pmeth.c:140:9: Taking true branch
    138.   static int setup_tbuf(RSA_PKEY_CTX *ctx, EVP_PKEY_CTX *pk)
    139.   {
    140.       if (ctx->tbuf)
                   ^
    141.           return 1;
    142.       ctx->tbuf = OPENSSL_malloc(EVP_PKEY_size(pk->pkey));

crypto/rsa/rsa_pmeth.c:141:9: 
    139.   {
    140.       if (ctx->tbuf)
    141. >         return 1;
    142.       ctx->tbuf = OPENSSL_malloc(EVP_PKEY_size(pk->pkey));
    143.       if (ctx->tbuf == NULL)

crypto/rsa/rsa_pmeth.c:146:1: return from a call to setup_tbuf
    144.           return 0;
    145.       return 1;
    146. > }
    147.   
    148.   static void pkey_rsa_cleanup(EVP_PKEY_CTX *ctx)

crypto/rsa/rsa_pmeth.c:233:18: Taking false branch
  231.       if (rctx->md) {
  232.           if (rctx->pad_mode == RSA_X931_PADDING) {
  233.               if (!setup_tbuf(rctx, ctx))
                          ^
  234.                   return -1;
  235.               ret = RSA_public_decrypt(siglen, sig,

crypto/rsa/rsa_pmeth.c:235:13: 
  233.               if (!setup_tbuf(rctx, ctx))
  234.                   return -1;
  235. >             ret = RSA_public_decrypt(siglen, sig,
  236.                                        rctx->tbuf, ctx->pkey->pkey.rsa,
  237.                                        RSA_X931_PADDING);

crypto/rsa/rsa_crpt.c:94:1: start of procedure RSA_public_decrypt()
    92.   }
    93.   
    94. > int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to,
    95.                          RSA *rsa, int padding)
    96.   {

crypto/rsa/rsa_crpt.c:97:5: Skipping __function_pointer__(): unresolved function pointer
    95.                          RSA *rsa, int padding)
    96.   {
    97.       return (rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding));
               ^
    98.   }
    99.   

crypto/rsa/rsa_crpt.c:98:1: return from a call to RSA_public_decrypt
    96.   {
    97.       return (rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding));
    98. > }
    99.   
    100.   int RSA_flags(const RSA *r)

crypto/rsa/rsa_pmeth.c:238:17: Taking true branch
  236.                                        rctx->tbuf, ctx->pkey->pkey.rsa,
  237.                                        RSA_X931_PADDING);
  238.               if (ret < 1)
                         ^
  239.                   return 0;
  240.               ret--;

crypto/rsa/rsa_pmeth.c:239:17: 
  237.                                        RSA_X931_PADDING);
  238.               if (ret < 1)
  239. >                 return 0;
  240.               ret--;
  241.               if (rctx->tbuf[ret] != RSA_X931_hash_id(EVP_MD_type(rctx->md))) {

crypto/rsa/rsa_pmeth.c:270:1: return from a call to pkey_rsa_verifyrecover
  268.       *routlen = ret;
  269.       return 1;
  270. > }
  271.   
  272.   static int pkey_rsa_verify(EVP_PKEY_CTX *ctx,

static int pkey_rsa_verify(EVP_PKEY_CTX *ctx,
                           const unsigned char *sig, size_t siglen,
                           const unsigned char *tbs, size_t tbslen)
{
    RSA_PKEY_CTX *rctx = ctx->data;
    RSA *rsa = ctx->pkey->pkey.rsa;
    size_t rslen;
    if (rctx->md) {
        if (rctx->pad_mode == RSA_PKCS1_PADDING)
            return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen,
                              sig, siglen, rsa);
        if (rctx->pad_mode == RSA_X931_PADDING) {
            if (pkey_rsa_verifyrecover(ctx, NULL, &rslen, sig, siglen) <= 0)
                return 0;
        } else if (rctx->pad_mode == RSA_PKCS1_PSS_PADDING) {
            int ret;
            if (!setup_tbuf(rctx, ctx))
                return -1;
            ret = RSA_public_decrypt(siglen, sig, rctx->tbuf,
                                     rsa, RSA_NO_PADDING);
            if (ret <= 0)
                return 0;
            ret = RSA_verify_PKCS1_PSS_mgf1(rsa, tbs,
                                            rctx->md, rctx->mgf1md,
                                            rctx->tbuf, rctx->saltlen);
            if (ret <= 0)
                return 0;
            return 1;
        } else
            return -1;
    } else {
        if (!setup_tbuf(rctx, ctx))
            return -1;
        rslen = RSA_public_decrypt(siglen, sig, rctx->tbuf,
                                   rsa, rctx->pad_mode);
        if (rslen == 0)
            return 0;
    }
    if ((rslen != tbslen) || memcmp(tbs, rctx->tbuf, rslen))
        return 0;
    return 1;
}
['static int pkey_rsa_verify(EVP_PKEY_CTX *ctx,\n                           const unsigned char *sig, size_t siglen,\n                           const unsigned char *tbs, size_t tbslen)\n{\n    RSA_PKEY_CTX *rctx = ctx->data;\n    RSA *rsa = ctx->pkey->pkey.rsa;\n    size_t rslen;\n    if (rctx->md) {\n        if (rctx->pad_mode == RSA_PKCS1_PADDING)\n            return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen,\n                              sig, siglen, rsa);\n        if (rctx->pad_mode == RSA_X931_PADDING) {\n            if (pkey_rsa_verifyrecover(ctx, NULL, &rslen, sig, siglen) <= 0)\n                return 0;\n        } else if (rctx->pad_mode == RSA_PKCS1_PSS_PADDING) {\n            int ret;\n            if (!setup_tbuf(rctx, ctx))\n                return -1;\n            ret = RSA_public_decrypt(siglen, sig, rctx->tbuf,\n                                     rsa, RSA_NO_PADDING);\n            if (ret <= 0)\n                return 0;\n            ret = RSA_verify_PKCS1_PSS_mgf1(rsa, tbs,\n                                            rctx->md, rctx->mgf1md,\n                                            rctx->tbuf, rctx->saltlen);\n            if (ret <= 0)\n                return 0;\n            return 1;\n        } else\n            return -1;\n    } else {\n        if (!setup_tbuf(rctx, ctx))\n            return -1;\n        rslen = RSA_public_decrypt(siglen, sig, rctx->tbuf,\n                                   rsa, rctx->pad_mode);\n        if (rslen == 0)\n            return 0;\n    }\n    if ((rslen != tbslen) || memcmp(tbs, rctx->tbuf, rslen))\n        return 0;\n    return 1;\n}', 'static int pkey_rsa_verifyrecover(EVP_PKEY_CTX *ctx,\n                                  unsigned char *rout, size_t *routlen,\n                                  const unsigned char *sig, size_t siglen)\n{\n    int ret;\n    RSA_PKEY_CTX *rctx = ctx->data;\n    if (rctx->md) {\n        if (rctx->pad_mode == RSA_X931_PADDING) {\n            if (!setup_tbuf(rctx, ctx))\n                return -1;\n            ret = RSA_public_decrypt(siglen, sig,\n                                     rctx->tbuf, ctx->pkey->pkey.rsa,\n                                     RSA_X931_PADDING);\n            if (ret < 1)\n                return 0;\n            ret--;\n            if (rctx->tbuf[ret] != RSA_X931_hash_id(EVP_MD_type(rctx->md))) {\n                RSAerr(RSA_F_PKEY_RSA_VERIFYRECOVER,\n                       RSA_R_ALGORITHM_MISMATCH);\n                return 0;\n            }\n            if (ret != EVP_MD_size(rctx->md)) {\n                RSAerr(RSA_F_PKEY_RSA_VERIFYRECOVER,\n                       RSA_R_INVALID_DIGEST_LENGTH);\n                return 0;\n            }\n            if (rout)\n                memcpy(rout, rctx->tbuf, ret);\n        } else if (rctx->pad_mode == RSA_PKCS1_PADDING) {\n            size_t sltmp;\n            ret = int_rsa_verify(EVP_MD_type(rctx->md),\n                                 NULL, 0, rout, &sltmp,\n                                 sig, siglen, ctx->pkey->pkey.rsa);\n            if (ret <= 0)\n                return 0;\n            ret = sltmp;\n        } else\n            return -1;\n    } else\n        ret = RSA_public_decrypt(siglen, sig, rout, ctx->pkey->pkey.rsa,\n                                 rctx->pad_mode);\n    if (ret < 0)\n        return ret;\n    *routlen = ret;\n    return 1;\n}', 'static int setup_tbuf(RSA_PKEY_CTX *ctx, EVP_PKEY_CTX *pk)\n{\n    if (ctx->tbuf)\n        return 1;\n    ctx->tbuf = OPENSSL_malloc(EVP_PKEY_size(pk->pkey));\n    if (ctx->tbuf == NULL)\n        return 0;\n    return 1;\n}', 'int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to,\n                       RSA *rsa, int padding)\n{\n    return (rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding));\n}']