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


ssl/t1_lib.c:4217:1: start of procedure ssl_get_auto_dh()
4215.   
4216.   #ifndef OPENSSL_NO_DH
4217. > DH *ssl_get_auto_dh(SSL *s)
4218.   {
4219.       int dh_secbits = 80;

ssl/t1_lib.c:4219:5: 
4217.   DH *ssl_get_auto_dh(SSL *s)
4218.   {
4219. >     int dh_secbits = 80;
4220.       if (s->cert->dh_tmp_auto == 2)
4221.           return DH_get_1024_160();

ssl/t1_lib.c:4220:9: Taking false branch
4218.   {
4219.       int dh_secbits = 80;
4220.       if (s->cert->dh_tmp_auto == 2)
                ^
4221.           return DH_get_1024_160();
4222.       if (s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aPSK)) {

ssl/t1_lib.c:4222:9: Taking false branch
4220.       if (s->cert->dh_tmp_auto == 2)
4221.           return DH_get_1024_160();
4222.       if (s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aPSK)) {
                ^
4223.           if (s->s3->tmp.new_cipher->strength_bits == 256)
4224.               dh_secbits = 128;

ssl/t1_lib.c:4228:9: 
4226.               dh_secbits = 80;
4227.       } else {
4228. >         CERT_PKEY *cpk = ssl_get_server_send_pkey(s);
4229.           dh_secbits = EVP_PKEY_security_bits(cpk->privatekey);
4230.       }

ssl/ssl_lib.c:2662:1: start of procedure ssl_get_server_send_pkey()
  2660.   }
  2661.   
  2662. > CERT_PKEY *ssl_get_server_send_pkey(SSL *s)
  2663.   {
  2664.       CERT *c;

ssl/ssl_lib.c:2667:5: 
  2665.       int i;
  2666.   
  2667. >     c = s->cert;
  2668.       if (!s->s3 || !s->s3->tmp.new_cipher)
  2669.           return NULL;

ssl/ssl_lib.c:2668:10: Taking false branch
  2666.   
  2667.       c = s->cert;
  2668.       if (!s->s3 || !s->s3->tmp.new_cipher)
                   ^
  2669.           return NULL;
  2670.       ssl_set_masks(s, s->s3->tmp.new_cipher);

ssl/ssl_lib.c:2668:20: Taking false branch
  2666.   
  2667.       c = s->cert;
  2668.       if (!s->s3 || !s->s3->tmp.new_cipher)
                             ^
  2669.           return NULL;
  2670.       ssl_set_masks(s, s->s3->tmp.new_cipher);

ssl/ssl_lib.c:2670:5: Skipping ssl_set_masks(): empty list of specs
  2668.       if (!s->s3 || !s->s3->tmp.new_cipher)
  2669.           return NULL;
  2670.       ssl_set_masks(s, s->s3->tmp.new_cipher);
              ^
  2671.   
  2672.   #ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL

ssl/ssl_lib.c:2681:5: 
  2679.   #endif
  2680.   
  2681. >     i = ssl_get_server_cert_index(s);
  2682.   
  2683.       /* This may or may not be an error. */

ssl/ssl_lib.c:2641:1: start of procedure ssl_get_server_cert_index()
    2639.   #endif
    2640.   
    2641. > static int ssl_get_server_cert_index(const SSL *s)
    2642.   {
    2643.       int idx;

ssl/ssl_lib.c:2644:5: 
    2642.   {
    2643.       int idx;
    2644. >     idx = ssl_cipher_get_cert_index(s->s3->tmp.new_cipher);
    2645.       if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)
    2646.           idx = SSL_PKEY_RSA_SIGN;

ssl/ssl_ciph.c:1941:1: start of procedure ssl_cipher_get_cert_index()
      1939.   
      1940.   /* For a cipher return the index corresponding to the certificate type */
      1941. > int ssl_cipher_get_cert_index(const SSL_CIPHER *c)
      1942.   {
      1943.       uint32_t alg_k, alg_a;

ssl/ssl_ciph.c:1945:5: 
      1943.       uint32_t alg_k, alg_a;
      1944.   
      1945. >     alg_k = c->algorithm_mkey;
      1946.       alg_a = c->algorithm_auth;
      1947.   

ssl/ssl_ciph.c:1946:5: 
      1944.   
      1945.       alg_k = c->algorithm_mkey;
      1946. >     alg_a = c->algorithm_auth;
      1947.   
      1948.       if (alg_k & (SSL_kECDHr | SSL_kECDHe)) {

ssl/ssl_ciph.c:1948:9: Taking false branch
      1946.       alg_a = c->algorithm_auth;
      1947.   
      1948.       if (alg_k & (SSL_kECDHr | SSL_kECDHe)) {
                      ^
      1949.           /*
      1950.            * we don't need to look at SSL_kECDHE since no certificate is needed

ssl/ssl_ciph.c:1958:16: Taking false branch
      1956.            */
      1957.           return SSL_PKEY_ECC;
      1958.       } else if (alg_a & SSL_aECDSA)
                             ^
      1959.           return SSL_PKEY_ECC;
      1960.       else if (alg_a & SSL_aDSS)

ssl/ssl_ciph.c:1960:14: Taking false branch
      1958.       } else if (alg_a & SSL_aECDSA)
      1959.           return SSL_PKEY_ECC;
      1960.       else if (alg_a & SSL_aDSS)
                           ^
      1961.           return SSL_PKEY_DSA_SIGN;
      1962.       else if (alg_a & SSL_aRSA)

ssl/ssl_ciph.c:1962:14: Taking true branch
      1960.       else if (alg_a & SSL_aDSS)
      1961.           return SSL_PKEY_DSA_SIGN;
      1962.       else if (alg_a & SSL_aRSA)
                           ^
      1963.           return SSL_PKEY_RSA_ENC;
      1964.       else if (alg_a & SSL_aGOST12)

ssl/ssl_ciph.c:1963:9: 
      1961.           return SSL_PKEY_DSA_SIGN;
      1962.       else if (alg_a & SSL_aRSA)
      1963. >         return SSL_PKEY_RSA_ENC;
      1964.       else if (alg_a & SSL_aGOST12)
      1965.           return SSL_PKEY_GOST_EC;

ssl/ssl_ciph.c:1970:1: return from a call to ssl_cipher_get_cert_index
      1968.   
      1969.       return -1;
      1970. > }
      1971.   
      1972.   const SSL_CIPHER *ssl_get_cipher_by_char(SSL *ssl, const unsigned char *ptr)

ssl/ssl_lib.c:2645:9: Taking true branch
    2643.       int idx;
    2644.       idx = ssl_cipher_get_cert_index(s->s3->tmp.new_cipher);
    2645.       if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)
                    ^
    2646.           idx = SSL_PKEY_RSA_SIGN;
    2647.       if (idx == SSL_PKEY_GOST_EC) {

ssl/ssl_lib.c:2645:37: Taking false branch
    2643.       int idx;
    2644.       idx = ssl_cipher_get_cert_index(s->s3->tmp.new_cipher);
    2645.       if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)
                                                ^
    2646.           idx = SSL_PKEY_RSA_SIGN;
    2647.       if (idx == SSL_PKEY_GOST_EC) {

ssl/ssl_lib.c:2647:9: Taking false branch
    2645.       if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)
    2646.           idx = SSL_PKEY_RSA_SIGN;
    2647.       if (idx == SSL_PKEY_GOST_EC) {
                    ^
    2648.           if (s->cert->pkeys[SSL_PKEY_GOST12_512].x509)
    2649.               idx = SSL_PKEY_GOST12_512;

ssl/ssl_lib.c:2657:9: Taking false branch
    2655.               idx = -1;
    2656.       }
    2657.       if (idx == -1)
                    ^
    2658.           SSLerr(SSL_F_SSL_GET_SERVER_CERT_INDEX, ERR_R_INTERNAL_ERROR);
    2659.       return idx;

ssl/ssl_lib.c:2659:5: 
    2657.       if (idx == -1)
    2658.           SSLerr(SSL_F_SSL_GET_SERVER_CERT_INDEX, ERR_R_INTERNAL_ERROR);
    2659. >     return idx;
    2660.   }
    2661.   

ssl/ssl_lib.c:2660:1: return from a call to ssl_get_server_cert_index
    2658.           SSLerr(SSL_F_SSL_GET_SERVER_CERT_INDEX, ERR_R_INTERNAL_ERROR);
    2659.       return idx;
    2660. > }
    2661.   
    2662.   CERT_PKEY *ssl_get_server_send_pkey(SSL *s)

ssl/ssl_lib.c:2684:9: Taking true branch
  2682.   
  2683.       /* This may or may not be an error. */
  2684.       if (i < 0)
                  ^
  2685.           return NULL;
  2686.   

ssl/ssl_lib.c:2685:9: 
  2683.       /* This may or may not be an error. */
  2684.       if (i < 0)
  2685. >         return NULL;
  2686.   
  2687.       /* May be NULL. */

ssl/ssl_lib.c:2689:1: return from a call to ssl_get_server_send_pkey
  2687.       /* May be NULL. */
  2688.       return &c->pkeys[i];
  2689. > }
  2690.   
  2691.   EVP_PKEY *ssl_get_sign_pkey(SSL *s, const SSL_CIPHER *cipher,

ssl/t1_lib.c:4229:9: 
4227.       } else {
4228.           CERT_PKEY *cpk = ssl_get_server_send_pkey(s);
4229. >         dh_secbits = EVP_PKEY_security_bits(cpk->privatekey);
4230.       }
4231.   

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();
        if (dhp == NULL)
            return NULL;
        dhp->g = BN_new();
        if (dhp->g != NULL)
            BN_set_word(dhp->g, 2);
        if (dh_secbits >= 192)
            dhp->p = get_rfc3526_prime_8192(NULL);
        else
            dhp->p = get_rfc3526_prime_3072(NULL);
        if (dhp->p == NULL || dhp->g == NULL) {
            DH_free(dhp);
            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        if (dhp == NULL)\n            return NULL;\n        dhp->g = BN_new();\n        if (dhp->g != NULL)\n            BN_set_word(dhp->g, 2);\n        if (dh_secbits >= 192)\n            dhp->p = get_rfc3526_prime_8192(NULL);\n        else\n            dhp->p = get_rfc3526_prime_3072(NULL);\n        if (dhp->p == NULL || dhp->g == NULL) {\n            DH_free(dhp);\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, s->s3->tmp.new_cipher);\n#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL\n    if (c->cert_flags & SSL_CERT_FLAG_BROKEN_PROTOCOL)\n        return c->key;\n#endif\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_k, alg_a;\n    alg_k = c->algorithm_mkey;\n    alg_a = c->algorithm_auth;\n    if (alg_k & (SSL_kECDHr | SSL_kECDHe)) {\n        return SSL_PKEY_ECC;\n    } else 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}']