#include "config.h"
#include <atf-c.h>
#include "dhcpd.h"
+#include "omapip/alloc.h"
static const char* checkString (struct data_string* ds, const char *src);
data_string_forget(&new_string, MDL);
}
+void checkBuffer(size_t test_size, const char *file, int line) {
+ char *buf;
+ size_t max_size;
+ /* Determine the maximum size we may have
+ * Depending on configuration options we may be adding some
+ * space to the allocated buffer for debugging purposes
+ * so remove that as well.
+ */
+ max_size = ((size_t)-1) - DMDSIZE;
+
+ if (test_size > max_size) {
+ atf_tc_skip("Test size greater than max size, %lx", test_size);
+ return;
+ }
+
+ /* We allocate the buffer and then try to set the last character
+ * to a known value.
+ */
+ buf = dmalloc(test_size, file, line);
+ if (buf != NULL) {
+ buf[test_size - 1] = 1;
+ if (buf[test_size - 1] != 1)
+ atf_tc_fail("Value mismatch for index %lu", test_size);
+ dfree(buf, file, line);
+ } else {
+ atf_tc_skip("Unable to allocate memory %lu", test_size);
+ }
+}
+
+ATF_TC(dmalloc_max32);
+
+ATF_TC_HEAD(dmalloc_max32, tc) {
+ atf_tc_set_md_var(tc, "descr", "dmalloc_max32 test, "
+ "dmalloc 0xFFFFFFFF");
+}
+ATF_TC_BODY(dmalloc_max32, tc) {
+ checkBuffer(0XFFFFFFFF, MDL);
+}
+
+ATF_TC(dmalloc_med1);
+
+ATF_TC_HEAD(dmalloc_med1, tc) {
+ atf_tc_set_md_var(tc, "descr", "dmalloc_med1 test, "
+ "dmalloc 0x80000000,");
+}
+ATF_TC_BODY(dmalloc_med1, tc) {
+ checkBuffer(0x80000000, MDL);
+}
+
+ATF_TC(dmalloc_med2);
+
+ATF_TC_HEAD(dmalloc_med2, tc) {
+ atf_tc_set_md_var(tc, "descr", "dmalloc_med2 test, "
+ "dmalloc 0x7FFFFFFF, ");
+}
+ATF_TC_BODY(dmalloc_med2, tc) {
+ checkBuffer(0x7FFFFFFF, MDL);
+}
+
+ATF_TC(dmalloc_med3);
+
+ATF_TC_HEAD(dmalloc_med3, tc) {
+ atf_tc_set_md_var(tc, "descr", "dmalloc_med3 test, "
+ "dmalloc 0x10000000,");
+}
+ATF_TC_BODY(dmalloc_med3, tc) {
+ checkBuffer(0x10000000, MDL);
+}
+
+ATF_TC(dmalloc_small);
+
+ATF_TC_HEAD(dmalloc_small, tc) {
+ atf_tc_set_md_var(tc, "descr", "dmalloc_small test, "
+ "dmalloc 0x0FFFFFFF");
+}
+ATF_TC_BODY(dmalloc_small, tc) {
+ checkBuffer(0X0FFFFFFF, MDL);
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, buffer_allocate);
ATF_TP_ADD_TC(tp, data_string_copy_nobuf);
ATF_TP_ADD_TC(tp, data_string_new);
ATF_TP_ADD_TC(tp, data_string_terminate);
+ ATF_TP_ADD_TC(tp, dmalloc_max32);
+ ATF_TP_ADD_TC(tp, dmalloc_med1);
+ ATF_TP_ADD_TC(tp, dmalloc_med2);
+ ATF_TP_ADD_TC(tp, dmalloc_med3);
+ ATF_TP_ADD_TC(tp, dmalloc_small);
return (atf_no_error());
}
Definitions for the object management API and protocol... */
/*
- * Copyright (c) 2009,2013-2014 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009,2013-2014,2016 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
isc_result_t omapi_handle_lookup (omapi_object_t **, omapi_handle_t);
isc_result_t omapi_handle_td_lookup (omapi_object_t **, omapi_typed_data_t *);
-void * dmalloc (unsigned, const char *, int);
+void * dmalloc (size_t, const char *, int);
void dfree (void *, const char *, int);
#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
protocol... */
/*
- * Copyright (c) 2012,2014 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2012,2014,2016 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
#endif
void *
-dmalloc(unsigned size, const char *file, int line) {
+dmalloc(size_t size, const char *file, int line) {
unsigned char *foo;
- unsigned len;
+ size_t len;
void **bar;
#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)