diff --git a/smmapdfw/configure b/smmapdfw/configure index 9b6a5aa..ba17d0a 100755 --- a/smmapdfw/configure +++ b/smmapdfw/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for smmapdfw 0.91. +# Generated by GNU Autoconf 2.59 for smmapdfw 0.92. # # Report bugs to . # @@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='smmapdfw' PACKAGE_TARNAME='smmapdfw' -PACKAGE_VERSION='0.91' -PACKAGE_STRING='smmapdfw 0.91' +PACKAGE_VERSION='0.92' +PACKAGE_STRING='smmapdfw 0.92' PACKAGE_BUGREPORT='woho@hottis.de' # Factoring default headers for most tests. @@ -953,7 +953,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures smmapdfw 0.91 to adapt to many kinds of systems. +\`configure' configures smmapdfw 0.92 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1019,7 +1019,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of smmapdfw 0.91:";; + short | recursive ) echo "Configuration of smmapdfw 0.92:";; esac cat <<\_ACEOF @@ -1162,7 +1162,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -smmapdfw configure 0.91 +smmapdfw configure 0.92 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -1176,7 +1176,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by smmapdfw $as_me 0.91, which was +It was created by smmapdfw $as_me 0.92, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1707,7 +1707,7 @@ fi PACKAGE=smmapdfw -VERSION=0.91 +VERSION=0.92 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 @@ -21715,7 +21715,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by smmapdfw $as_me 0.91, which was +This file was extended by smmapdfw $as_me 0.92, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21778,7 +21778,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -smmapdfw config.status 0.91 +smmapdfw config.status 0.92 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff --git a/smmapdfw/configure.ac b/smmapdfw/configure.ac index 17f7c9f..4ac0b0c 100644 --- a/smmapdfw/configure.ac +++ b/smmapdfw/configure.ac @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. -AC_INIT(smmapdfw, 0.91, woho@hottis.de) -AM_INIT_AUTOMAKE(smmapdfw, 0.91) +AC_INIT(smmapdfw, 0.92, woho@hottis.de) +AM_INIT_AUTOMAKE(smmapdfw, 0.92) AM_MAINTAINER_MODE AM_CONFIG_HEADER(config.h) diff --git a/smmapdfw/cyrus_worker/cyrus_worker.c b/smmapdfw/cyrus_worker/cyrus_worker.c index caaad14..efc253a 100644 --- a/smmapdfw/cyrus_worker/cyrus_worker.c +++ b/smmapdfw/cyrus_worker/cyrus_worker.c @@ -27,6 +27,7 @@ #include "smtp.h" #include "htdns.h" +#include "htmalloc.h" #define SMM_LOCAL_PERM_NOK 101 #define SMM_LOCAL_TEMP_NOK 102 @@ -75,7 +76,7 @@ class_descriptor_t cyruscheck = { int cyrus_init(cfgl_t *cfg, void **handle) { cyrus_container_handle_t *cch; - cch = (cyrus_container_handle_t*) malloc(sizeof(cyrus_container_handle_t)); + cch = (cyrus_container_handle_t*) htmalloc(sizeof(cyrus_container_handle_t)); cch->cfg = cfg; cch->timeout = atoi(findcfglx(cch->cfg, "timeout", "5")); @@ -165,7 +166,7 @@ int cyrus_work(void *handle, void *work_handle, char *input, char *output) { err = smtp_mailfrom(lmtp, cch->sender_address); break; case RCPTTO: - tmp_arg = (char*) malloc(sizeof(char) * (strlen(depot_uid)+5)); + tmp_arg = (char*) htmalloc(sizeof(char) * (strlen(depot_uid)+5)); *tmp_arg = '\0'; strcat(tmp_arg, "<"); strcat(tmp_arg, depot_uid); diff --git a/smmapdfw/libsmmapdfw/Makefile.am b/smmapdfw/libsmmapdfw/Makefile.am index 56b1349..fd72e73 100644 --- a/smmapdfw/libsmmapdfw/Makefile.am +++ b/smmapdfw/libsmmapdfw/Makefile.am @@ -1,5 +1,5 @@ -include_HEADERS=containers_public.h queue.h smtp.h cfg.h count.h safe_write.h sunos_comp.h htdns.h smmapd.h +include_HEADERS=containers_public.h queue.h smtp.h cfg.h count.h safe_write.h sunos_comp.h htdns.h smmapd.h htmalloc.h lib_LTLIBRARIES = libsmmapdfw.la -libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c +libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c htmalloc.c diff --git a/smmapdfw/libsmmapdfw/Makefile.in b/smmapdfw/libsmmapdfw/Makefile.in index f314cf7..215be5d 100644 --- a/smmapdfw/libsmmapdfw/Makefile.in +++ b/smmapdfw/libsmmapdfw/Makefile.in @@ -87,9 +87,9 @@ RC = @RC@ STRIP = @STRIP@ VERSION = @VERSION@ -include_HEADERS = containers_public.h queue.h smtp.h cfg.h count.h safe_write.h sunos_comp.h htdns.h smmapd.h +include_HEADERS = containers_public.h queue.h smtp.h cfg.h count.h safe_write.h sunos_comp.h htdns.h smmapd.h htmalloc.h lib_LTLIBRARIES = libsmmapdfw.la -libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c +libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c htmalloc.c mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = @@ -103,7 +103,7 @@ LIBS = @LIBS@ libsmmapdfw_la_LDFLAGS = libsmmapdfw_la_LIBADD = libsmmapdfw_la_OBJECTS = cfg.lo queue.lo count.lo safe_write.lo \ -config_public.lo htdns.lo smtp.lo +config_public.lo htdns.lo smtp.lo htmalloc.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -119,7 +119,8 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best DEP_FILES = .deps/cfg.P .deps/config_public.P .deps/count.P \ -.deps/htdns.P .deps/queue.P .deps/safe_write.P .deps/smtp.P +.deps/htdns.P .deps/htmalloc.P .deps/queue.P .deps/safe_write.P \ +.deps/smtp.P SOURCES = $(libsmmapdfw_la_SOURCES) OBJECTS = $(libsmmapdfw_la_OBJECTS) diff --git a/smmapdfw/libsmmapdfw/cfg.c b/smmapdfw/libsmmapdfw/cfg.c index d0b4f51..cee84ef 100644 --- a/smmapdfw/libsmmapdfw/cfg.c +++ b/smmapdfw/libsmmapdfw/cfg.c @@ -37,6 +37,7 @@ #endif #include "cfg.h" +#include "htmalloc.h" #include "sunos_comp.h" @@ -103,9 +104,9 @@ config_section_t *readcfg(char *cfgfile) { state = STATE_START; i = 0; - cs = (config_section_t*) malloc(sizeof(config_section_t)); + cs = (config_section_t*) htmalloc(sizeof(config_section_t)); cs->next = NULL; - cs->name = (char*) malloc(strlen(buffer)+1); + cs->name = (char*) htmalloc(strlen(buffer)+1); strcpy(cs->name, buffer); cs->item = NULL; @@ -135,9 +136,9 @@ config_section_t *readcfg(char *cfgfile) { state = STATE_EQUAL; i = 0; - ci = (config_item_t*) malloc(sizeof(config_item_t)); + ci = (config_item_t*) htmalloc(sizeof(config_item_t)); ci->next = NULL; - ci->name = (char*) malloc(strlen(buffer)+1); + ci->name = (char*) htmalloc(strlen(buffer)+1); strcpy(ci->name, buffer); ci->value = NULL; @@ -194,7 +195,7 @@ config_section_t *readcfg(char *cfgfile) { state = STATE_START; i = 0; - ci->value = (char*) malloc(strlen(buffer)+1); + ci->value = (char*) htmalloc(strlen(buffer)+1); strcpy(ci->value, buffer); break; diff --git a/smmapdfw/libsmmapdfw/htdns.c b/smmapdfw/libsmmapdfw/htdns.c index a842aaa..e1a6b9d 100644 --- a/smmapdfw/libsmmapdfw/htdns.c +++ b/smmapdfw/libsmmapdfw/htdns.c @@ -40,6 +40,8 @@ #endif #include "htdns.h" +#include "htmalloc.h" + #if ! HAVE_LIBDJBDNS extern int h_errno; @@ -77,7 +79,7 @@ static int get_domain_name(answer_t *answer, int offset, char **name) { offset2 = ((len & ~0xC0) << 8) + answer->buf[offset++]; get_domain_name(answer, offset2, &name_buf2); remember_name_buf = name_buf; - name_buf = (char*) realloc(name_buf, ((NULL != name_buf) ? strlen(name_buf) : 0) + strlen(name_buf2) + 1); + name_buf = (char*) htrealloc(name_buf, ((NULL != name_buf) ? strlen(name_buf) : 0) + strlen(name_buf2) + 1); if (NULL == remember_name_buf) { name_buf[0] = '\0'; } @@ -93,7 +95,7 @@ static int get_domain_name(answer_t *answer, int offset, char **name) { offset += len; if (NULL != name) { i = (NULL != name_buf) ? strlen(name_buf) : 0; - name_buf = (char*) realloc(name_buf, i+len+2); + name_buf = (char*) htrealloc(name_buf, i+len+2); strncpy(name_buf + i, answer->buf + start, len); name_buf[i+len] = '\0'; strcat(name_buf, "."); @@ -108,7 +110,7 @@ static int get_domain_name(answer_t *answer, int offset, char **name) { } static int get_mx_rdata(answer_t *answer, int offset, int len, mx_rdata_t **resp) { - *resp = (mx_rdata_t*) malloc(sizeof(mx_rdata_t)); + *resp = (mx_rdata_t*) htmalloc(sizeof(mx_rdata_t)); (*resp)->preference = get16(answer->buf, offset); get_domain_name(answer, offset+2, &(*resp)->exchange); (*resp)->type = T_MX; @@ -124,7 +126,7 @@ static void free_mx_rdata(mx_rdata_t *resp) { static int get_a_rdata(answer_t *answer, int offset, int len, a_rdata_t **resp) { - *resp = (a_rdata_t*) malloc(sizeof(a_rdata_t)); + *resp = (a_rdata_t*) htmalloc(sizeof(a_rdata_t)); (*resp)->address = htonl(get32(answer->buf, offset)); (*resp)->type = T_A; @@ -132,7 +134,7 @@ static int get_a_rdata(answer_t *answer, int offset, int len, a_rdata_t **resp) } static int get_cname_rdata(answer_t *answer, int offset, int len, cname_rdata_t **resp) { - *resp = (cname_rdata_t*) malloc(sizeof(cname_rdata_t)); + *resp = (cname_rdata_t*) htmalloc(sizeof(cname_rdata_t)); get_domain_name(answer, offset, &(*resp)->cname); (*resp)->type = T_CNAME; @@ -317,7 +319,7 @@ static void** get_rrs(char *domain, int qtype) { } /* answer section */ - rdata = (void**)malloc(sizeof(void*) * (ntohs(answer->hdr.ancount)+1)); + rdata = (void**)htmalloc(sizeof(void*) * (ntohs(answer->hdr.ancount)+1)); for (y = 0; y < ntohs(answer->hdr.ancount); y++) { cnt = get_domain_name(answer, cnt, NULL); type = get16(answer->buf, cnt); @@ -401,7 +403,7 @@ mx_rdata_t** get_best_mx_rrs(char *domain) { return all_mx_rrs; } else { /* space for the minimum pref rr's */ - best_mx_rrs = (mx_rdata_t**) malloc(sizeof(mx_rdata_t*) * (best_cnt+1)); + best_mx_rrs = (mx_rdata_t**) htmalloc(sizeof(mx_rdata_t*) * (best_cnt+1)); for (mx_rdata2 = all_mx_rrs; *mx_rdata2 != NULL; mx_rdata2++) { if ((*mx_rdata2)->preference == min_pref) { /* is a minimum one, keep it */ diff --git a/smmapdfw/libsmmapdfw/htmalloc.c b/smmapdfw/libsmmapdfw/htmalloc.c new file mode 100644 index 0000000..a9d2ebf --- /dev/null +++ b/smmapdfw/libsmmapdfw/htmalloc.c @@ -0,0 +1,56 @@ +/* + Copyright (C) 2004, Wolfgang Hottgenroth + + This file is part of smmapdfw. + + smmapdfw is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + smmapdfw is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with smmapdfw. If not, write to the Free Software Foundation, 59 + Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + + +#include +#include +#include "htmalloc.h" + + +void *htmalloc(size_t size) { + void *p = malloc(size); + if (NULL == p) { + syslog(LOG_ERR, "htmalloc: out of memory"); + exit(153); + } + return p; +} + +void *htrealloc(void *ptr, size_t size) { + void *p = realloc(ptr, size); + if (NULL == p) { + syslog(LOG_ERR, "htremalloc: out of memory"); + exit(153); + } + return p; +} + +char *htstrdup(const char *s) { + char *p = htmalloc(strlen(s) + 1); + strcpy(p, s); + return p; +} + + + + + + + diff --git a/smmapdfw/libsmmapdfw/htmalloc.h b/smmapdfw/libsmmapdfw/htmalloc.h new file mode 100644 index 0000000..33d924f --- /dev/null +++ b/smmapdfw/libsmmapdfw/htmalloc.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2004, Wolfgang Hottgenroth + + This file is part of smmapdfw. + + smmapdfw is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + smmapdfw is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with smmapdfw. If not, write to the Free Software Foundation, 59 + Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef _HTMALLOC_H_ +#define _HTMALLOC_H_ + +#include + +void *htmalloc(size_t size); +void *htrealloc(void *ptr, size_t size); +char *htstrdup(const char *s); + + + +#endif /* _HTMALLOC_H_ */ + + diff --git a/smmapdfw/libsmmapdfw/queue.c b/smmapdfw/libsmmapdfw/queue.c index 6439c96..e24404c 100644 --- a/smmapdfw/libsmmapdfw/queue.c +++ b/smmapdfw/libsmmapdfw/queue.c @@ -21,6 +21,7 @@ #include "queue.h" +#include "htmalloc.h" #ifdef _TEST_MODE_ #include @@ -45,7 +46,7 @@ void queue_destroy(ht_queue_t *q) { int queue_put(ht_queue_t *q, void *d) { queue_entry_t *entry; - entry = (queue_entry_t *) malloc(sizeof(queue_entry_t)); + entry = (queue_entry_t *) htmalloc(sizeof(queue_entry_t)); if (NULL == entry) return -1; diff --git a/smmapdfw/libsmmapdfw/smtp.c b/smmapdfw/libsmmapdfw/smtp.c index 80fdfd7..b111ead 100644 --- a/smmapdfw/libsmmapdfw/smtp.c +++ b/smmapdfw/libsmmapdfw/smtp.c @@ -34,7 +34,7 @@ #include #include "smtp.h" - +#include "htmalloc.h" #define BUFSIZE 1024 @@ -43,7 +43,7 @@ smtp_t *smtp_init(unsigned int address, int port, int timeout) { - smtp_t *handle = (smtp_t*) malloc(sizeof(smtp_t)); + smtp_t *handle = (smtp_t*) htmalloc(sizeof(smtp_t)); handle->address = address; handle->port = port; @@ -52,7 +52,7 @@ smtp_t *smtp_init(unsigned int address, int port, int timeout) { handle->response_code = 0; handle->got_timeout = 0; - handle->buffer = (char*) malloc(BUFSIZE+5); + handle->buffer = (char*) htmalloc(BUFSIZE+5); return handle; } diff --git a/smmapdfw/lua_worker/lua_worker.c b/smmapdfw/lua_worker/lua_worker.c index 4b8d5fc..516fe7b 100644 --- a/smmapdfw/lua_worker/lua_worker.c +++ b/smmapdfw/lua_worker/lua_worker.c @@ -27,6 +27,7 @@ #include "containers_public.h" #include "smmapd.h" +#include "htmalloc.h" #define CFG_LUALIB_NAMES "load" @@ -87,7 +88,7 @@ int lua_init(cfgl_t *cfg, void **handle) { const luaL_reg *lualib; cfgl_t *cfgl_iter; - lch = (lua_container_handle_t*) malloc(sizeof(lua_container_handle_t)); + lch = (lua_container_handle_t*) htmalloc(sizeof(lua_container_handle_t)); lch->cfg = cfg; lua_filename = findcfgl(lch->cfg, CFG_LUA_FILENAME); @@ -165,7 +166,7 @@ int lua_destroy(void *handle) { } int lua_work_setup(void *handle, void **work_handle) { - lua_worker_handle_t *lwh = (lua_worker_handle_t*)malloc(sizeof(lua_worker_handle_t)); + lua_worker_handle_t *lwh = (lua_worker_handle_t*)htmalloc(sizeof(lua_worker_handle_t)); lwh->lch = (lua_container_handle_t*) handle; lwh->l = lua_newthread(lwh->lch->l); diff --git a/smmapdfw/smmapd/containers.c b/smmapdfw/smmapd/containers.c index 820e1f3..0b45171 100644 --- a/smmapdfw/smmapd/containers.c +++ b/smmapdfw/smmapd/containers.c @@ -43,6 +43,7 @@ #include "containers.h" #include "cfg.h" #include "smmapd.h" +#include "htmalloc.h" #define CFG_SECTION_GLOBAL "global" @@ -59,7 +60,7 @@ classes_t *classes_head = &classes_root; int containers_setup(container_handle_t **ch) { - *ch = (container_handle_t*)malloc(sizeof(container_handle_t)); + *ch = (container_handle_t*)htmalloc(sizeof(container_handle_t)); (*ch)->worker_handle_root.next = NULL; return 0; } @@ -130,7 +131,7 @@ int containers_dispatcher(container_handle_t *ch, char *input, char *output) { if ((NULL == wh_last->next) && (NULL == wh2)) { syslog(LOG_DEBUG, "dispatcher: we haven't one, we create one"); - wh2 = (worker_handle_t*)malloc(sizeof(worker_handle_t)); + wh2 = (worker_handle_t*)htmalloc(sizeof(worker_handle_t)); wh2->id = classes->id; if (NULL != classes->descr->work_setup_function) { err = (*classes->descr->work_setup_function)(classes->handle, &(wh2->handle)); @@ -170,7 +171,7 @@ static int register_class(int id, class_descriptor_t *class_descriptor) { return -1; } - w = (classes_t *) malloc(sizeof(classes_t)); + w = (classes_t *) htmalloc(sizeof(classes_t)); if (NULL == w) { syslog(LOG_ERR, "register_class: unable to alloc memory"); return -2; @@ -254,7 +255,7 @@ int register_all() { return -3; } - obj_name = (char*) malloc(((cfg_plugin_dir == NULL) ? 0 : strlen(cfg_plugin_dir)) + strlen(cfg_obj) + 5); + obj_name = (char*) htmalloc(((cfg_plugin_dir == NULL) ? 0 : strlen(cfg_plugin_dir)) + strlen(cfg_obj) + 5); obj_name[0] = '\0'; if (cfg_plugin_dir != NULL) { strcat(obj_name, cfg_plugin_dir); diff --git a/smmapdfw/smmapd/smmapd.c b/smmapdfw/smmapd/smmapd.c index 6da19db..8bdfecc 100644 --- a/smmapdfw/smmapd/smmapd.c +++ b/smmapdfw/smmapd/smmapd.c @@ -63,6 +63,7 @@ #include "containers.h" #include "cfg.h" #include "safe_write.h" +#include "htmalloc.h" #define _SMMAPD_C_ #include "smmapd.h" @@ -279,7 +280,7 @@ int server() { } - thread = (networkerThread_t *) malloc(sizeof(networkerThread_t)+10); + thread = (networkerThread_t *) htmalloc(sizeof(networkerThread_t)+10); if (NULL == thread) { syslog(LOG_ERR, "server: unable to alloc memory for networker"); continue; @@ -325,10 +326,10 @@ int main(int argc, char **argv) { foreground = 1; break; case 'f': - cfg_file = strdup(optarg); + cfg_file = htstrdup(optarg); break; case 'p': - pid_file = strdup(optarg); + pid_file = htstrdup(optarg); break; case 'v': printf("\nsmmapd - Wolfgang Hottgenroth \n"); diff --git a/smmapdfw/test/test.ini b/smmapdfw/test/test.ini index ec8dcd6..9eec7c0 100644 --- a/smmapdfw/test/test.ini +++ b/smmapdfw/test/test.ini @@ -1,6 +1,6 @@ [Global] -Host: ddev1.eng.emea.uu.net -Port: 110 +Host: localhost +Port: 8887 Threads: 20 [Verifier] diff --git a/smmapdfw/test_worker/test_workers.c b/smmapdfw/test_worker/test_workers.c index 6356a8d..ff42fd7 100644 --- a/smmapdfw/test_worker/test_workers.c +++ b/smmapdfw/test_worker/test_workers.c @@ -21,6 +21,8 @@ #include #include #include "containers_public.h" +#include "htmalloc.h" + int test_worker1_init(cfgl_t *cfg, void **handle); int test_worker1_setup(void *handle, void **work_handle); @@ -63,7 +65,7 @@ int test_worker1_init(cfgl_t *cfg, void **handle) { } int test_worker1_setup(void *handle, void **work_handle) { - test_worker1_handle_t *twh = (test_worker1_handle_t*)malloc(sizeof(test_worker1_handle_t)); + test_worker1_handle_t *twh = (test_worker1_handle_t*)htmalloc(sizeof(test_worker1_handle_t)); twh->counter = 0; *work_handle = twh; return 0; diff --git a/smmapdfw/verify_worker/verify_worker.c b/smmapdfw/verify_worker/verify_worker.c index 5647797..18ce52b 100644 --- a/smmapdfw/verify_worker/verify_worker.c +++ b/smmapdfw/verify_worker/verify_worker.c @@ -46,7 +46,7 @@ #include "htdns.h" #include "queue.h" #include "smtp.h" - +#include "htmalloc.h" #define SMM_LOCAL_PERM_NOK 101 @@ -160,7 +160,7 @@ class_descriptor_t verifier = { int verify_init(cfgl_t *cfg, void **handle) { verify_container_handle_t *vch; - vch = (verify_container_handle_t*) malloc(sizeof(verify_container_handle_t)); + vch = (verify_container_handle_t*) htmalloc(sizeof(verify_container_handle_t)); vch->cfg = cfg; vch->timeout_result = atoi(findcfglx(vch->cfg, "timeout_result", "5")); @@ -174,7 +174,7 @@ int verify_init(cfgl_t *cfg, void **handle) { vch->cache_file = findcfglx(vch->cfg, "cache_file", "verifier_cache"); if (1 == vch->cache_enabled) { - vch->cache_mutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t)); + vch->cache_mutex = (pthread_mutex_t*) htmalloc(sizeof(pthread_mutex_t)); pthread_mutex_init(vch->cache_mutex, NULL); pthread_mutex_unlock(vch->cache_mutex); } else { @@ -204,15 +204,15 @@ int verify_destroy(void *handle) { int verify_work_setup(void *handle, void **work_handle) { verify_work_handle_t *vwh; - vwh = (verify_work_handle_t*)malloc(sizeof(verify_work_handle_t)); + vwh = (verify_work_handle_t*)htmalloc(sizeof(verify_work_handle_t)); vwh->id = 0; - vwh->result = (verify_result_t*) malloc(sizeof(verify_result_t)); - vwh->result_mutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t)); + vwh->result = (verify_result_t*) htmalloc(sizeof(verify_result_t)); + vwh->result_mutex = (pthread_mutex_t*) htmalloc(sizeof(pthread_mutex_t)); pthread_mutex_init(vwh->result_mutex, NULL); pthread_mutex_unlock(vwh->result_mutex); - vwh->result_cond = (pthread_cond_t*) malloc(sizeof(pthread_cond_t)); + vwh->result_cond = (pthread_cond_t*) htmalloc(sizeof(pthread_cond_t)); pthread_cond_init(vwh->result_cond, NULL); - vwh->terminator_queue = (ht_queue_t*) malloc(sizeof(ht_queue_t)); + vwh->terminator_queue = (ht_queue_t*) htmalloc(sizeof(ht_queue_t)); queue_init(vwh->terminator_queue); vwh->vch = (verify_container_handle_t*)handle; @@ -295,7 +295,7 @@ void cache_insert(verify_container_handle_t *vch, const char *address, int resul key.dsize = strlen(address) + 1; /* one more for the terminating \0 */ key.dptr = (char*) address; data.dsize = (sizeof(mydata_t) + (sizeof(char) * (strlen(output) + 1))); - mydata = (mydata_t *) malloc(data.dsize); + mydata = (mydata_t *) htmalloc(data.dsize); mydata->result = result; mydata->timestamp = time(NULL); strcpy(mydata->output, output); @@ -345,7 +345,7 @@ int cache_lookup(verify_container_handle_t *vch, const char* address, int *resul if ((mydata->timestamp + vch->cache_expiry) > time(NULL)) { syslog(LOG_DEBUG, "cache_lookup: not yet expired"); *result = mydata->result; - *output = (char*) malloc(sizeof(char) * (strlen(mydata->output) + 1)); + *output = (char*) htmalloc(sizeof(char) * (strlen(mydata->output) + 1)); strcpy(*output, mydata->output); /* Berkeley DB frees on its own! */ @@ -429,16 +429,16 @@ int verify_work(void *handle, void *work_handle, char *input, char *output) { vwh->result->id = vwh->id; - wt = (worker_thread_t*) malloc(sizeof(worker_thread_t)); + wt = (worker_thread_t*) htmalloc(sizeof(worker_thread_t)); wt->id = vwh->id; wt->terminator_queue = vwh->terminator_queue; - wt->input = (char*) malloc(sizeof(char) * (strlen(input)+1)); + wt->input = (char*) htmalloc(sizeof(char) * (strlen(input)+1)); strcpy(wt->input, input); wt->output = NULL; wt->mutex = vwh->result_mutex; wt->cond = vwh->result_cond; wt->result = vwh->result; - wt->checker_terminator_queue = (ht_queue_t*) malloc(sizeof(ht_queue_t)); + wt->checker_terminator_queue = (ht_queue_t*) htmalloc(sizeof(ht_queue_t)); queue_init(wt->checker_terminator_queue); wt->checker_cnt = 0; wt->vwh = work_handle; @@ -486,7 +486,7 @@ static unsigned int *get_mx_ip_addresses(char *domain) { a_rdata = get_a_rrs((*mx_rdata2)->exchange); if (NULL != a_rdata) { for (a_rdata2 = a_rdata; *a_rdata2 != NULL; a_rdata2++) { - addresses = (unsigned int*)realloc(addresses, sizeof(unsigned int)*(i+2)); /* 2 since first i==0 and + addresses = (unsigned int*)htrealloc(addresses, sizeof(unsigned int)*(i+2)); /* 2 since first i==0 and we always need one more for the termination */ *(addresses+i) = (*a_rdata2)->address; @@ -555,7 +555,7 @@ static void *checker_thread(void *arg) { err = smtp_mailfrom(smtp, sender_address); break; case RCPTTO: - tmp_arg = (char*) malloc(sizeof(char) * (strlen(ct->email_address)+5)); + tmp_arg = (char*) htmalloc(sizeof(char) * (strlen(ct->email_address)+5)); *tmp_arg = '\0'; strcat(tmp_arg, "<"); strcat(tmp_arg, ct->email_address); @@ -624,7 +624,7 @@ static void *checker_thread(void *arg) { smtp_close(smtp); - ct->output = (char*) malloc(sizeof(char) * (strlen(response_text)+1)); + ct->output = (char*) htmalloc(sizeof(char) * (strlen(response_text)+1)); strcpy(ct->output, response_text); smtp_destroy(smtp); @@ -688,7 +688,7 @@ static void *worker_thread(void *arg) { (address&0x0000ff00)>>8, (address&0x000000ff), wt->input); - ct = (checker_thread_t*) malloc(sizeof(checker_thread_t)); + ct = (checker_thread_t*) htmalloc(sizeof(checker_thread_t)); ct->id = i+1; /* id of ct should start with 1, same as id of wt */ ct->ip_address = address; ct->email_address = wt->input; @@ -752,7 +752,7 @@ static void *worker_thread(void *arg) { if (wt->result->id == wt->id) { syslog(LOG_DEBUG, "verify (%p) worker_thread %d returned result", wt->vwh, wt->id); /* we can write the result */ - wt->result->output = (char*) malloc(sizeof(char) * (strlen(wt->output)+15)); /* enough for the output + wt->result->output = (char*) htmalloc(sizeof(char) * (strlen(wt->output)+15)); /* enough for the output plus <><> and prefix */ switch (result) { case SMM_LOCAL_TEMP_NOK: