Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use OPENSSL_free for OpenSSL allocations to avoid crash (libusual#41)
OpenSSL functions, like `X509_NAME_oneline`, return 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 libusual#1 0x000000000043a168 in tls_free_conninfo (conninfo=0x272fbea0) at lib/usual/tls/tls_conninfo.c:193 libusual#2 0x0000000000436dc4 in tls_reset (ctx=ctx@entry=0x272f4bb0) at lib/usual/tls/tls.c:519 libusual#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. In passing it also defines some stubs for functions that are missing in AWS-LC, due to AWS-LS not supporting OCSP. We do this in the same way as we already do for BoringSSL.
- Loading branch information