ssl/t1_lib.c:2164: error: NULL_DEREFERENCE
  pointer `cpk` last assigned on line 2163 could be null and is dereferenced at line 2164, column 45.
Showing all 15 steps of the trace


ssl/t1_lib.c:2152:1: start of procedure ssl_get_auto_dh()
2150.   
2151.   #ifndef OPENSSL_NO_DH
2152. > DH *ssl_get_auto_dh(SSL *s)
2153.   {
2154.       int dh_secbits = 80;

ssl/t1_lib.c:2154:5: 
2152.   DH *ssl_get_auto_dh(SSL *s)
2153.   {
2154. >     int dh_secbits = 80;
2155.       if (s->cert->dh_tmp_auto == 2)
2156.           return DH_get_1024_160();

ssl/t1_lib.c:2155:9: Taking false branch
2153.   {
2154.       int dh_secbits = 80;
2155.       if (s->cert->dh_tmp_auto == 2)
                ^
2156.           return DH_get_1024_160();
2157.       if (s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aPSK)) {

ssl/t1_lib.c:2157:9: Taking false branch
2155.       if (s->cert->dh_tmp_auto == 2)
2156.           return DH_get_1024_160();
2157.       if (s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aPSK)) {
                ^
2158.           if (s->s3->tmp.new_cipher->strength_bits == 256)
2159.               dh_secbits = 128;

ssl/t1_lib.c:2163:9: 
2161.               dh_secbits = 80;
2162.       } else {
2163. >         CERT_PKEY *cpk = ssl_get_server_send_pkey(s);
2164.           dh_secbits = EVP_PKEY_security_bits(cpk->privatekey);
2165.       }

ssl/ssl_lib.c:2867:1: start of procedure ssl_get_server_send_pkey()
  2865.   }
  2866.   
  2867. > CERT_PKEY *ssl_get_server_send_pkey(SSL *s)
  2868.   {
  2869.       CERT *c;

ssl/ssl_lib.c:2872:5: 
  2870.       int i;
  2871.   
  2872. >     c = s->cert;
  2873.       if (!s->s3 || !s->s3->tmp.new_cipher)
  2874.           return NULL;

ssl/ssl_lib.c:2873:10: Taking false branch
  2871.   
  2872.       c = s->cert;
  2873.       if (!s->s3 || !s->s3->tmp.new_cipher)
                   ^
  2874.           return NULL;
  2875.       ssl_set_masks(s);

ssl/ssl_lib.c:2873:20: Taking false branch
  2871.   
  2872.       c = s->cert;
  2873.       if (!s->s3 || !s->s3->tmp.new_cipher)
                             ^
  2874.           return NULL;
  2875.       ssl_set_masks(s);

ssl/ssl_lib.c:2875:5: Skipping ssl_set_masks(): empty list of specs
  2873.       if (!s->s3 || !s->s3->tmp.new_cipher)
  2874.           return NULL;
  2875.       ssl_set_masks(s);
              ^
  2876.   
  2877.       i = ssl_get_server_cert_index(s);

ssl/ssl_lib.c:2877:5: Skipping ssl_get_server_cert_index(): empty list of specs
  2875.       ssl_set_masks(s);
  2876.   
  2877.       i = ssl_get_server_cert_index(s);
              ^
  2878.   
  2879.       /* This may or may not be an error. */

ssl/ssl_lib.c:2880:9: Taking true branch
  2878.   
  2879.       /* This may or may not be an error. */
  2880.       if (i < 0)
                  ^
  2881.           return NULL;
  2882.   

ssl/ssl_lib.c:2881:9: 
  2879.       /* This may or may not be an error. */
  2880.       if (i < 0)
  2881. >         return NULL;
  2882.   
  2883.       /* May be NULL. */

ssl/ssl_lib.c:2885:1: return from a call to ssl_get_server_send_pkey
  2883.       /* May be NULL. */
  2884.       return &c->pkeys[i];
  2885. > }
  2886.   
  2887.   EVP_PKEY *ssl_get_sign_pkey(SSL *s, const SSL_CIPHER *cipher,

ssl/t1_lib.c:2164:9: 
2162.       } else {
2163.           CERT_PKEY *cpk = ssl_get_server_send_pkey(s);
2164. >         dh_secbits = EVP_PKEY_security_bits(cpk->privatekey);
2165.       }
2166.   

DH *ssl_get_auto_dh(SSL *s)
{
    int dh_secbits = 80;
    if (s->cert->dh_tmp_auto == 2)
        return DH_get_1024_160();
    if (s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aPSK)) {
        if (s->s3->tmp.new_cipher->strength_bits == 256)
            dh_secbits = 128;
        else
            dh_secbits = 80;
    } else {
        CERT_PKEY *cpk = ssl_get_server_send_pkey(s);
        dh_secbits = EVP_PKEY_security_bits(cpk->privatekey);
    }
    if (dh_secbits >= 128) {
        DH *dhp = DH_new();
        BIGNUM *p, *g;
        if (dhp == NULL)
            return NULL;
        g = BN_new();
        if (g != NULL)
            BN_set_word(g, 2);
        if (dh_secbits >= 192)
            p = BN_get_rfc3526_prime_8192(NULL);
        else
            p = BN_get_rfc3526_prime_3072(NULL);
        if (p == NULL || g == NULL || !DH_set0_pqg(dhp, p, NULL, g)) {
            DH_free(dhp);
            BN_free(p);
            BN_free(g);
            return NULL;
        }
        return dhp;
    }
    if (dh_secbits >= 112)
        return DH_get_2048_224();
    return DH_get_1024_160();
}
['DH *ssl_get_auto_dh(SSL *s)\n{\n    int dh_secbits = 80;\n    if (s->cert->dh_tmp_auto == 2)\n        return DH_get_1024_160();\n    if (s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aPSK)) {\n        if (s->s3->tmp.new_cipher->strength_bits == 256)\n            dh_secbits = 128;\n        else\n            dh_secbits = 80;\n    } else {\n        CERT_PKEY *cpk = ssl_get_server_send_pkey(s);\n        dh_secbits = EVP_PKEY_security_bits(cpk->privatekey);\n    }\n    if (dh_secbits >= 128) {\n        DH *dhp = DH_new();\n        BIGNUM *p, *g;\n        if (dhp == NULL)\n            return NULL;\n        g = BN_new();\n        if (g != NULL)\n            BN_set_word(g, 2);\n        if (dh_secbits >= 192)\n            p = BN_get_rfc3526_prime_8192(NULL);\n        else\n            p = BN_get_rfc3526_prime_3072(NULL);\n        if (p == NULL || g == NULL || !DH_set0_pqg(dhp, p, NULL, g)) {\n            DH_free(dhp);\n            BN_free(p);\n            BN_free(g);\n            return NULL;\n        }\n        return dhp;\n    }\n    if (dh_secbits >= 112)\n        return DH_get_2048_224();\n    return DH_get_1024_160();\n}', 'CERT_PKEY *ssl_get_server_send_pkey(SSL *s)\n{\n    CERT *c;\n    int i;\n    c = s->cert;\n    if (!s->s3 || !s->s3->tmp.new_cipher)\n        return NULL;\n    ssl_set_masks(s);\n    i = ssl_get_server_cert_index(s);\n    if (i < 0)\n        return NULL;\n    return &c->pkeys[i];\n}']