Skip to content

Commit eeb75c9

Browse files
Fix native leak in CryptoNative_GetX509nameInfo
The implementation was previously only freeing the STACK_OF, but not the contents of the stack. This change fixes not freeing the individual GENERAL_NAME items. Co-authored-by: Kevin Jones <[email protected]>
1 parent 0e7d0c9 commit eeb75c9

File tree

1 file changed

+4
-4
lines changed
  • src/libraries/Native/Unix/System.Security.Cryptography.Native

1 file changed

+4
-4
lines changed

src/libraries/Native/Unix/System.Security.Cryptography.Native/openssl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,8 @@ BIO* CryptoNative_GetX509NameInfo(X509* x509, int32_t nameType, int32_t forIssue
593593
break;
594594
}
595595

596-
STACK_OF(GENERAL_NAME)* altNames = (STACK_OF(GENERAL_NAME)*)(
597-
X509_get_ext_d2i(x509, forIssuer ? NID_issuer_alt_name : NID_subject_alt_name, NULL, NULL));
596+
GENERAL_NAMES* altNames = (GENERAL_NAMES*)
597+
X509_get_ext_d2i(x509, forIssuer ? NID_issuer_alt_name : NID_subject_alt_name, NULL, NULL);
598598

599599
if (altNames)
600600
{
@@ -652,13 +652,13 @@ BIO* CryptoNative_GetX509NameInfo(X509* x509, int32_t nameType, int32_t forIssue
652652
{
653653
BIO* b = BIO_new(BIO_s_mem());
654654
ASN1_STRING_print_ex(b, str, ASN1_STRFLGS_UTF8_CONVERT);
655-
sk_GENERAL_NAME_free(altNames);
655+
GENERAL_NAMES_free(altNames);
656656
return b;
657657
}
658658
}
659659
}
660660

661-
sk_GENERAL_NAME_free(altNames);
661+
GENERAL_NAMES_free(altNames);
662662
}
663663
}
664664

0 commit comments

Comments
 (0)