summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorinoguchi <>2022-01-22 00:34:48 +0000
committerinoguchi <>2022-01-22 00:34:48 +0000
commit37f9c924dfb51feb0b51e0445d8f00d9818d9381 (patch)
tree3312a59256d7a027afc9d4779d744a4dffa48994 /src
parent4d9d2a4ca4c44d0e5f4b26337113b6f241ab2e56 (diff)
downloadopenbsd-37f9c924dfb51feb0b51e0445d8f00d9818d9381.tar.gz
openbsd-37f9c924dfb51feb0b51e0445d8f00d9818d9381.tar.bz2
openbsd-37f9c924dfb51feb0b51e0445d8f00d9818d9381.zip
X509_GET_PUBKEY(3) return value check in libcrypto
CID 25131 ok beck@ tb@ suggest using X509_REQ_get0_pubkey() and remove the EVP_PKEY_free() from tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/x509/x509_req.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/libcrypto/x509/x509_req.c b/src/lib/libcrypto/x509/x509_req.c
index ffe9b8607f..8d5bf58509 100644
--- a/src/lib/libcrypto/x509/x509_req.c
+++ b/src/lib/libcrypto/x509/x509_req.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_req.c,v 1.27 2021/12/12 21:30:14 tb Exp $ */ 1/* $OpenBSD: x509_req.c,v 1.28 2022/01/22 00:34:48 inoguchi Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -138,7 +138,9 @@ X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k)
138 EVP_PKEY *xk = NULL; 138 EVP_PKEY *xk = NULL;
139 int ok = 0; 139 int ok = 0;
140 140
141 xk = X509_REQ_get_pubkey(x); 141 if ((xk = X509_REQ_get0_pubkey(x)) == NULL)
142 return 0;
143
142 switch (EVP_PKEY_cmp(xk, k)) { 144 switch (EVP_PKEY_cmp(xk, k)) {
143 case 1: 145 case 1:
144 ok = 1; 146 ok = 1;
@@ -166,7 +168,6 @@ X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k)
166 X509error(X509_R_UNKNOWN_KEY_TYPE); 168 X509error(X509_R_UNKNOWN_KEY_TYPE);
167 } 169 }
168 170
169 EVP_PKEY_free(xk);
170 return (ok); 171 return (ok);
171} 172}
172 173