Skip to content

Commit 5081638

Browse files
Free allocated stack of found exts
1 parent 3175080 commit 5081638

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crypto/x509/x509_vfy.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ static int check_custom_critical_extensions(X509_STORE_CTX *ctx, X509 *x) {
598598
if (OBJ_cmp(ext->object, known_ext) == 0) {
599599
found = 1;
600600
if (!sk_ASN1_OBJECT_push(found_exts, known_ext)) {
601+
sk_ASN1_OBJECT_pop_free(found_exts, ASN1_OBJECT_free);
601602
return 0;
602603
}
603604
break;
@@ -606,6 +607,7 @@ static int check_custom_critical_extensions(X509_STORE_CTX *ctx, X509 *x) {
606607

607608
if (!found) {
608609
// If any critical extension isn't in our known list, return early.
610+
sk_ASN1_OBJECT_pop_free(found_exts, ASN1_OBJECT_free);
609611
return 0;
610612
}
611613
}
@@ -615,13 +617,15 @@ static int check_custom_critical_extensions(X509_STORE_CTX *ctx, X509 *x) {
615617
// If we get here, all unknown critical extensions in |x| were
616618
// properly handled and we pass the ones that were found to the caller.
617619
if (!ctx->verify_custom_crit_oids(ctx, x, found_exts)) {
620+
sk_ASN1_OBJECT_pop_free(found_exts, ASN1_OBJECT_free);
618621
return 0;
619622
}
620623

621624
// Remove the |EXFLAG_CRITICAL| flag from |x|, now that all unknown
622625
// critical extensions have been handled.
623626
x->ex_flags &= ~EXFLAG_CRITICAL;
624627

628+
sk_ASN1_OBJECT_pop_free(found_exts, ASN1_OBJECT_free);
625629
return 1;
626630
}
627631

0 commit comments

Comments
 (0)