Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use OPENSSL_free for OpenSSL allocations to avoid crash #41

Merged
merged 1 commit into from Sep 21, 2023

Conversation

skmcgrail
Copy link
Contributor

@skmcgrail skmcgrail commented Jun 2, 2023

Description

OpenSSL functions, like X509_NAME_oneline, returns pointers to memory allocations created using OPENSSL_malloc. The documentation for OpenSSL hints that such allocations should be freed using OPENSSL_free and not the standard free. For example:

OPENSSL_strdup(), OPENSSL_strndup() and OPENSSL_memdup() are like the equivalent C functions, except that memory is allocated by calling the OPENSSL_malloc() and should be released by calling OPENSSL_free().

In OpenSSL forks like BoringSSL and AWS-LC, OPENSSL_malloc returns a pointer that can't be freed by free, and when attempted will cause a panic:

#0  0x0000ffff8e367c9c in free () from /lib64/libc.so.6
#1  0x000000000043a168 in tls_free_conninfo (conninfo=0x272fbea0) at lib/usual/tls/tls_conninfo.c:193
#2  0x0000000000436dc4 in tls_reset (ctx=ctx@entry=0x272f4bb0) at lib/usual/tls/tls.c:519
#3  0x0000000000436e58 in tls_free (ctx=0x272f4bb0) at lib/usual/tls/tls.c:494

This PR updates tls_free_conninfo to properly free the issuer and subject information in order to improve compatibility with the OpenSSL forks.

@JelteF JelteF merged commit 490d96e into libusual:master Sep 21, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants