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


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

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

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

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

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

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

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

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

crypto/x509/x509_req.c:129:5: 
127.   
128.       xk = X509_REQ_get_pubkey(x);
129. >     switch (EVP_PKEY_cmp(xk, k)) {
130.       case 1:
131.           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 (EVP_PKEY_id(k) == EVP_PKEY_EC) {
            X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, ERR_R_EC_LIB);
            break;
        }
#endif
#ifndef OPENSSL_NO_DH
        if (EVP_PKEY_id(k) == 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 (EVP_PKEY_id(k) == 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 (EVP_PKEY_id(k) == 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}']