diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2024-03-02 11:35:10 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2024-03-02 11:35:10 +0000 |
commit | d6db6afc248958f59b1ea413af6c96e0dc7d0e05 (patch) | |
tree | 4bcacee429c8aa197070097bba0756da5d45ba24 | |
parent | f73059b94279f40cc04eafe375fafc6f2b41d6db (diff) |
Fix CRYPTO_malloc/free signatures
Importantly, the size in malloc is now a size_t instead of an int. The API
now also takes a file and line to match upstream's signature.
ok jsing
-rw-r--r-- | lib/libcrypto/crypto.h | 10 | ||||
-rw-r--r-- | lib/libcrypto/malloc-wrapper.c | 8 |
2 files changed, 8 insertions, 10 deletions
diff --git a/lib/libcrypto/crypto.h b/lib/libcrypto/crypto.h index 67c5820500f..382d40a3505 100644 --- a/lib/libcrypto/crypto.h +++ b/lib/libcrypto/crypto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.h,v 1.67 2024/03/02 11:32:31 tb Exp $ */ +/* $OpenBSD: crypto.h,v 1.68 2024/03/02 11:35:09 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * @@ -273,9 +273,9 @@ DECLARE_STACK_OF(void) int CRYPTO_mem_ctrl(int mode); -#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,NULL,0) +#define OPENSSL_malloc(num) CRYPTO_malloc((num),NULL,0) #define OPENSSL_strdup(str) CRYPTO_strdup((str),NULL,0) -#define OPENSSL_free(addr) CRYPTO_free(addr) +#define OPENSSL_free(addr) CRYPTO_free((addr),NULL,0) #endif const char *OpenSSL_version(int type); @@ -364,9 +364,9 @@ int CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int), void *(*r)(void *, size_t, const char *, int), void (*f)(void *)); #ifndef LIBRESSL_INTERNAL -void *CRYPTO_malloc(int num, const char *file, int line); +void *CRYPTO_malloc(size_t num, const char *file, int line); char *CRYPTO_strdup(const char *str, const char *file, int line); -void CRYPTO_free(void *ptr); +void CRYPTO_free(void *ptr, const char *file, int line); #endif #ifndef LIBRESSL_INTERNAL diff --git a/lib/libcrypto/malloc-wrapper.c b/lib/libcrypto/malloc-wrapper.c index e13cc233739..fb42169b2fa 100644 --- a/lib/libcrypto/malloc-wrapper.c +++ b/lib/libcrypto/malloc-wrapper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc-wrapper.c,v 1.9 2024/03/02 11:28:46 tb Exp $ */ +/* $OpenBSD: malloc-wrapper.c,v 1.10 2024/03/02 11:35:09 tb Exp $ */ /* * Copyright (c) 2014 Bob Beck * @@ -37,10 +37,8 @@ CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int), LCRYPTO_ALIAS(CRYPTO_set_mem_ex_functions); void * -CRYPTO_malloc(int num, const char *file, int line) +CRYPTO_malloc(size_t num, const char *file, int line) { - if (num <= 0) - return NULL; return malloc(num); } @@ -51,7 +49,7 @@ CRYPTO_strdup(const char *str, const char *file, int line) } void -CRYPTO_free(void *ptr) +CRYPTO_free(void *ptr, const char *file, int line) { free(ptr); } |