apps/s_cb.c:405: error: NULL_DEREFERENCE
  pointer `ec` last assigned on line 402 could be null and is dereferenced by call to `EC_KEY_get0_group()` at line 405, column 43.
Showing all 34 steps of the trace


apps/s_cb.c:385:1: start of procedure ssl_print_tmp_key()
383.   #endif
384.   
385. > int ssl_print_tmp_key(BIO *out, SSL *s)
386.   {
387.       EVP_PKEY *key;

apps/s_cb.c:388:10: Taking false branch
386.   {
387.       EVP_PKEY *key;
388.       if (!SSL_get_server_tmp_key(s, &key))
                ^
389.           return 1;
390.       BIO_puts(out, "Server Temp Key: ");

apps/s_cb.c:390:5: 
388.       if (!SSL_get_server_tmp_key(s, &key))
389.           return 1;
390. >     BIO_puts(out, "Server Temp Key: ");
391.       switch (EVP_PKEY_id(key)) {
392.       case EVP_PKEY_RSA:

crypto/bio/bio_lib.c:388:1: start of procedure BIO_puts()
  386.   }
  387.   
  388. > int BIO_puts(BIO *b, const char *buf)
  389.   {
  390.       int ret;

crypto/bio/bio_lib.c:391:5: 
  389.   {
  390.       int ret;
  391. >     size_t written = 0;
  392.   
  393.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {

crypto/bio/bio_lib.c:393:10: Taking false branch
  391.       size_t written = 0;
  392.   
  393.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
                  ^
  394.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
  395.           return -2;

crypto/bio/bio_lib.c:393:25: Taking false branch
  391.       size_t written = 0;
  392.   
  393.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
                                 ^
  394.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
  395.           return -2;

crypto/bio/bio_lib.c:393:48: Taking false branch
  391.       size_t written = 0;
  392.   
  393.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
                                                        ^
  394.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
  395.           return -2;

crypto/bio/bio_lib.c:398:9: Taking false branch
  396.       }
  397.   
  398.       if (b->callback != NULL || b->callback_ex != NULL) {
                 ^
  399.           ret = (int)bio_call_callback(b, BIO_CB_PUTS, buf, 0, 0, 0L, 1L, NULL);
  400.           if (ret <= 0)

crypto/bio/bio_lib.c:398:32: Taking false branch
  396.       }
  397.   
  398.       if (b->callback != NULL || b->callback_ex != NULL) {
                                        ^
  399.           ret = (int)bio_call_callback(b, BIO_CB_PUTS, buf, 0, 0, 0L, 1L, NULL);
  400.           if (ret <= 0)

crypto/bio/bio_lib.c:404:10: Taking true branch
  402.       }
  403.   
  404.       if (!b->init) {
                  ^
  405.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);
  406.           return -2;

crypto/bio/bio_lib.c:405:9: Skipping ERR_put_error(): empty list of specs
  403.   
  404.       if (!b->init) {
  405.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);
                 ^
  406.           return -2;
  407.       }

crypto/bio/bio_lib.c:406:9: 
  404.       if (!b->init) {
  405.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);
  406. >         return -2;
  407.       }
  408.   

crypto/bio/bio_lib.c:431:1: return from a call to BIO_puts
  429.   
  430.       return ret;
  431. > }
  432.   
  433.   int BIO_gets(BIO *b, char *buf, int size)

apps/s_cb.c:391:5: 
389.           return 1;
390.       BIO_puts(out, "Server Temp Key: ");
391. >     switch (EVP_PKEY_id(key)) {
392.       case EVP_PKEY_RSA:
393.           BIO_printf(out, "RSA, %d bits\n", EVP_PKEY_bits(key));

crypto/evp/p_lib.c:428:1: start of procedure EVP_PKEY_id()
  426.   }
  427.   
  428. > int EVP_PKEY_id(const EVP_PKEY *pkey)
  429.   {
  430.       return pkey->type;

crypto/evp/p_lib.c:430:5: 
  428.   int EVP_PKEY_id(const EVP_PKEY *pkey)
  429.   {
  430. >     return pkey->type;
  431.   }
  432.   

crypto/evp/p_lib.c:431:1: return from a call to EVP_PKEY_id
  429.   {
  430.       return pkey->type;
  431. > }
  432.   
  433.   int EVP_PKEY_base_id(const EVP_PKEY *pkey)

apps/s_cb.c:392:5: Switch condition is false. Skipping switch case
390.       BIO_puts(out, "Server Temp Key: ");
391.       switch (EVP_PKEY_id(key)) {
392.       case EVP_PKEY_RSA:
           ^
393.           BIO_printf(out, "RSA, %d bits\n", EVP_PKEY_bits(key));
394.           break;

apps/s_cb.c:396:5: Switch condition is false. Skipping switch case
394.           break;
395.   
396.       case EVP_PKEY_DH:
           ^
397.           BIO_printf(out, "DH, %d bits\n", EVP_PKEY_bits(key));
398.           break;

apps/s_cb.c:400:5: Switch condition is true. Entering switch case
398.           break;
399.   #ifndef OPENSSL_NO_EC
400.       case EVP_PKEY_EC:
           ^
401.           {
402.               EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);

apps/s_cb.c:402:13: 
400.       case EVP_PKEY_EC:
401.           {
402. >             EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
403.               int nid;
404.               const char *cname;

crypto/evp/p_lib.c:375:1: start of procedure EVP_PKEY_get1_EC_KEY()
  373.   }
  374.   
  375. > EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
  376.   {
  377.       EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);

crypto/evp/p_lib.c:377:5: 
  375.   EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
  376.   {
  377. >     EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);
  378.       if (ret != NULL)
  379.           EC_KEY_up_ref(ret);

crypto/evp/p_lib.c:366:1: start of procedure EVP_PKEY_get0_EC_KEY()
    364.   }
    365.   
    366. > EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
    367.   {
    368.       if (pkey->type != EVP_PKEY_EC) {

crypto/evp/p_lib.c:368:9: Taking false branch
    366.   EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
    367.   {
    368.       if (pkey->type != EVP_PKEY_EC) {
                   ^
    369.           EVPerr(EVP_F_EVP_PKEY_GET0_EC_KEY, EVP_R_EXPECTING_A_EC_KEY);
    370.           return NULL;

crypto/evp/p_lib.c:372:5: 
    370.           return NULL;
    371.       }
    372. >     return pkey->pkey.ec;
    373.   }
    374.   

crypto/evp/p_lib.c:373:1: return from a call to EVP_PKEY_get0_EC_KEY
    371.       }
    372.       return pkey->pkey.ec;
    373. > }
    374.   
    375.   EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)

crypto/evp/p_lib.c:378:9: Taking false branch
  376.   {
  377.       EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);
  378.       if (ret != NULL)
                 ^
  379.           EC_KEY_up_ref(ret);
  380.       return ret;

crypto/evp/p_lib.c:380:5: 
  378.       if (ret != NULL)
  379.           EC_KEY_up_ref(ret);
  380. >     return ret;
  381.   }
  382.   #endif

crypto/evp/p_lib.c:381:1: return from a call to EVP_PKEY_get1_EC_KEY
  379.           EC_KEY_up_ref(ret);
  380.       return ret;
  381. > }
  382.   #endif
  383.   

apps/s_cb.c:405:13: 
403.               int nid;
404.               const char *cname;
405. >             nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
406.               EC_KEY_free(ec);
407.               cname = EC_curve_nid2nist(nid);

crypto/ec/ec_key.c:419:1: start of procedure EC_KEY_get0_group()
  417.   }
  418.   
  419. > const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
  420.   {
  421.       return key->group;

crypto/ec/ec_key.c:421:5: 
  419.   const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
  420.   {
  421. >     return key->group;
  422.   }
  423.   

int ssl_print_tmp_key(BIO *out, SSL *s)
{
    EVP_PKEY *key;
    if (!SSL_get_server_tmp_key(s, &key))
        return 1;
    BIO_puts(out, "Server Temp Key: ");
    switch (EVP_PKEY_id(key)) {
    case EVP_PKEY_RSA:
        BIO_printf(out, "RSA, %d bits\n", EVP_PKEY_bits(key));
        break;
    case EVP_PKEY_DH:
        BIO_printf(out, "DH, %d bits\n", EVP_PKEY_bits(key));
        break;
#ifndef OPENSSL_NO_EC
    case EVP_PKEY_EC:
        {
            EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
            int nid;
            const char *cname;
            nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
            EC_KEY_free(ec);
            cname = EC_curve_nid2nist(nid);
            if (cname == NULL)
                cname = OBJ_nid2sn(nid);
            BIO_printf(out, "ECDH, %s, %d bits\n", cname, EVP_PKEY_bits(key));
        }
    break;
#endif
    default:
        BIO_printf(out, "%s, %d bits\n", OBJ_nid2sn(EVP_PKEY_id(key)),
                   EVP_PKEY_bits(key));
    }
    EVP_PKEY_free(key);
    return 1;
}
['int ssl_print_tmp_key(BIO *out, SSL *s)\n{\n    EVP_PKEY *key;\n    if (!SSL_get_server_tmp_key(s, &key))\n        return 1;\n    BIO_puts(out, "Server Temp Key: ");\n    switch (EVP_PKEY_id(key)) {\n    case EVP_PKEY_RSA:\n        BIO_printf(out, "RSA, %d bits\\n", EVP_PKEY_bits(key));\n        break;\n    case EVP_PKEY_DH:\n        BIO_printf(out, "DH, %d bits\\n", EVP_PKEY_bits(key));\n        break;\n#ifndef OPENSSL_NO_EC\n    case EVP_PKEY_EC:\n        {\n            EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);\n            int nid;\n            const char *cname;\n            nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));\n            EC_KEY_free(ec);\n            cname = EC_curve_nid2nist(nid);\n            if (cname == NULL)\n                cname = OBJ_nid2sn(nid);\n            BIO_printf(out, "ECDH, %s, %d bits\\n", cname, EVP_PKEY_bits(key));\n        }\n    break;\n#endif\n    default:\n        BIO_printf(out, "%s, %d bits\\n", OBJ_nid2sn(EVP_PKEY_id(key)),\n                   EVP_PKEY_bits(key));\n    }\n    EVP_PKEY_free(key);\n    return 1;\n}', 'int BIO_puts(BIO *b, const char *buf)\n{\n    int ret;\n    size_t written = 0;\n    if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {\n        BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);\n        return -2;\n    }\n    if (b->callback != NULL || b->callback_ex != NULL) {\n        ret = (int)bio_call_callback(b, BIO_CB_PUTS, buf, 0, 0, 0L, 1L, NULL);\n        if (ret <= 0)\n            return ret;\n    }\n    if (!b->init) {\n        BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);\n        return -2;\n    }\n    ret = b->method->bputs(b, buf);\n    if (ret > 0) {\n        b->num_write += (uint64_t)ret;\n        written = ret;\n        ret = 1;\n    }\n    if (b->callback != NULL || b->callback_ex != NULL)\n        ret = (int)bio_call_callback(b, BIO_CB_PUTS | BIO_CB_RETURN, buf, 0, 0,\n                                     0L, ret, &written);\n    if (ret > 0) {\n        if (written > INT_MAX) {\n            BIOerr(BIO_F_BIO_PUTS, BIO_R_LENGTH_TOO_LONG);\n            ret = -1;\n        } else {\n            ret = (int)written;\n        }\n    }\n    return ret;\n}', 'int EVP_PKEY_id(const EVP_PKEY *pkey)\n{\n    return pkey->type;\n}', 'EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)\n{\n    EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);\n    if (ret != NULL)\n        EC_KEY_up_ref(ret);\n    return ret;\n}', 'EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)\n{\n    if (pkey->type != EVP_PKEY_EC) {\n        EVPerr(EVP_F_EVP_PKEY_GET0_EC_KEY, EVP_R_EXPECTING_A_EC_KEY);\n        return NULL;\n    }\n    return pkey->pkey.ec;\n}', 'const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)\n{\n    return key->group;\n}']