diff options
author | miod <> | 2015-07-19 05:42:55 +0000 |
---|---|---|
committer | miod <> | 2015-07-19 05:42:55 +0000 |
commit | e2fdff6ec8caaf7f2ab38d837f605b9724bc5279 (patch) | |
tree | 50a9d501470e88dcc8bed9bf14a1c0a28f099e3b /src/lib/libcrypto/ts/ts_rsp_verify.c | |
parent | bac793e50611d30da720c67ccfadbbf60bb3e8aa (diff) | |
download | openbsd-e2fdff6ec8caaf7f2ab38d837f605b9724bc5279.tar.gz openbsd-e2fdff6ec8caaf7f2ab38d837f605b9724bc5279.tar.bz2 openbsd-e2fdff6ec8caaf7f2ab38d837f605b9724bc5279.zip |
Now that it is safe to invoke X509_STORE_CTX_cleanup() if X509_STORE_CTX_init()
fails, check its return value and correctly mop up after ourselves.
ok beck@ doug@
Diffstat (limited to 'src/lib/libcrypto/ts/ts_rsp_verify.c')
-rw-r--r-- | src/lib/libcrypto/ts/ts_rsp_verify.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/libcrypto/ts/ts_rsp_verify.c b/src/lib/libcrypto/ts/ts_rsp_verify.c index 25aa31ee4d..797877011c 100644 --- a/src/lib/libcrypto/ts/ts_rsp_verify.c +++ b/src/lib/libcrypto/ts/ts_rsp_verify.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ts_rsp_verify.c,v 1.14 2015/07/19 02:43:24 miod Exp $ */ | 1 | /* $OpenBSD: ts_rsp_verify.c,v 1.15 2015/07/19 05:42:55 miod Exp $ */ |
2 | /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL | 2 | /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL |
3 | * project 2002. | 3 | * project 2002. |
4 | */ | 4 | */ |
@@ -234,26 +234,32 @@ static int | |||
234 | TS_verify_cert(X509_STORE *store, STACK_OF(X509) *untrusted, X509 *signer, | 234 | TS_verify_cert(X509_STORE *store, STACK_OF(X509) *untrusted, X509 *signer, |
235 | STACK_OF(X509) **chain) | 235 | STACK_OF(X509) **chain) |
236 | { | 236 | { |
237 | X509_STORE_CTX cert_ctx; | 237 | X509_STORE_CTX cert_ctx; |
238 | int i; | 238 | int i; |
239 | int ret = 1; | 239 | int ret = 0; |
240 | 240 | ||
241 | /* chain is an out argument. */ | 241 | /* chain is an out argument. */ |
242 | *chain = NULL; | 242 | *chain = NULL; |
243 | X509_STORE_CTX_init(&cert_ctx, store, signer, untrusted); | 243 | if (X509_STORE_CTX_init(&cert_ctx, store, signer, untrusted) == 0) { |
244 | TSerr(TS_F_TS_VERIFY_CERT, ERR_R_X509_LIB); | ||
245 | goto err; | ||
246 | } | ||
244 | X509_STORE_CTX_set_purpose(&cert_ctx, X509_PURPOSE_TIMESTAMP_SIGN); | 247 | X509_STORE_CTX_set_purpose(&cert_ctx, X509_PURPOSE_TIMESTAMP_SIGN); |
245 | i = X509_verify_cert(&cert_ctx); | 248 | i = X509_verify_cert(&cert_ctx); |
246 | if (i <= 0) { | 249 | if (i <= 0) { |
247 | int j = X509_STORE_CTX_get_error(&cert_ctx); | 250 | int j = X509_STORE_CTX_get_error(&cert_ctx); |
251 | |||
248 | TSerr(TS_F_TS_VERIFY_CERT, TS_R_CERTIFICATE_VERIFY_ERROR); | 252 | TSerr(TS_F_TS_VERIFY_CERT, TS_R_CERTIFICATE_VERIFY_ERROR); |
249 | ERR_asprintf_error_data("Verify error:%s", | 253 | ERR_asprintf_error_data("Verify error:%s", |
250 | X509_verify_cert_error_string(j)); | 254 | X509_verify_cert_error_string(j)); |
251 | ret = 0; | 255 | goto err; |
252 | } else { | 256 | } else { |
253 | /* Get a copy of the certificate chain. */ | 257 | /* Get a copy of the certificate chain. */ |
254 | *chain = X509_STORE_CTX_get1_chain(&cert_ctx); | 258 | *chain = X509_STORE_CTX_get1_chain(&cert_ctx); |
259 | ret = 1; | ||
255 | } | 260 | } |
256 | 261 | ||
262 | err: | ||
257 | X509_STORE_CTX_cleanup(&cert_ctx); | 263 | X509_STORE_CTX_cleanup(&cert_ctx); |
258 | 264 | ||
259 | return ret; | 265 | return ret; |