apps/s_cb.c:415: error: NULL_DEREFERENCE
  pointer `ec` last assigned on line 412 could be null and is dereferenced by call to `EC_KEY_get0_group()` at line 415, 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:398:10: Taking false branch
396.       EVP_PKEY *key;
397.   
398.       if (!SSL_get_peer_tmp_key(s, &key))
                ^
399.           return 1;
400.       BIO_puts(out, "Server Temp Key: ");

apps/s_cb.c:400:5: 
398.       if (!SSL_get_peer_tmp_key(s, &key))
399.           return 1;
400. >     BIO_puts(out, "Server Temp Key: ");
401.       switch (EVP_PKEY_id(key)) {
402.       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:401:5: 
399.           return 1;
400.       BIO_puts(out, "Server Temp Key: ");
401. >     switch (EVP_PKEY_id(key)) {
402.       case EVP_PKEY_RSA:
403.           BIO_printf(out, "RSA, %d bits\n", EVP_PKEY_bits(key));

crypto/evp/p_lib.c:580:1: start of procedure EVP_PKEY_id()
  578.   }
  579.   
  580. > int EVP_PKEY_id(const EVP_PKEY *pkey)
  581.   {
  582.       return pkey->type;

crypto/evp/p_lib.c:582:5: 
  580.   int EVP_PKEY_id(const EVP_PKEY *pkey)
  581.   {
  582. >     return pkey->type;
  583.   }
  584.   

crypto/evp/p_lib.c:583:1: return from a call to EVP_PKEY_id
  581.   {
  582.       return pkey->type;
  583. > }
  584.   
  585.   int EVP_PKEY_base_id(const EVP_PKEY *pkey)

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

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

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

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

crypto/evp/p_lib.c:527:1: start of procedure EVP_PKEY_get1_EC_KEY()
  525.   }
  526.   
  527. > EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
  528.   {
  529.       EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);

crypto/evp/p_lib.c:529:5: 
  527.   EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
  528.   {
  529. >     EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);
  530.       if (ret != NULL)
  531.           EC_KEY_up_ref(ret);

crypto/evp/p_lib.c:518:1: start of procedure EVP_PKEY_get0_EC_KEY()
    516.   }
    517.   
    518. > EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
    519.   {
    520.       if (pkey->type != EVP_PKEY_EC) {

crypto/evp/p_lib.c:520:9: Taking false branch
    518.   EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
    519.   {
    520.       if (pkey->type != EVP_PKEY_EC) {
                   ^
    521.           EVPerr(EVP_F_EVP_PKEY_GET0_EC_KEY, EVP_R_EXPECTING_A_EC_KEY);
    522.           return NULL;

crypto/evp/p_lib.c:524:5: 
    522.           return NULL;
    523.       }
    524. >     return pkey->pkey.ec;
    525.   }
    526.   

crypto/evp/p_lib.c:525:1: return from a call to EVP_PKEY_get0_EC_KEY
    523.       }
    524.       return pkey->pkey.ec;
    525. > }
    526.   
    527.   EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)

crypto/evp/p_lib.c:530:9: Taking false branch
  528.   {
  529.       EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);
  530.       if (ret != NULL)
                 ^
  531.           EC_KEY_up_ref(ret);
  532.       return ret;

crypto/evp/p_lib.c:532:5: 
  530.       if (ret != NULL)
  531.           EC_KEY_up_ref(ret);
  532. >     return ret;
  533.   }
  534.   #endif

crypto/evp/p_lib.c:533:1: return from a call to EVP_PKEY_get1_EC_KEY
  531.           EC_KEY_up_ref(ret);
  532.       return ret;
  533. > }
  534.   #endif
  535.   

apps/s_cb.c:415:13: 
413.               int nid;
414.               const char *cname;
415. >             nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
416.               EC_KEY_free(ec);
417.               cname = EC_curve_nid2nist(nid);

crypto/ec/ec_key.c:398:1: start of procedure EC_KEY_get0_group()
  396.   }
  397.   
  398. > const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
  399.   {
  400.       return key->group;

crypto/ec/ec_key.c:400:5: 
  398.   const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
  399.   {
  400. >     return key->group;
  401.   }
  402.   

int ssl_print_tmp_key(BIO *out, SSL *s)
{
    EVP_PKEY *key;
    if (!SSL_get_peer_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_peer_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}']