crypto/x509/x509_req.c:131: error: NULL_DEREFERENCE
  pointer `xk` last assigned on line 130 could be null and is dereferenced by call to `EVP_PKEY_cmp()` at line 131, column 13.
Showing all 11 steps of the trace


crypto/x509/x509_req.c:125:1: start of procedure X509_REQ_check_private_key()
123.   }
124.   
125. > int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k)
126.   {
127.       EVP_PKEY *xk = NULL;

crypto/x509/x509_req.c:127:5: 
125.   int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k)
126.   {
127. >     EVP_PKEY *xk = NULL;
128.       int ok = 0;
129.   

crypto/x509/x509_req.c:128:5: 
126.   {
127.       EVP_PKEY *xk = NULL;
128. >     int ok = 0;
129.   
130.       xk = X509_REQ_get_pubkey(x);

crypto/x509/x509_req.c:130:5: 
128.       int ok = 0;
129.   
130. >     xk = X509_REQ_get_pubkey(x);
131.       switch (EVP_PKEY_cmp(xk, k)) {
132.       case 1:

crypto/x509/x509_req.c:113:1: start of procedure X509_REQ_get_pubkey()
  111.   }
  112.   
  113. > EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req)
  114.   {
  115.       if (req == NULL)

crypto/x509/x509_req.c:115:9: Taking true branch
  113.   EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req)
  114.   {
  115.       if (req == NULL)
                 ^
  116.           return (NULL);
  117.       return (X509_PUBKEY_get(req->req_info.pubkey));

crypto/x509/x509_req.c:116:9: 
  114.   {
  115.       if (req == NULL)
  116. >         return (NULL);
  117.       return (X509_PUBKEY_get(req->req_info.pubkey));
  118.   }

crypto/x509/x509_req.c:118:1: return from a call to X509_REQ_get_pubkey
  116.           return (NULL);
  117.       return (X509_PUBKEY_get(req->req_info.pubkey));
  118. > }
  119.   
  120.   X509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *req)

crypto/x509/x509_req.c:131:5: 
129.   
130.       xk = X509_REQ_get_pubkey(x);
131. >     switch (EVP_PKEY_cmp(xk, k)) {
132.       case 1:
133.           ok = 1;

crypto/evp/p_lib.c:163:1: start of procedure EVP_PKEY_cmp()
  161.   }
  162.   
  163. > int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
  164.   {
  165.       if (a->type != b->type)

crypto/evp/p_lib.c:165:9: 
  163.   int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
  164.   {
  165. >     if (a->type != b->type)
  166.           return -1;
  167.   

int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k)
{
    EVP_PKEY *xk = NULL;
    int ok = 0;
    xk = X509_REQ_get_pubkey(x);
    switch (EVP_PKEY_cmp(xk, k)) {
    case 1:
        ok = 1;
        break;
    case 0:
        X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY,
                X509_R_KEY_VALUES_MISMATCH);
        break;
    case -1:
        X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, X509_R_KEY_TYPE_MISMATCH);
        break;
    case -2:
#ifndef OPENSSL_NO_EC
        if (k->type == EVP_PKEY_EC) {
            X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, ERR_R_EC_LIB);
            break;
        }
#endif
#ifndef OPENSSL_NO_DH
        if (k->type == EVP_PKEY_DH) {
            X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY,
                    X509_R_CANT_CHECK_DH_KEY);
            break;
        }
#endif
        X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, X509_R_UNKNOWN_KEY_TYPE);
    }
    EVP_PKEY_free(xk);
    return (ok);
}
['int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k)\n{\n    EVP_PKEY *xk = NULL;\n    int ok = 0;\n    xk = X509_REQ_get_pubkey(x);\n    switch (EVP_PKEY_cmp(xk, k)) {\n    case 1:\n        ok = 1;\n        break;\n    case 0:\n        X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY,\n                X509_R_KEY_VALUES_MISMATCH);\n        break;\n    case -1:\n        X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, X509_R_KEY_TYPE_MISMATCH);\n        break;\n    case -2:\n#ifndef OPENSSL_NO_EC\n        if (k->type == EVP_PKEY_EC) {\n            X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, ERR_R_EC_LIB);\n            break;\n        }\n#endif\n#ifndef OPENSSL_NO_DH\n        if (k->type == EVP_PKEY_DH) {\n            X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY,\n                    X509_R_CANT_CHECK_DH_KEY);\n            break;\n        }\n#endif\n        X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, X509_R_UNKNOWN_KEY_TYPE);\n    }\n    EVP_PKEY_free(xk);\n    return (ok);\n}', 'EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req)\n{\n    if (req == NULL)\n        return (NULL);\n    return (X509_PUBKEY_get(req->req_info.pubkey));\n}', 'int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)\n{\n    if (a->type != b->type)\n        return -1;\n    if (a->ameth) {\n        int ret;\n        if (a->ameth->param_cmp) {\n            ret = a->ameth->param_cmp(a, b);\n            if (ret <= 0)\n                return ret;\n        }\n        if (a->ameth->pub_cmp)\n            return a->ameth->pub_cmp(a, b);\n    }\n    return -2;\n}']