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


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

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

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

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

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

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

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

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

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

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

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

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}']