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


ssl/t1_lib.c:3891:1: start of procedure ssl_get_auto_dh()
3889.   
3890.   #ifndef OPENSSL_NO_DH
3891. > DH *ssl_get_auto_dh(SSL *s)
3892.   {
3893.       int dh_secbits = 80;

ssl/t1_lib.c:3893:5: 
3891.   DH *ssl_get_auto_dh(SSL *s)
3892.   {
3893. >     int dh_secbits = 80;
3894.       if (s->cert->dh_tmp_auto == 2)
3895.           return DH_get_1024_160();

ssl/t1_lib.c:3894:9: Taking false branch
3892.   {
3893.       int dh_secbits = 80;
3894.       if (s->cert->dh_tmp_auto == 2)
                ^
3895.           return DH_get_1024_160();
3896.       if (s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aPSK)) {

ssl/t1_lib.c:3896:9: Taking false branch
3894.       if (s->cert->dh_tmp_auto == 2)
3895.           return DH_get_1024_160();
3896.       if (s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aPSK)) {
                ^
3897.           if (s->s3->tmp.new_cipher->strength_bits == 256)
3898.               dh_secbits = 128;

ssl/t1_lib.c:3902:9: 
3900.               dh_secbits = 80;
3901.       } else {
3902. >         CERT_PKEY *cpk = ssl_get_server_send_pkey(s);
3903.           dh_secbits = EVP_PKEY_security_bits(cpk->privatekey);
3904.       }

ssl/ssl_lib.c:2857:1: start of procedure ssl_get_server_send_pkey()
  2855.   }
  2856.   
  2857. > CERT_PKEY *ssl_get_server_send_pkey(SSL *s)
  2858.   {
  2859.       CERT *c;

ssl/ssl_lib.c:2862:5: 
  2860.       int i;
  2861.   
  2862. >     c = s->cert;
  2863.       if (!s->s3 || !s->s3->tmp.new_cipher)
  2864.           return NULL;

ssl/ssl_lib.c:2863:10: Taking false branch
  2861.   
  2862.       c = s->cert;
  2863.       if (!s->s3 || !s->s3->tmp.new_cipher)
                   ^
  2864.           return NULL;
  2865.       ssl_set_masks(s);

ssl/ssl_lib.c:2863:20: Taking false branch
  2861.   
  2862.       c = s->cert;
  2863.       if (!s->s3 || !s->s3->tmp.new_cipher)
                             ^
  2864.           return NULL;
  2865.       ssl_set_masks(s);

ssl/ssl_lib.c:2865:5: Skipping ssl_set_masks(): empty list of specs
  2863.       if (!s->s3 || !s->s3->tmp.new_cipher)
  2864.           return NULL;
  2865.       ssl_set_masks(s);
              ^
  2866.   
  2867.       i = ssl_get_server_cert_index(s);

ssl/ssl_lib.c:2867:5: 
  2865.       ssl_set_masks(s);
  2866.   
  2867. >     i = ssl_get_server_cert_index(s);
  2868.   
  2869.       /* This may or may not be an error. */

ssl/ssl_lib.c:2836:1: start of procedure ssl_get_server_cert_index()
    2834.   #endif
    2835.   
    2836. > static int ssl_get_server_cert_index(const SSL *s)
    2837.   {
    2838.       int idx;

ssl/ssl_lib.c:2839:5: 
    2837.   {
    2838.       int idx;
    2839. >     idx = ssl_cipher_get_cert_index(s->s3->tmp.new_cipher);
    2840.       if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)
    2841.           idx = SSL_PKEY_RSA_SIGN;

ssl/ssl_ciph.c:1875:1: start of procedure ssl_cipher_get_cert_index()
      1873.   
      1874.   /* For a cipher return the index corresponding to the certificate type */
      1875. > int ssl_cipher_get_cert_index(const SSL_CIPHER *c)
      1876.   {
      1877.       uint32_t alg_a;

ssl/ssl_ciph.c:1879:5: 
      1877.       uint32_t alg_a;
      1878.   
      1879. >     alg_a = c->algorithm_auth;
      1880.   
      1881.       if (alg_a & SSL_aECDSA)

ssl/ssl_ciph.c:1881:9: Taking false branch
      1879.       alg_a = c->algorithm_auth;
      1880.   
      1881.       if (alg_a & SSL_aECDSA)
                      ^
      1882.           return SSL_PKEY_ECC;
      1883.       else if (alg_a & SSL_aDSS)

ssl/ssl_ciph.c:1883:14: Taking false branch
      1881.       if (alg_a & SSL_aECDSA)
      1882.           return SSL_PKEY_ECC;
      1883.       else if (alg_a & SSL_aDSS)
                           ^
      1884.           return SSL_PKEY_DSA_SIGN;
      1885.       else if (alg_a & SSL_aRSA)

ssl/ssl_ciph.c:1885:14: Taking true branch
      1883.       else if (alg_a & SSL_aDSS)
      1884.           return SSL_PKEY_DSA_SIGN;
      1885.       else if (alg_a & SSL_aRSA)
                           ^
      1886.           return SSL_PKEY_RSA_ENC;
      1887.       else if (alg_a & SSL_aGOST12)

ssl/ssl_ciph.c:1886:9: 
      1884.           return SSL_PKEY_DSA_SIGN;
      1885.       else if (alg_a & SSL_aRSA)
      1886. >         return SSL_PKEY_RSA_ENC;
      1887.       else if (alg_a & SSL_aGOST12)
      1888.           return SSL_PKEY_GOST_EC;

ssl/ssl_ciph.c:1893:1: return from a call to ssl_cipher_get_cert_index
      1891.   
      1892.       return -1;
      1893. > }
      1894.   
      1895.   const SSL_CIPHER *ssl_get_cipher_by_char(SSL *ssl, const unsigned char *ptr)

ssl/ssl_lib.c:2840:9: Taking true branch
    2838.       int idx;
    2839.       idx = ssl_cipher_get_cert_index(s->s3->tmp.new_cipher);
    2840.       if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)
                    ^
    2841.           idx = SSL_PKEY_RSA_SIGN;
    2842.       if (idx == SSL_PKEY_GOST_EC) {

ssl/ssl_lib.c:2840:37: Taking false branch
    2838.       int idx;
    2839.       idx = ssl_cipher_get_cert_index(s->s3->tmp.new_cipher);
    2840.       if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)
                                                ^
    2841.           idx = SSL_PKEY_RSA_SIGN;
    2842.       if (idx == SSL_PKEY_GOST_EC) {

ssl/ssl_lib.c:2842:9: Taking false branch
    2840.       if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)
    2841.           idx = SSL_PKEY_RSA_SIGN;
    2842.       if (idx == SSL_PKEY_GOST_EC) {
                    ^
    2843.           if (s->cert->pkeys[SSL_PKEY_GOST12_512].x509)
    2844.               idx = SSL_PKEY_GOST12_512;

ssl/ssl_lib.c:2852:9: Taking false branch
    2850.               idx = -1;
    2851.       }
    2852.       if (idx == -1)
                    ^
    2853.           SSLerr(SSL_F_SSL_GET_SERVER_CERT_INDEX, ERR_R_INTERNAL_ERROR);
    2854.       return idx;

ssl/ssl_lib.c:2854:5: 
    2852.       if (idx == -1)
    2853.           SSLerr(SSL_F_SSL_GET_SERVER_CERT_INDEX, ERR_R_INTERNAL_ERROR);
    2854. >     return idx;
    2855.   }
    2856.   

ssl/ssl_lib.c:2855:1: return from a call to ssl_get_server_cert_index
    2853.           SSLerr(SSL_F_SSL_GET_SERVER_CERT_INDEX, ERR_R_INTERNAL_ERROR);
    2854.       return idx;
    2855. > }
    2856.   
    2857.   CERT_PKEY *ssl_get_server_send_pkey(SSL *s)

ssl/ssl_lib.c:2870:9: Taking true branch
  2868.   
  2869.       /* This may or may not be an error. */
  2870.       if (i < 0)
                  ^
  2871.           return NULL;
  2872.   

ssl/ssl_lib.c:2871:9: 
  2869.       /* This may or may not be an error. */
  2870.       if (i < 0)
  2871. >         return NULL;
  2872.   
  2873.       /* May be NULL. */

ssl/ssl_lib.c:2875:1: return from a call to ssl_get_server_send_pkey
  2873.       /* May be NULL. */
  2874.       return &c->pkeys[i];
  2875. > }
  2876.   
  2877.   EVP_PKEY *ssl_get_sign_pkey(SSL *s, const SSL_CIPHER *cipher,

ssl/t1_lib.c:3903:9: 
3901.       } else {
3902.           CERT_PKEY *cpk = ssl_get_server_send_pkey(s);
3903. >         dh_secbits = EVP_PKEY_security_bits(cpk->privatekey);
3904.       }
3905.   

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}', 'static int ssl_get_server_cert_index(const SSL *s)\n{\n    int idx;\n    idx = ssl_cipher_get_cert_index(s->s3->tmp.new_cipher);\n    if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)\n        idx = SSL_PKEY_RSA_SIGN;\n    if (idx == SSL_PKEY_GOST_EC) {\n        if (s->cert->pkeys[SSL_PKEY_GOST12_512].x509)\n            idx = SSL_PKEY_GOST12_512;\n        else if (s->cert->pkeys[SSL_PKEY_GOST12_256].x509)\n            idx = SSL_PKEY_GOST12_256;\n        else if (s->cert->pkeys[SSL_PKEY_GOST01].x509)\n            idx = SSL_PKEY_GOST01;\n        else\n            idx = -1;\n    }\n    if (idx == -1)\n        SSLerr(SSL_F_SSL_GET_SERVER_CERT_INDEX, ERR_R_INTERNAL_ERROR);\n    return idx;\n}', 'int ssl_cipher_get_cert_index(const SSL_CIPHER *c)\n{\n    uint32_t alg_a;\n    alg_a = c->algorithm_auth;\n    if (alg_a & SSL_aECDSA)\n        return SSL_PKEY_ECC;\n    else if (alg_a & SSL_aDSS)\n        return SSL_PKEY_DSA_SIGN;\n    else if (alg_a & SSL_aRSA)\n        return SSL_PKEY_RSA_ENC;\n    else if (alg_a & SSL_aGOST12)\n        return SSL_PKEY_GOST_EC;\n    else if (alg_a & SSL_aGOST01)\n        return SSL_PKEY_GOST01;\n    return -1;\n}']