diff options
author | tb <> | 2020-09-20 19:13:06 +0000 |
---|---|---|
committer | tb <> | 2020-09-20 19:13:06 +0000 |
commit | bbbce94f43affd45f1dfd72c669cb061c1cc01e5 (patch) | |
tree | d7ad4f2bd91d34ae759edabe90d77b3298da4c56 | |
parent | bef75f92760574525922f5ff9c66adf59413432e (diff) | |
download | openbsd-bbbce94f43affd45f1dfd72c669cb061c1cc01e5.tar.gz openbsd-bbbce94f43affd45f1dfd72c669cb061c1cc01e5.tar.bz2 openbsd-bbbce94f43affd45f1dfd72c669cb061c1cc01e5.zip |
Avoid memleak caused by shadowing
The outer scope in x509_constraints_extract_names() contains a vname
variable which will be freed on error, but an inner scope contains
another vname that won't be freed, e.g., if x509_constraints_names_add
fails.
Found by llvm scan-build.
ok beck
-rw-r--r-- | src/lib/libcrypto/x509/x509_constraints.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/libcrypto/x509/x509_constraints.c b/src/lib/libcrypto/x509/x509_constraints.c index 34795c0796..f50a55c6ac 100644 --- a/src/lib/libcrypto/x509/x509_constraints.c +++ b/src/lib/libcrypto/x509/x509_constraints.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_constraints.c,v 1.7 2020/09/20 18:32:33 tb Exp $ */ | 1 | /* $OpenBSD: x509_constraints.c,v 1.8 2020/09/20 19:13:06 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> |
4 | * | 4 | * |
@@ -769,9 +769,12 @@ x509_constraints_extract_names(struct x509_constraints_names *names, | |||
769 | } | 769 | } |
770 | subject_name = X509_get_subject_name(cert); | 770 | subject_name = X509_get_subject_name(cert); |
771 | if (X509_NAME_entry_count(subject_name) > 0) { | 771 | if (X509_NAME_entry_count(subject_name) > 0) { |
772 | struct x509_constraints_name *vname = NULL; | ||
773 | X509_NAME_ENTRY *email; | 772 | X509_NAME_ENTRY *email; |
774 | X509_NAME_ENTRY *cn; | 773 | X509_NAME_ENTRY *cn; |
774 | |||
775 | x509_constraints_name_free(vname); | ||
776 | vname = NULL; | ||
777 | |||
775 | /* | 778 | /* |
776 | * This cert has a non-empty subject, so we must add | 779 | * This cert has a non-empty subject, so we must add |
777 | * the subject as a dirname to be compared against | 780 | * the subject as a dirname to be compared against |