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


apps/s_cb.c:394:1: start of procedure ssl_print_tmp_key()
392.   #endif
393.   
394. > int ssl_print_tmp_key(BIO *out, SSL *s)
395.   {
396.       EVP_PKEY *key;

apps/s_cb.c:397:10: Taking false branch
395.   {
396.       EVP_PKEY *key;
397.       if (!SSL_get_server_tmp_key(s, &key))
                ^
398.           return 1;
399.       BIO_puts(out, "Server Temp Key: ");

apps/s_cb.c:399:5: 
397.       if (!SSL_get_server_tmp_key(s, &key))
398.           return 1;
399. >     BIO_puts(out, "Server Temp Key: ");
400.       switch (EVP_PKEY_id(key)) {
401.       case EVP_PKEY_RSA:

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

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

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

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

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

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

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

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

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

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

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

apps/s_cb.c:400:5: 
398.           return 1;
399.       BIO_puts(out, "Server Temp Key: ");
400. >     switch (EVP_PKEY_id(key)) {
401.       case EVP_PKEY_RSA:
402.           BIO_printf(out, "RSA, %d bits\n", EVP_PKEY_bits(key));

crypto/evp/p_lib.c:524:1: start of procedure EVP_PKEY_id()
  522.   }
  523.   
  524. > int EVP_PKEY_id(const EVP_PKEY *pkey)
  525.   {
  526.       return pkey->type;

crypto/evp/p_lib.c:526:5: 
  524.   int EVP_PKEY_id(const EVP_PKEY *pkey)
  525.   {
  526. >     return pkey->type;
  527.   }
  528.   

crypto/evp/p_lib.c:527:1: return from a call to EVP_PKEY_id
  525.   {
  526.       return pkey->type;
  527. > }
  528.   
  529.   int EVP_PKEY_base_id(const EVP_PKEY *pkey)

apps/s_cb.c:401:5: Switch condition is false. Skipping switch case
399.       BIO_puts(out, "Server Temp Key: ");
400.       switch (EVP_PKEY_id(key)) {
401.       case EVP_PKEY_RSA:
           ^
402.           BIO_printf(out, "RSA, %d bits\n", EVP_PKEY_bits(key));
403.           break;

apps/s_cb.c:405:5: Switch condition is false. Skipping switch case
403.           break;
404.   
405.       case EVP_PKEY_DH:
           ^
406.           BIO_printf(out, "DH, %d bits\n", EVP_PKEY_bits(key));
407.           break;

apps/s_cb.c:409:5: Switch condition is true. Entering switch case
407.           break;
408.   #ifndef OPENSSL_NO_EC
409.       case EVP_PKEY_EC:
           ^
410.           {
411.               EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);

apps/s_cb.c:411:13: 
409.       case EVP_PKEY_EC:
410.           {
411. >             EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
412.               int nid;
413.               const char *cname;

crypto/evp/p_lib.c:471:1: start of procedure EVP_PKEY_get1_EC_KEY()
  469.   }
  470.   
  471. > EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
  472.   {
  473.       EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);

crypto/evp/p_lib.c:473:5: 
  471.   EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
  472.   {
  473. >     EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);
  474.       if (ret != NULL)
  475.           EC_KEY_up_ref(ret);

crypto/evp/p_lib.c:462:1: start of procedure EVP_PKEY_get0_EC_KEY()
    460.   }
    461.   
    462. > EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
    463.   {
    464.       if (pkey->type != EVP_PKEY_EC) {

crypto/evp/p_lib.c:464:9: Taking false branch
    462.   EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
    463.   {
    464.       if (pkey->type != EVP_PKEY_EC) {
                   ^
    465.           EVPerr(EVP_F_EVP_PKEY_GET0_EC_KEY, EVP_R_EXPECTING_A_EC_KEY);
    466.           return NULL;

crypto/evp/p_lib.c:468:5: 
    466.           return NULL;
    467.       }
    468. >     return pkey->pkey.ec;
    469.   }
    470.   

crypto/evp/p_lib.c:469:1: return from a call to EVP_PKEY_get0_EC_KEY
    467.       }
    468.       return pkey->pkey.ec;
    469. > }
    470.   
    471.   EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)

crypto/evp/p_lib.c:474:9: Taking false branch
  472.   {
  473.       EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);
  474.       if (ret != NULL)
                 ^
  475.           EC_KEY_up_ref(ret);
  476.       return ret;

crypto/evp/p_lib.c:476:5: 
  474.       if (ret != NULL)
  475.           EC_KEY_up_ref(ret);
  476. >     return ret;
  477.   }
  478.   #endif

crypto/evp/p_lib.c:477:1: return from a call to EVP_PKEY_get1_EC_KEY
  475.           EC_KEY_up_ref(ret);
  476.       return ret;
  477. > }
  478.   #endif
  479.   

apps/s_cb.c:414:13: 
412.               int nid;
413.               const char *cname;
414. >             nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
415.               EC_KEY_free(ec);
416.               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}']