summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiod <>2014-07-12 14:58:32 +0000
committermiod <>2014-07-12 14:58:32 +0000
commitbe62ec7782f11e6015eaa953859a4ea240c4ed8b (patch)
treeb1d347ffdd3c76df9af253450a9dbb01eb287231
parent253f6c49c29fbea00aba20d557aba42e338399ba (diff)
downloadopenbsd-be62ec7782f11e6015eaa953859a4ea240c4ed8b.tar.gz
openbsd-be62ec7782f11e6015eaa953859a4ea240c4ed8b.tar.bz2
openbsd-be62ec7782f11e6015eaa953859a4ea240c4ed8b.zip
Principle of least surprise: make CMAC_CTX_free(), OCSP_REQ_CTX_free() and
X509_STORE_CTX_free() accept NULL pointers as input without dereferencing them, like all the other well-behaved *_CTX_free() functions do.
-rw-r--r--src/lib/libcrypto/cmac/cmac.c5
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_ht.c5
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.c5
-rw-r--r--src/lib/libssl/src/crypto/cmac/cmac.c5
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_ht.c5
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_vfy.c5
6 files changed, 24 insertions, 6 deletions
diff --git a/src/lib/libcrypto/cmac/cmac.c b/src/lib/libcrypto/cmac/cmac.c
index baba674ec1..18635b942a 100644
--- a/src/lib/libcrypto/cmac/cmac.c
+++ b/src/lib/libcrypto/cmac/cmac.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cmac.c,v 1.8 2014/07/11 08:44:48 jsing Exp $ */ 1/* $OpenBSD: cmac.c,v 1.9 2014/07/12 14:58:32 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -123,6 +123,9 @@ CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx)
123void 123void
124CMAC_CTX_free(CMAC_CTX *ctx) 124CMAC_CTX_free(CMAC_CTX *ctx)
125{ 125{
126 if (ctx == NULL)
127 return;
128
126 CMAC_CTX_cleanup(ctx); 129 CMAC_CTX_cleanup(ctx);
127 free(ctx); 130 free(ctx);
128} 131}
diff --git a/src/lib/libcrypto/ocsp/ocsp_ht.c b/src/lib/libcrypto/ocsp/ocsp_ht.c
index bc3c957b0c..c895e9df4d 100644
--- a/src/lib/libcrypto/ocsp/ocsp_ht.c
+++ b/src/lib/libcrypto/ocsp/ocsp_ht.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp_ht.c,v 1.19 2014/06/12 15:49:30 deraadt Exp $ */ 1/* $OpenBSD: ocsp_ht.c,v 1.20 2014/07/12 14:58:32 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -108,6 +108,9 @@ static int parse_http_line1(char *line);
108void 108void
109OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx) 109OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx)
110{ 110{
111 if (rctx == NULL)
112 return;
113
111 if (rctx->mem) 114 if (rctx->mem)
112 BIO_free(rctx->mem); 115 BIO_free(rctx->mem);
113 free(rctx->iobuf); 116 free(rctx->iobuf);
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c
index 9d7a7d1228..d894facd47 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.34 2014/07/11 12:52:41 miod Exp $ */ 1/* $OpenBSD: x509_vfy.c,v 1.35 2014/07/12 14:58:32 miod 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 *
@@ -1979,6 +1979,9 @@ X509_STORE_CTX_new(void)
1979void 1979void
1980X509_STORE_CTX_free(X509_STORE_CTX *ctx) 1980X509_STORE_CTX_free(X509_STORE_CTX *ctx)
1981{ 1981{
1982 if (ctx == NULL)
1983 return;
1984
1982 X509_STORE_CTX_cleanup(ctx); 1985 X509_STORE_CTX_cleanup(ctx);
1983 free(ctx); 1986 free(ctx);
1984} 1987}
diff --git a/src/lib/libssl/src/crypto/cmac/cmac.c b/src/lib/libssl/src/crypto/cmac/cmac.c
index baba674ec1..18635b942a 100644
--- a/src/lib/libssl/src/crypto/cmac/cmac.c
+++ b/src/lib/libssl/src/crypto/cmac/cmac.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cmac.c,v 1.8 2014/07/11 08:44:48 jsing Exp $ */ 1/* $OpenBSD: cmac.c,v 1.9 2014/07/12 14:58:32 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -123,6 +123,9 @@ CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx)
123void 123void
124CMAC_CTX_free(CMAC_CTX *ctx) 124CMAC_CTX_free(CMAC_CTX *ctx)
125{ 125{
126 if (ctx == NULL)
127 return;
128
126 CMAC_CTX_cleanup(ctx); 129 CMAC_CTX_cleanup(ctx);
127 free(ctx); 130 free(ctx);
128} 131}
diff --git a/src/lib/libssl/src/crypto/ocsp/ocsp_ht.c b/src/lib/libssl/src/crypto/ocsp/ocsp_ht.c
index bc3c957b0c..c895e9df4d 100644
--- a/src/lib/libssl/src/crypto/ocsp/ocsp_ht.c
+++ b/src/lib/libssl/src/crypto/ocsp/ocsp_ht.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp_ht.c,v 1.19 2014/06/12 15:49:30 deraadt Exp $ */ 1/* $OpenBSD: ocsp_ht.c,v 1.20 2014/07/12 14:58:32 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -108,6 +108,9 @@ static int parse_http_line1(char *line);
108void 108void
109OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx) 109OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx)
110{ 110{
111 if (rctx == NULL)
112 return;
113
111 if (rctx->mem) 114 if (rctx->mem)
112 BIO_free(rctx->mem); 115 BIO_free(rctx->mem);
113 free(rctx->iobuf); 116 free(rctx->iobuf);
diff --git a/src/lib/libssl/src/crypto/x509/x509_vfy.c b/src/lib/libssl/src/crypto/x509/x509_vfy.c
index 9d7a7d1228..d894facd47 100644
--- a/src/lib/libssl/src/crypto/x509/x509_vfy.c
+++ b/src/lib/libssl/src/crypto/x509/x509_vfy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_vfy.c,v 1.34 2014/07/11 12:52:41 miod Exp $ */ 1/* $OpenBSD: x509_vfy.c,v 1.35 2014/07/12 14:58:32 miod 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 *
@@ -1979,6 +1979,9 @@ X509_STORE_CTX_new(void)
1979void 1979void
1980X509_STORE_CTX_free(X509_STORE_CTX *ctx) 1980X509_STORE_CTX_free(X509_STORE_CTX *ctx)
1981{ 1981{
1982 if (ctx == NULL)
1983 return;
1984
1982 X509_STORE_CTX_cleanup(ctx); 1985 X509_STORE_CTX_cleanup(ctx);
1983 free(ctx); 1986 free(ctx);
1984} 1987}