summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2024-03-02 11:35:09 +0000
committertb <>2024-03-02 11:35:09 +0000
commit0e0cb92067894b44c4616c0ca3622a555adf404c (patch)
treef4dbee84a23329e7ce15123ae094c7df149b039e /src/lib
parent2ebc8c867d962934d7ca505b4686cb67359ed825 (diff)
downloadopenbsd-0e0cb92067894b44c4616c0ca3622a555adf404c.tar.gz
openbsd-0e0cb92067894b44c4616c0ca3622a555adf404c.tar.bz2
openbsd-0e0cb92067894b44c4616c0ca3622a555adf404c.zip
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
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/crypto.h10
-rw-r--r--src/lib/libcrypto/malloc-wrapper.c8
2 files changed, 8 insertions, 10 deletions
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index 67c5820500..382d40a350 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto.h,v 1.67 2024/03/02 11:32:31 tb Exp $ */ 1/* $OpenBSD: crypto.h,v 1.68 2024/03/02 11:35:09 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -273,9 +273,9 @@ DECLARE_STACK_OF(void)
273 273
274int CRYPTO_mem_ctrl(int mode); 274int CRYPTO_mem_ctrl(int mode);
275 275
276#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,NULL,0) 276#define OPENSSL_malloc(num) CRYPTO_malloc((num),NULL,0)
277#define OPENSSL_strdup(str) CRYPTO_strdup((str),NULL,0) 277#define OPENSSL_strdup(str) CRYPTO_strdup((str),NULL,0)
278#define OPENSSL_free(addr) CRYPTO_free(addr) 278#define OPENSSL_free(addr) CRYPTO_free((addr),NULL,0)
279#endif 279#endif
280 280
281const char *OpenSSL_version(int type); 281const char *OpenSSL_version(int type);
@@ -364,9 +364,9 @@ int CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int),
364 void *(*r)(void *, size_t, const char *, int), void (*f)(void *)); 364 void *(*r)(void *, size_t, const char *, int), void (*f)(void *));
365 365
366#ifndef LIBRESSL_INTERNAL 366#ifndef LIBRESSL_INTERNAL
367void *CRYPTO_malloc(int num, const char *file, int line); 367void *CRYPTO_malloc(size_t num, const char *file, int line);
368char *CRYPTO_strdup(const char *str, const char *file, int line); 368char *CRYPTO_strdup(const char *str, const char *file, int line);
369void CRYPTO_free(void *ptr); 369void CRYPTO_free(void *ptr, const char *file, int line);
370#endif 370#endif
371 371
372#ifndef LIBRESSL_INTERNAL 372#ifndef LIBRESSL_INTERNAL
diff --git a/src/lib/libcrypto/malloc-wrapper.c b/src/lib/libcrypto/malloc-wrapper.c
index e13cc23373..fb42169b2f 100644
--- a/src/lib/libcrypto/malloc-wrapper.c
+++ b/src/lib/libcrypto/malloc-wrapper.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc-wrapper.c,v 1.9 2024/03/02 11:28:46 tb Exp $ */ 1/* $OpenBSD: malloc-wrapper.c,v 1.10 2024/03/02 11:35:09 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Bob Beck 3 * Copyright (c) 2014 Bob Beck
4 * 4 *
@@ -37,10 +37,8 @@ CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int),
37LCRYPTO_ALIAS(CRYPTO_set_mem_ex_functions); 37LCRYPTO_ALIAS(CRYPTO_set_mem_ex_functions);
38 38
39void * 39void *
40CRYPTO_malloc(int num, const char *file, int line) 40CRYPTO_malloc(size_t num, const char *file, int line)
41{ 41{
42 if (num <= 0)
43 return NULL;
44 return malloc(num); 42 return malloc(num);
45} 43}
46 44
@@ -51,7 +49,7 @@ CRYPTO_strdup(const char *str, const char *file, int line)
51} 49}
52 50
53void 51void
54CRYPTO_free(void *ptr) 52CRYPTO_free(void *ptr, const char *file, int line)
55{ 53{
56 free(ptr); 54 free(ptr);
57} 55}