From: tb Date: Sat, 2 Mar 2024 11:35:09 +0000 (+0000) Subject: Fix CRYPTO_malloc/free signatures X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=45e00fd61e4c3fb6158657a27b884f201273b43b;p=openbsd 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 --- 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); }