summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2018-03-02 00:02:06 +0800
committerMatt Johnston <matt@ucc.asn.au>2018-03-02 00:02:06 +0800
commit6d274cc097cb8d28be375c9c2b7135c133f3cbe2 (patch)
tree1f55953334c32b8fd0dca2f222a58c52f3231e9d
parent4cb32aeff3b9f7f3ba6ef1d08b4d961fd99b62b3 (diff)
downloaddropbear-6d274cc097cb8d28be375c9c2b7135c133f3cbe2.tar.gz
Attempt to fix m_free for libtomcrypt/libtommath
-rw-r--r--dbmalloc.h10
-rw-r--r--libtomcrypt/src/headers/tomcrypt_custom.h7
-rw-r--r--libtommath/tommath_class.h7
3 files changed, 8 insertions, 16 deletions
diff --git a/dbmalloc.h b/dbmalloc.h
index a5a13ad..d5e814e 100644
--- a/dbmalloc.h
+++ b/dbmalloc.h
@@ -1,7 +1,9 @@
#ifndef DBMALLOC_H_
#define DBMALLOC_H_
-#include "includes.h"
+#include "stdint.h"
+#include "stdlib.h"
+#include "options.h"
void * m_malloc(size_t size);
void * m_calloc(size_t nmemb, size_t size);
@@ -10,16 +12,16 @@ void * m_realloc(void* ptr, size_t size);
#if DROPBEAR_TRACKING_MALLOC
void m_free_direct(void* ptr);
-#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
void m_malloc_set_epoch(unsigned int epoch);
void m_malloc_free_epoch(unsigned int epoch, int dofree);
#else
/* plain wrapper */
-
-#define m_free(X) do {free(X); (X) = NULL;} while (0)
+#define m_free_direct free
#endif
+#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
+
#endif /* DBMALLOC_H_ */
diff --git a/libtomcrypt/src/headers/tomcrypt_custom.h b/libtomcrypt/src/headers/tomcrypt_custom.h
index 6fb0f27..f2351da 100644
--- a/libtomcrypt/src/headers/tomcrypt_custom.h
+++ b/libtomcrypt/src/headers/tomcrypt_custom.h
@@ -12,12 +12,7 @@
#include "tomcrypt_dropbear.h"
-void * m_malloc(size_t size);
-/* m_calloc is limited in size, enough for libtomcrypt */
-void * m_calloc(size_t nmemb, size_t size);
-void * m_realloc(void* ptr, size_t size);
-void m_free_direct(void* ptr);
-
+#include "dbmalloc.h"
#define XMALLOC m_malloc
#define XFREE m_free_direct
#define XREALLOC m_realloc
diff --git a/libtommath/tommath_class.h b/libtommath/tommath_class.h
index bd7c39a..b9d9c0c 100644
--- a/libtommath/tommath_class.h
+++ b/libtommath/tommath_class.h
@@ -1062,12 +1062,7 @@
#undef BN_MP_TOOM_MUL_C
#undef BN_MP_TOOM_SQR_C
-void * m_malloc(size_t size);
-/* m_calloc is limited in size, enough for libtomcrypt */
-void * m_calloc(size_t nmemb, size_t size);
-void * m_realloc(void* ptr, size_t size);
-void m_free_direct(void* ptr);
-
+#include "dbmalloc.h"
#define XMALLOC m_malloc
#define XFREE m_free_direct
#define XREALLOC m_realloc