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


ssl/t1_lib.c:4045:1: start of procedure ssl_get_auto_dh()
4043.   
4044.   #ifndef OPENSSL_NO_DH
4045. > DH *ssl_get_auto_dh(SSL *s)
4046.   {
4047.       int dh_secbits = 80;

ssl/t1_lib.c:4047:5: 
4045.   DH *ssl_get_auto_dh(SSL *s)
4046.   {
4047. >     int dh_secbits = 80;
4048.       if (s->cert->dh_tmp_auto == 2)
4049.           return DH_get_1024_160();

ssl/t1_lib.c:4048:9: Taking false branch
4046.   {
4047.       int dh_secbits = 80;
4048.       if (s->cert->dh_tmp_auto == 2)
                ^
4049.           return DH_get_1024_160();
4050.       if (s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aPSK)) {

ssl/t1_lib.c:4050:9: Taking false branch
4048.       if (s->cert->dh_tmp_auto == 2)
4049.           return DH_get_1024_160();
4050.       if (s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aPSK)) {
                ^
4051.           if (s->s3->tmp.new_cipher->strength_bits == 256)
4052.               dh_secbits = 128;

ssl/t1_lib.c:4056:9: 
4054.               dh_secbits = 80;
4055.       } else {
4056. >         CERT_PKEY *cpk = ssl_get_server_send_pkey(s);
4057.           dh_secbits = EVP_PKEY_security_bits(cpk->privatekey);
4058.       }

ssl/ssl_lib.c:2645:1: start of procedure ssl_get_server_send_pkey()
  2643.   }
  2644.   
  2645. > CERT_PKEY *ssl_get_server_send_pkey(SSL *s)
  2646.   {
  2647.       CERT *c;

ssl/ssl_lib.c:2650:5: 
  2648.       int i;
  2649.   
  2650. >     c = s->cert;
  2651.       if (!s->s3 || !s->s3->tmp.new_cipher)
  2652.           return NULL;

ssl/ssl_lib.c:2651:10: Taking false branch
  2649.   
  2650.       c = s->cert;
  2651.       if (!s->s3 || !s->s3->tmp.new_cipher)
                   ^
  2652.           return NULL;
  2653.       ssl_set_masks(s);

ssl/ssl_lib.c:2651:20: Taking false branch
  2649.   
  2650.       c = s->cert;
  2651.       if (!s->s3 || !s->s3->tmp.new_cipher)
                             ^
  2652.           return NULL;
  2653.       ssl_set_masks(s);

ssl/ssl_lib.c:2653:5: Skipping ssl_set_masks(): empty list of specs
  2651.       if (!s->s3 || !s->s3->tmp.new_cipher)
  2652.           return NULL;
  2653.       ssl_set_masks(s);
              ^
  2654.   
  2655.       i = ssl_get_server_cert_index(s);

ssl/ssl_lib.c:2655:5: 
  2653.       ssl_set_masks(s);
  2654.   
  2655. >     i = ssl_get_server_cert_index(s);
  2656.   
  2657.       /* This may or may not be an error. */

ssl/ssl_lib.c:2624:1: start of procedure ssl_get_server_cert_index()
    2622.   #endif
    2623.   
    2624. > static int ssl_get_server_cert_index(const SSL *s)
    2625.   {
    2626.       int idx;

ssl/ssl_lib.c:2627:5: 
    2625.   {
    2626.       int idx;
    2627. >     idx = ssl_cipher_get_cert_index(s->s3->tmp.new_cipher);
    2628.       if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)
    2629.           idx = SSL_PKEY_RSA_SIGN;

ssl/ssl_ciph.c:1920:1: start of procedure ssl_cipher_get_cert_index()
      1918.   
      1919.   /* For a cipher return the index corresponding to the certificate type */
      1920. > int ssl_cipher_get_cert_index(const SSL_CIPHER *c)
      1921.   {
      1922.       uint32_t alg_a;

ssl/ssl_ciph.c:1924:5: 
      1922.       uint32_t alg_a;
      1923.   
      1924. >     alg_a = c->algorithm_auth;
      1925.   
      1926.       if (alg_a & SSL_aECDSA)

ssl/ssl_ciph.c:1926:9: Taking false branch
      1924.       alg_a = c->algorithm_auth;
      1925.   
      1926.       if (alg_a & SSL_aECDSA)
                      ^
      1927.           return SSL_PKEY_ECC;
      1928.       else if (alg_a & SSL_aDSS)

ssl/ssl_ciph.c:1928:14: Taking false branch
      1926.       if (alg_a & SSL_aECDSA)
      1927.           return SSL_PKEY_ECC;
      1928.       else if (alg_a & SSL_aDSS)
                           ^
      1929.           return SSL_PKEY_DSA_SIGN;
      1930.       else if (alg_a & SSL_aRSA)

ssl/ssl_ciph.c:1930:14: Taking true branch
      1928.       else if (alg_a & SSL_aDSS)
      1929.           return SSL_PKEY_DSA_SIGN;
      1930.       else if (alg_a & SSL_aRSA)
                           ^
      1931.           return SSL_PKEY_RSA_ENC;
      1932.       else if (alg_a & SSL_aGOST12)

ssl/ssl_ciph.c:1931:9: 
      1929.           return SSL_PKEY_DSA_SIGN;
      1930.       else if (alg_a & SSL_aRSA)
      1931. >         return SSL_PKEY_RSA_ENC;
      1932.       else if (alg_a & SSL_aGOST12)
      1933.           return SSL_PKEY_GOST_EC;

ssl/ssl_ciph.c:1938:1: return from a call to ssl_cipher_get_cert_index
      1936.   
      1937.       return -1;
      1938. > }
      1939.   
      1940.   const SSL_CIPHER *ssl_get_cipher_by_char(SSL *ssl, const unsigned char *ptr)

ssl/ssl_lib.c:2628:9: Taking true branch
    2626.       int idx;
    2627.       idx = ssl_cipher_get_cert_index(s->s3->tmp.new_cipher);
    2628.       if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)
                    ^
    2629.           idx = SSL_PKEY_RSA_SIGN;
    2630.       if (idx == SSL_PKEY_GOST_EC) {

ssl/ssl_lib.c:2628:37: Taking false branch
    2626.       int idx;
    2627.       idx = ssl_cipher_get_cert_index(s->s3->tmp.new_cipher);
    2628.       if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)
                                                ^
    2629.           idx = SSL_PKEY_RSA_SIGN;
    2630.       if (idx == SSL_PKEY_GOST_EC) {

ssl/ssl_lib.c:2630:9: Taking false branch
    2628.       if (idx == SSL_PKEY_RSA_ENC && !s->cert->pkeys[SSL_PKEY_RSA_ENC].x509)
    2629.           idx = SSL_PKEY_RSA_SIGN;
    2630.       if (idx == SSL_PKEY_GOST_EC) {
                    ^
    2631.           if (s->cert->pkeys[SSL_PKEY_GOST12_512].x509)
    2632.               idx = SSL_PKEY_GOST12_512;

ssl/ssl_lib.c:2640:9: Taking false branch
    2638.               idx = -1;
    2639.       }
    2640.       if (idx == -1)
                    ^
    2641.           SSLerr(SSL_F_SSL_GET_SERVER_CERT_INDEX, ERR_R_INTERNAL_ERROR);
    2642.       return idx;

ssl/ssl_lib.c:2642:5: 
    2640.       if (idx == -1)
    2641.           SSLerr(SSL_F_SSL_GET_SERVER_CERT_INDEX, ERR_R_INTERNAL_ERROR);
    2642. >     return idx;
    2643.   }
    2644.   

ssl/ssl_lib.c:2643:1: return from a call to ssl_get_server_cert_index
    2641.           SSLerr(SSL_F_SSL_GET_SERVER_CERT_INDEX, ERR_R_INTERNAL_ERROR);
    2642.       return idx;
    2643. > }
    2644.   
    2645.   CERT_PKEY *ssl_get_server_send_pkey(SSL *s)

ssl/ssl_lib.c:2658:9: Taking true branch
  2656.   
  2657.       /* This may or may not be an error. */
  2658.       if (i < 0)
                  ^
  2659.           return NULL;
  2660.   

ssl/ssl_lib.c:2659:9: 
  2657.       /* This may or may not be an error. */
  2658.       if (i < 0)
  2659. >         return NULL;
  2660.   
  2661.       /* May be NULL. */

ssl/ssl_lib.c:2663:1: return from a call to ssl_get_server_send_pkey
  2661.       /* May be NULL. */
  2662.       return &c->pkeys[i];
  2663. > }
  2664.   
  2665.   EVP_PKEY *ssl_get_sign_pkey(SSL *s, const SSL_CIPHER *cipher,

ssl/t1_lib.c:4057:9: 
4055.       } else {
4056.           CERT_PKEY *cpk = ssl_get_server_send_pkey(s);
4057. >         dh_secbits = EVP_PKEY_security_bits(cpk->privatekey);
4058.       }
4059.   

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);\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}']