diff options
author | beck <> | 2018-04-08 16:57:57 +0000 |
---|---|---|
committer | beck <> | 2018-04-08 16:57:57 +0000 |
commit | f55451b08e4fd711fc9735faac842bc5cd19d400 (patch) | |
tree | 1287b39c2e09233a3e96a4f84d285ce0bf2dba52 /src | |
parent | cb3aa30294676dd1f9e40ea8ce72c0bd0e4f42d9 (diff) | |
download | openbsd-f55451b08e4fd711fc9735faac842bc5cd19d400.tar.gz openbsd-f55451b08e4fd711fc9735faac842bc5cd19d400.tar.bz2 openbsd-f55451b08e4fd711fc9735faac842bc5cd19d400.zip |
Fail early if an X509_VERIFY_PARAM is poisoned - don't allow
this to be "overridden" by the user supplied callback.
ok jsing@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index 8392f509e7..9b4c06310a 100644 --- a/src/lib/libcrypto/x509/x509_vfy.c +++ b/src/lib/libcrypto/x509/x509_vfy.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_vfy.c,v 1.69 2018/04/06 07:08:20 beck Exp $ */ | 1 | /* $OpenBSD: x509_vfy.c,v 1.70 2018/04/08 16:57:57 beck 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 | * |
@@ -185,9 +185,6 @@ check_hosts(X509 *x, X509_VERIFY_PARAM_ID *id) | |||
185 | size_t i, n; | 185 | size_t i, n; |
186 | char *name; | 186 | char *name; |
187 | 187 | ||
188 | if (id->poisoned) | ||
189 | return 0; | ||
190 | |||
191 | n = sk_OPENSSL_STRING_num(id->hosts); | 188 | n = sk_OPENSSL_STRING_num(id->hosts); |
192 | free(id->peername); | 189 | free(id->peername); |
193 | id->peername = NULL; | 190 | id->peername = NULL; |
@@ -208,10 +205,6 @@ check_id(X509_STORE_CTX *ctx) | |||
208 | X509_VERIFY_PARAM_ID *id = vpm->id; | 205 | X509_VERIFY_PARAM_ID *id = vpm->id; |
209 | X509 *x = ctx->cert; | 206 | X509 *x = ctx->cert; |
210 | 207 | ||
211 | if (id->poisoned) | ||
212 | if (!check_id_error(ctx, X509_V_ERR_INVALID_CALL)) | ||
213 | return 0; | ||
214 | |||
215 | if (id->hosts && check_hosts(x, id) <= 0) { | 208 | if (id->hosts && check_hosts(x, id) <= 0) { |
216 | if (!check_id_error(ctx, X509_V_ERR_HOSTNAME_MISMATCH)) | 209 | if (!check_id_error(ctx, X509_V_ERR_HOSTNAME_MISMATCH)) |
217 | return 0; | 210 | return 0; |
@@ -253,6 +246,15 @@ X509_verify_cert(X509_STORE_CTX *ctx) | |||
253 | ctx->error = X509_V_ERR_INVALID_CALL; | 246 | ctx->error = X509_V_ERR_INVALID_CALL; |
254 | return -1; | 247 | return -1; |
255 | } | 248 | } |
249 | if (ctx->param->id->poisoned) { | ||
250 | /* | ||
251 | * This X509_STORE_CTX had failures setting | ||
252 | * up verify parameters. We can not use it. | ||
253 | */ | ||
254 | X509error(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | ||
255 | ctx->error = X509_V_ERR_INVALID_CALL; | ||
256 | return -1; | ||
257 | } | ||
256 | if (ctx->error != X509_V_ERR_INVALID_CALL) { | 258 | if (ctx->error != X509_V_ERR_INVALID_CALL) { |
257 | /* | 259 | /* |
258 | * This X509_STORE_CTX has not been properly initialized. | 260 | * This X509_STORE_CTX has not been properly initialized. |