Skip to content

librcrypto does not alwasys arm OPENSSL_cleanup() atexit hander #1734

@Sashan

Description

@Sashan

@mbroz point me to old issue #16516 There is a simple demonstration program I'm copying here:

#include <stdio.h>
#include <openssl/crypto.h>
#include <openssl/provider.h>

static OSSL_PROVIDER *ossl_legacy = NULL;
static OSSL_LIB_CTX  *ossl_ctx = NULL;

int main(int argc, char *argv[])
{
	printf("OpenSSL (%s)\n", OpenSSL_version(OPENSSL_VERSION));

	ossl_ctx = OSSL_LIB_CTX_new();
	if (!ossl_ctx) {
		printf("CTX fail.\n");
		return 1;
	}

	ossl_legacy  = OSSL_PROVIDER_load(ossl_ctx, "legacy");
	if (!ossl_legacy)
		printf("Cannot load legacy provider.\n");
	printf("App EXIT\n");

	OSSL_PROVIDER_unload(ossl_legacy);
	OSSL_LIB_CTX_free(ossl_ctx);

	return 0;
}

The program above leaks memory because libcrypto does not arm OPENSSL_cleanup() handler in that case. I'm using this ticket as a reminder that we should arm always arm cleanup atexit handler when running under valgrind.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Pre-Refinement

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions