diff options
author | schwarze <> | 2021-11-19 07:49:27 +0000 |
---|---|---|
committer | schwarze <> | 2021-11-19 07:49:27 +0000 |
commit | 37e49cc98d663f90282949c6b5c281cf7f838399 (patch) | |
tree | 0cd45211abbe4b0ded785aa363bb23d83b34b6c9 /src/lib | |
parent | 3311f461e9cad69855a601eb8afc8b5468e0b18c (diff) | |
download | openbsd-37e49cc98d663f90282949c6b5c281cf7f838399.tar.gz openbsd-37e49cc98d663f90282949c6b5c281cf7f838399.tar.bz2 openbsd-37e49cc98d663f90282949c6b5c281cf7f838399.zip |
As long as X509_OBJECT_free_contents(3) is a public API function,
make sure it fully re-initializes the object rather than leaving
behind a stale pointer and a stale type in the object.
The old behaviour was dangerous because X509_OBJECT_get_type(3)
would then return the stale type to the user and one of
X509_OBJECT_get0_X509(3) or X509_OBJECT_get0_X509_CRL(3) would
then return the stale pointer to the user, provoking a use-after-free
bug in the application program. Having these functions return
X509_LU_NONE and NULL is better because those are the documented
return values for these functions when the object is empty.
OK tb@
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/x509/x509_lu.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lib/libcrypto/x509/x509_lu.c b/src/lib/libcrypto/x509/x509_lu.c index dd048972b4..ca96edf221 100644 --- a/src/lib/libcrypto/x509/x509_lu.c +++ b/src/lib/libcrypto/x509/x509_lu.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_lu.c,v 1.52 2021/11/07 15:52:38 tb Exp $ */ | 1 | /* $OpenBSD: x509_lu.c,v 1.53 2021/11/19 07:49:27 schwarze 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 | * |
@@ -451,6 +451,8 @@ X509_OBJECT_free_contents(X509_OBJECT *a) | |||
451 | X509_CRL_free(a->data.crl); | 451 | X509_CRL_free(a->data.crl); |
452 | break; | 452 | break; |
453 | } | 453 | } |
454 | memset(a, 0, sizeof(*a)); | ||
455 | a->type = X509_LU_NONE; | ||
454 | } | 456 | } |
455 | 457 | ||
456 | static int | 458 | static int |