summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2024-03-02 11:28:46 +0000
committertb <>2024-03-02 11:28:46 +0000
commit9b9fc000d4d482c0c3086b0e54b4c1a88c76ee34 (patch)
treef40142fa94b70538607eebd6e277749aa7bb40c1
parente26a003ae69c592a266ff1b2331d6206111a56db (diff)
downloadopenbsd-9b9fc000d4d482c0c3086b0e54b4c1a88c76ee34.tar.gz
openbsd-9b9fc000d4d482c0c3086b0e54b4c1a88c76ee34.tar.bz2
openbsd-9b9fc000d4d482c0c3086b0e54b4c1a88c76ee34.zip
Remove a bunch of CRYPTO memory API
This was neutered early on in the fork and has been rotting ever since. Some parts of the API are still used, but it's easier to clean up when most of the mess is gone. ok jsing
-rw-r--r--src/lib/libcrypto/Symbols.list24
-rw-r--r--src/lib/libcrypto/Symbols.namespace14
-rw-r--r--src/lib/libcrypto/crypto.h80
-rw-r--r--src/lib/libcrypto/hidden/openssl/crypto.h22
-rw-r--r--src/lib/libcrypto/malloc-wrapper.c150
-rw-r--r--src/lib/libcrypto/mem_dbg.c68
6 files changed, 4 insertions, 354 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list
index 5a1fe7be48..26170084e5 100644
--- a/src/lib/libcrypto/Symbols.list
+++ b/src/lib/libcrypto/Symbols.list
@@ -649,16 +649,10 @@ CRYPTO_chacha_20
649CRYPTO_cleanup_all_ex_data 649CRYPTO_cleanup_all_ex_data
650CRYPTO_ctr128_encrypt 650CRYPTO_ctr128_encrypt
651CRYPTO_ctr128_encrypt_ctr32 651CRYPTO_ctr128_encrypt_ctr32
652CRYPTO_dbg_free
653CRYPTO_dbg_get_options
654CRYPTO_dbg_malloc
655CRYPTO_dbg_realloc
656CRYPTO_dbg_set_options
657CRYPTO_destroy_dynlockid 652CRYPTO_destroy_dynlockid
658CRYPTO_dup_ex_data 653CRYPTO_dup_ex_data
659CRYPTO_free 654CRYPTO_free
660CRYPTO_free_ex_data 655CRYPTO_free_ex_data
661CRYPTO_free_locked
662CRYPTO_gcm128_aad 656CRYPTO_gcm128_aad
663CRYPTO_gcm128_decrypt 657CRYPTO_gcm128_decrypt
664CRYPTO_gcm128_decrypt_ctr32 658CRYPTO_gcm128_decrypt_ctr32
@@ -679,24 +673,13 @@ CRYPTO_get_ex_data
679CRYPTO_get_ex_new_index 673CRYPTO_get_ex_new_index
680CRYPTO_get_id_callback 674CRYPTO_get_id_callback
681CRYPTO_get_lock_name 675CRYPTO_get_lock_name
682CRYPTO_get_locked_mem_ex_functions
683CRYPTO_get_locked_mem_functions
684CRYPTO_get_locking_callback 676CRYPTO_get_locking_callback
685CRYPTO_get_mem_debug_functions
686CRYPTO_get_mem_debug_options
687CRYPTO_get_mem_ex_functions
688CRYPTO_get_mem_functions
689CRYPTO_get_new_dynlockid 677CRYPTO_get_new_dynlockid
690CRYPTO_get_new_lockid 678CRYPTO_get_new_lockid
691CRYPTO_hchacha_20 679CRYPTO_hchacha_20
692CRYPTO_is_mem_check_on
693CRYPTO_lock 680CRYPTO_lock
694CRYPTO_malloc 681CRYPTO_malloc
695CRYPTO_malloc_locked
696CRYPTO_mem_ctrl 682CRYPTO_mem_ctrl
697CRYPTO_mem_leaks
698CRYPTO_mem_leaks_cb
699CRYPTO_mem_leaks_fp
700CRYPTO_memcmp 683CRYPTO_memcmp
701CRYPTO_new_ex_data 684CRYPTO_new_ex_data
702CRYPTO_num_locks 685CRYPTO_num_locks
@@ -706,9 +689,6 @@ CRYPTO_poly1305_init
706CRYPTO_poly1305_update 689CRYPTO_poly1305_update
707CRYPTO_pop_info 690CRYPTO_pop_info
708CRYPTO_push_info_ 691CRYPTO_push_info_
709CRYPTO_realloc
710CRYPTO_realloc_clean
711CRYPTO_remalloc
712CRYPTO_remove_all_info 692CRYPTO_remove_all_info
713CRYPTO_set_add_lock_callback 693CRYPTO_set_add_lock_callback
714CRYPTO_set_dynlock_create_callback 694CRYPTO_set_dynlock_create_callback
@@ -716,11 +696,7 @@ CRYPTO_set_dynlock_destroy_callback
716CRYPTO_set_dynlock_lock_callback 696CRYPTO_set_dynlock_lock_callback
717CRYPTO_set_ex_data 697CRYPTO_set_ex_data
718CRYPTO_set_id_callback 698CRYPTO_set_id_callback
719CRYPTO_set_locked_mem_ex_functions
720CRYPTO_set_locked_mem_functions
721CRYPTO_set_locking_callback 699CRYPTO_set_locking_callback
722CRYPTO_set_mem_debug_functions
723CRYPTO_set_mem_debug_options
724CRYPTO_set_mem_ex_functions 700CRYPTO_set_mem_ex_functions
725CRYPTO_set_mem_functions 701CRYPTO_set_mem_functions
726CRYPTO_strdup 702CRYPTO_strdup
diff --git a/src/lib/libcrypto/Symbols.namespace b/src/lib/libcrypto/Symbols.namespace
index b673042f02..ff6e6492e2 100644
--- a/src/lib/libcrypto/Symbols.namespace
+++ b/src/lib/libcrypto/Symbols.namespace
@@ -1864,26 +1864,12 @@ _libre_CRYPTO_set_locked_mem_functions
1864_libre_CRYPTO_set_mem_ex_functions 1864_libre_CRYPTO_set_mem_ex_functions
1865_libre_CRYPTO_set_locked_mem_ex_functions 1865_libre_CRYPTO_set_locked_mem_ex_functions
1866_libre_CRYPTO_set_mem_debug_functions 1866_libre_CRYPTO_set_mem_debug_functions
1867_libre_CRYPTO_get_mem_functions
1868_libre_CRYPTO_get_locked_mem_functions
1869_libre_CRYPTO_get_mem_ex_functions
1870_libre_CRYPTO_get_locked_mem_ex_functions
1871_libre_CRYPTO_get_mem_debug_functions
1872_libre_CRYPTO_realloc_clean 1867_libre_CRYPTO_realloc_clean
1873_libre_CRYPTO_remalloc 1868_libre_CRYPTO_remalloc
1874_libre_CRYPTO_set_mem_debug_options 1869_libre_CRYPTO_set_mem_debug_options
1875_libre_CRYPTO_get_mem_debug_options
1876_libre_CRYPTO_push_info_ 1870_libre_CRYPTO_push_info_
1877_libre_CRYPTO_pop_info 1871_libre_CRYPTO_pop_info
1878_libre_CRYPTO_remove_all_info 1872_libre_CRYPTO_remove_all_info
1879_libre_CRYPTO_dbg_malloc
1880_libre_CRYPTO_dbg_realloc
1881_libre_CRYPTO_dbg_free
1882_libre_CRYPTO_dbg_set_options
1883_libre_CRYPTO_dbg_get_options
1884_libre_CRYPTO_mem_leaks_fp
1885_libre_CRYPTO_mem_leaks
1886_libre_CRYPTO_mem_leaks_cb
1887_libre_OpenSSLDie 1873_libre_OpenSSLDie
1888_libre_OPENSSL_cpu_caps 1874_libre_OPENSSL_cpu_caps
1889_libre_OPENSSL_init_crypto 1875_libre_OPENSSL_init_crypto
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index f37ec3106d..19732ced32 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto.h,v 1.65 2024/03/02 09:15:03 tb Exp $ */ 1/* $OpenBSD: crypto.h,v 1.66 2024/03/02 11:28:46 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 *
@@ -272,26 +272,10 @@ DECLARE_STACK_OF(void)
272#endif 272#endif
273 273
274int CRYPTO_mem_ctrl(int mode); 274int CRYPTO_mem_ctrl(int mode);
275int CRYPTO_is_mem_check_on(void);
276
277/* for applications */
278#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
279#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)
280 275
281#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,NULL,0) 276#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,NULL,0)
282#define OPENSSL_strdup(str) CRYPTO_strdup((str),NULL,0) 277#define OPENSSL_strdup(str) CRYPTO_strdup((str),NULL,0)
283#define OPENSSL_realloc(addr,num) \
284 CRYPTO_realloc((char *)addr,(int)num,NULL,0)
285#define OPENSSL_realloc_clean(addr,old_num,num) \
286 CRYPTO_realloc_clean(addr,old_num,num,NULL,0)
287#define OPENSSL_remalloc(addr,num) \
288 CRYPTO_remalloc((char **)addr,(int)num,NULL,0)
289#define OPENSSL_freeFunc CRYPTO_free
290#define OPENSSL_free(addr) CRYPTO_free(addr) 278#define OPENSSL_free(addr) CRYPTO_free(addr)
291
292#define OPENSSL_malloc_locked(num) \
293 CRYPTO_malloc_locked((int)num,NULL,0)
294#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
295#endif 279#endif
296 280
297const char *OpenSSL_version(int type); 281const char *OpenSSL_version(int type);
@@ -376,87 +360,25 @@ void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l
376/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- 360/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
377 * call the latter last if you need different functions */ 361 * call the latter last if you need different functions */
378int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t), void (*f)(void *)); 362int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t), void (*f)(void *));
379int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
380int CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int), 363int CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int),
381 void *(*r)(void *, size_t, const char *, int), void (*f)(void *)); 364 void *(*r)(void *, size_t, const char *, int), void (*f)(void *));
382int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int),
383 void (*free_func)(void *));
384int CRYPTO_set_mem_debug_functions(
385 void (*m)(void *, int, const char *, int, int),
386 void (*r)(void *, void *, int, const char *, int, int),
387 void (*f)(void *, int), void (*so)(long), long (*go)(void));
388void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
389 void (**f)(void *));
390void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
391void CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int),
392 void *(**r)(void *, size_t, const char *, int), void (**f)(void *));
393void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int),
394 void (**f)(void *));
395void CRYPTO_get_mem_debug_functions(
396 void (**m)(void *, int, const char *, int, int),
397 void (**r)(void *, void *, int, const char *, int, int),
398 void (**f)(void *, int), void (**so)(long), long (**go)(void));
399 365
400#ifndef LIBRESSL_INTERNAL 366#ifndef LIBRESSL_INTERNAL
401void *CRYPTO_malloc_locked(int num, const char *file, int line);
402void CRYPTO_free_locked(void *ptr);
403void *CRYPTO_malloc(int num, const char *file, int line); 367void *CRYPTO_malloc(int num, const char *file, int line);
404char *CRYPTO_strdup(const char *str, const char *file, int line); 368char *CRYPTO_strdup(const char *str, const char *file, int line);
405void CRYPTO_free(void *ptr); 369void CRYPTO_free(void *ptr);
406void *CRYPTO_realloc(void *addr, int num, const char *file, int line);
407#endif 370#endif
408 371
409void *CRYPTO_realloc_clean(void *addr, int old_num, int num,
410 const char *file, int line);
411void *CRYPTO_remalloc(void *addr, int num, const char *file, int line);
412
413#ifndef LIBRESSL_INTERNAL 372#ifndef LIBRESSL_INTERNAL
414void OPENSSL_cleanse(void *ptr, size_t len); 373void OPENSSL_cleanse(void *ptr, size_t len);
415#endif 374#endif
416 375
417void CRYPTO_set_mem_debug_options(long bits);
418long CRYPTO_get_mem_debug_options(void);
419
420#define CRYPTO_push_info(info) \ 376#define CRYPTO_push_info(info) \
421 CRYPTO_push_info_(info, NULL, 0); 377 CRYPTO_push_info_(info, NULL, 0);
422int CRYPTO_push_info_(const char *info, const char *file, int line); 378int CRYPTO_push_info_(const char *info, const char *file, int line);
423int CRYPTO_pop_info(void); 379int CRYPTO_pop_info(void);
424int CRYPTO_remove_all_info(void); 380int CRYPTO_remove_all_info(void);
425 381
426
427/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;
428 * used as default in CRYPTO_MDEBUG compilations): */
429/* The last argument has the following significance:
430 *
431 * 0: called before the actual memory allocation has taken place
432 * 1: called after the actual memory allocation has taken place
433 */
434void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line, int before_p)
435 __attribute__ ((deprecated));
436void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file, int line, int before_p)
437 __attribute__ ((deprecated));
438void CRYPTO_dbg_free(void *addr, int before_p)
439 __attribute__ ((deprecated));
440/* Tell the debugging code about options. By default, the following values
441 * apply:
442 *
443 * 0: Clear all options.
444 * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option.
445 * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option.
446 * V_CRYPTO_MDEBUG_ALL (3): 1 + 2
447 */
448void CRYPTO_dbg_set_options(long bits)
449 __attribute__ ((deprecated));
450long CRYPTO_dbg_get_options(void)
451 __attribute__ ((deprecated));
452
453
454int CRYPTO_mem_leaks_fp(FILE *);
455int CRYPTO_mem_leaks(struct bio_st *bio);
456/* unsigned long order, char *file, int line, int num_bytes, char *addr */
457typedef int *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
458int CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
459
460/* 382/*
461 * Because this is a public header, use a portable method of indicating the 383 * Because this is a public header, use a portable method of indicating the
462 * function does not return, rather than __dead. 384 * function does not return, rather than __dead.
diff --git a/src/lib/libcrypto/hidden/openssl/crypto.h b/src/lib/libcrypto/hidden/openssl/crypto.h
index 083d156d14..efbcca975f 100644
--- a/src/lib/libcrypto/hidden/openssl/crypto.h
+++ b/src/lib/libcrypto/hidden/openssl/crypto.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto.h,v 1.3 2024/03/01 07:38:33 tb Exp $ */ 1/* $OpenBSD: crypto.h,v 1.4 2024/03/02 11:28:46 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2023 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -43,30 +43,10 @@ LCRYPTO_USED(CRYPTO_THREADID_cmp);
43LCRYPTO_USED(CRYPTO_THREADID_cpy); 43LCRYPTO_USED(CRYPTO_THREADID_cpy);
44LCRYPTO_USED(CRYPTO_THREADID_hash); 44LCRYPTO_USED(CRYPTO_THREADID_hash);
45LCRYPTO_USED(CRYPTO_set_mem_functions); 45LCRYPTO_USED(CRYPTO_set_mem_functions);
46LCRYPTO_USED(CRYPTO_set_locked_mem_functions);
47LCRYPTO_USED(CRYPTO_set_mem_ex_functions); 46LCRYPTO_USED(CRYPTO_set_mem_ex_functions);
48LCRYPTO_USED(CRYPTO_set_locked_mem_ex_functions);
49LCRYPTO_USED(CRYPTO_set_mem_debug_functions);
50LCRYPTO_USED(CRYPTO_get_mem_functions);
51LCRYPTO_USED(CRYPTO_get_locked_mem_functions);
52LCRYPTO_USED(CRYPTO_get_mem_ex_functions);
53LCRYPTO_USED(CRYPTO_get_locked_mem_ex_functions);
54LCRYPTO_USED(CRYPTO_get_mem_debug_functions);
55LCRYPTO_USED(CRYPTO_realloc_clean);
56LCRYPTO_USED(CRYPTO_remalloc);
57LCRYPTO_USED(CRYPTO_set_mem_debug_options);
58LCRYPTO_USED(CRYPTO_get_mem_debug_options);
59LCRYPTO_USED(CRYPTO_push_info_); 47LCRYPTO_USED(CRYPTO_push_info_);
60LCRYPTO_USED(CRYPTO_pop_info); 48LCRYPTO_USED(CRYPTO_pop_info);
61LCRYPTO_USED(CRYPTO_remove_all_info); 49LCRYPTO_USED(CRYPTO_remove_all_info);
62LCRYPTO_USED(CRYPTO_dbg_malloc);
63LCRYPTO_USED(CRYPTO_dbg_realloc);
64LCRYPTO_USED(CRYPTO_dbg_free);
65LCRYPTO_USED(CRYPTO_dbg_set_options);
66LCRYPTO_USED(CRYPTO_dbg_get_options);
67LCRYPTO_USED(CRYPTO_mem_leaks_fp);
68LCRYPTO_USED(CRYPTO_mem_leaks);
69LCRYPTO_USED(CRYPTO_mem_leaks_cb);
70LCRYPTO_USED(OpenSSLDie); 50LCRYPTO_USED(OpenSSLDie);
71LCRYPTO_USED(OPENSSL_cpu_caps); 51LCRYPTO_USED(OPENSSL_cpu_caps);
72LCRYPTO_USED(OPENSSL_init_crypto); 52LCRYPTO_USED(OPENSSL_init_crypto);
diff --git a/src/lib/libcrypto/malloc-wrapper.c b/src/lib/libcrypto/malloc-wrapper.c
index 4d57f00b23..e13cc23373 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.8 2023/07/08 08:28:23 beck Exp $ */ 1/* $OpenBSD: malloc-wrapper.c,v 1.9 2024/03/02 11:28:46 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Bob Beck 3 * Copyright (c) 2014 Bob Beck
4 * 4 *
@@ -36,111 +36,6 @@ CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int),
36} 36}
37LCRYPTO_ALIAS(CRYPTO_set_mem_ex_functions); 37LCRYPTO_ALIAS(CRYPTO_set_mem_ex_functions);
38 38
39int
40CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
41{
42 return 0;
43}
44LCRYPTO_ALIAS(CRYPTO_set_locked_mem_functions);
45
46int
47CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int),
48 void (*f)(void *))
49{
50 return 0;
51}
52LCRYPTO_ALIAS(CRYPTO_set_locked_mem_ex_functions);
53
54int
55CRYPTO_set_mem_debug_functions(void (*m)(void *, int, const char *, int, int),
56 void (*r)(void *, void *, int, const char *, int, int),
57 void (*f)(void *, int), void (*so)(long), long (*go)(void))
58{
59 return 0;
60}
61LCRYPTO_ALIAS(CRYPTO_set_mem_debug_functions);
62
63
64void
65CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
66 void (**f)(void *))
67{
68 if (m != NULL)
69 *m = malloc;
70 if (r != NULL)
71 *r = realloc;
72 if (f != NULL)
73 *f = free;
74}
75LCRYPTO_ALIAS(CRYPTO_get_mem_functions);
76
77void
78CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int),
79 void *(**r)(void *, size_t, const char *, int), void (**f)(void *))
80{
81 if (m != NULL)
82 *m = NULL;
83 if (r != NULL)
84 *r = NULL;
85 if (f != NULL)
86 *f = free;
87}
88LCRYPTO_ALIAS(CRYPTO_get_mem_ex_functions);
89
90void
91CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
92{
93 if (m != NULL)
94 *m = malloc;
95 if (f != NULL)
96 *f = free;
97}
98LCRYPTO_ALIAS(CRYPTO_get_locked_mem_functions);
99
100void
101CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int),
102 void (**f)(void *))
103{
104 if (m != NULL)
105 *m = NULL;
106 if (f != NULL)
107 *f = free;
108}
109LCRYPTO_ALIAS(CRYPTO_get_locked_mem_ex_functions);
110
111void
112CRYPTO_get_mem_debug_functions(void (**m)(void *, int, const char *, int, int),
113 void (**r)(void *, void *, int, const char *, int, int),
114 void (**f)(void *, int), void (**so)(long), long (**go)(void))
115{
116 if (m != NULL)
117 *m = NULL;
118 if (r != NULL)
119 *r = NULL;
120 if (f != NULL)
121 *f = NULL;
122 if (so != NULL)
123 *so = NULL;
124 if (go != NULL)
125 *go = NULL;
126}
127LCRYPTO_ALIAS(CRYPTO_get_mem_debug_functions);
128
129
130void *
131CRYPTO_malloc_locked(int num, const char *file, int line)
132{
133 if (num <= 0)
134 return NULL;
135 return malloc(num);
136}
137
138void
139CRYPTO_free_locked(void *ptr)
140{
141 free(ptr);
142}
143
144void * 39void *
145CRYPTO_malloc(int num, const char *file, int line) 40CRYPTO_malloc(int num, const char *file, int line)
146{ 41{
@@ -155,51 +50,8 @@ CRYPTO_strdup(const char *str, const char *file, int line)
155 return strdup(str); 50 return strdup(str);
156} 51}
157 52
158void *
159CRYPTO_realloc(void *ptr, int num, const char *file, int line)
160{
161 if (num <= 0)
162 return NULL;
163 return realloc(ptr, num);
164}
165
166void *
167CRYPTO_realloc_clean(void *ptr, int old_len, int num, const char *file,
168 int line)
169{
170 if (num <= 0)
171 return NULL;
172 /* Original does not support shrinking. */
173 if (num < old_len)
174 return NULL;
175 return recallocarray(ptr, old_len, num, 1);
176}
177LCRYPTO_ALIAS(CRYPTO_realloc_clean);
178
179void 53void
180CRYPTO_free(void *ptr) 54CRYPTO_free(void *ptr)
181{ 55{
182 free(ptr); 56 free(ptr);
183} 57}
184
185void *
186CRYPTO_remalloc(void *a, int num, const char *file, int line)
187{
188 free(a);
189 return malloc(num);
190}
191LCRYPTO_ALIAS(CRYPTO_remalloc);
192
193void
194CRYPTO_set_mem_debug_options(long bits)
195{
196 return;
197}
198LCRYPTO_ALIAS(CRYPTO_set_mem_debug_options);
199
200long
201CRYPTO_get_mem_debug_options(void)
202{
203 return 0;
204}
205LCRYPTO_ALIAS(CRYPTO_get_mem_debug_options);
diff --git a/src/lib/libcrypto/mem_dbg.c b/src/lib/libcrypto/mem_dbg.c
index e2eacebe19..bfdd9c171b 100644
--- a/src/lib/libcrypto/mem_dbg.c
+++ b/src/lib/libcrypto/mem_dbg.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mem_dbg.c,v 1.25 2023/07/08 08:28:23 beck Exp $ */ 1/* $OpenBSD: mem_dbg.c,v 1.26 2024/03/02 11:28:46 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -122,27 +122,6 @@ CRYPTO_mem_ctrl(int mode)
122} 122}
123 123
124int 124int
125CRYPTO_is_mem_check_on(void)
126{
127 return (0);
128}
129
130
131void
132CRYPTO_dbg_set_options(long bits)
133{
134 return;
135}
136LCRYPTO_ALIAS(CRYPTO_dbg_set_options);
137
138long
139CRYPTO_dbg_get_options(void)
140{
141 return (0);
142}
143LCRYPTO_ALIAS(CRYPTO_dbg_get_options);
144
145int
146CRYPTO_push_info_(const char *info, const char *file, int line) 125CRYPTO_push_info_(const char *info, const char *file, int line)
147{ 126{
148 return (0); 127 return (0);
@@ -162,48 +141,3 @@ CRYPTO_remove_all_info(void)
162 return (0); 141 return (0);
163} 142}
164LCRYPTO_ALIAS(CRYPTO_remove_all_info); 143LCRYPTO_ALIAS(CRYPTO_remove_all_info);
165
166void
167CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
168 int before_p)
169{
170 OPENSSL_assert("CRYPTO_dbg_malloc is no longer permitted");
171}
172LCRYPTO_ALIAS(CRYPTO_dbg_malloc);
173
174void
175CRYPTO_dbg_free(void *addr, int before_p)
176{
177 OPENSSL_assert("CRYPTO_dbg_free is no longer permitted");
178}
179LCRYPTO_ALIAS(CRYPTO_dbg_free);
180
181void
182CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
183 const char *file, int line, int before_p)
184{
185 OPENSSL_assert("CRYPTO_dbg_realloc is no longer permitted");
186}
187LCRYPTO_ALIAS(CRYPTO_dbg_realloc);
188
189int
190CRYPTO_mem_leaks(BIO *b)
191{
192 return -1;
193}
194LCRYPTO_ALIAS(CRYPTO_mem_leaks);
195
196int
197CRYPTO_mem_leaks_fp(FILE *fp)
198{
199 return -1;
200}
201LCRYPTO_ALIAS(CRYPTO_mem_leaks_fp);
202
203
204int
205CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb)
206{
207 return -1;
208}
209LCRYPTO_ALIAS(CRYPTO_mem_leaks_cb);