From 11a490dfe715accf249fca3104c0877bf992fe31 Mon Sep 17 00:00:00 2001 From: Gilles Chehade Date: Mon, 12 Oct 2009 22:34:38 +0000 Subject: - fix a null deref which could happen after a couple iterations of the aliases/virtual domains resolution code. - fix a logic bug which caused virtual domains not to be correctly handled after one iteration of the aliases resolution code. - introduce a few helper functions to help clean up and simplify the lka code. - simplify the IS_EXT/IS_MAILBOX/IS_RELAY macros so they manipulate a struct path * instead of the mess of dereferences we were passing them. --- usr.sbin/smtpd/aliases.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'usr.sbin/smtpd/aliases.c') diff --git a/usr.sbin/smtpd/aliases.c b/usr.sbin/smtpd/aliases.c index 99aa40b03af..076d7ef7099 100644 --- a/usr.sbin/smtpd/aliases.c +++ b/usr.sbin/smtpd/aliases.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aliases.c,v 1.20 2009/10/11 17:40:49 gilles Exp $ */ +/* $OpenBSD: aliases.c,v 1.21 2009/10/12 22:34:37 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -144,6 +144,9 @@ aliases_vdomain_exists(struct smtpd *env, struct map *map, char *hostname) DB *vtable; char strkey[MAX_LINE_SIZE]; + if (map == NULL) + return 0; + vtable = dbopen(map->m_config, O_RDONLY, 0600, DB_HASH, NULL); if (vtable == NULL) { log_warn("aliases_vdomain_exists: dbopen"); @@ -177,6 +180,9 @@ aliases_virtual_exist(struct smtpd *env, struct map *map, struct path *path) DB *aliasesdb; char strkey[MAX_LINE_SIZE]; + if (map == NULL) + return 0; + aliasesdb = dbopen(map->m_config, O_RDONLY, 0600, DB_HASH, NULL); if (aliasesdb == NULL) { log_warn("aliases_virtual_exist: dbopen"); @@ -231,6 +237,9 @@ aliases_virtual_get(struct smtpd *env, struct map *map, struct alias *nextalias; char strkey[MAX_LINE_SIZE]; + if (map == NULL) + return 0; + aliasesdb = dbopen(map->m_config, O_RDONLY, 0600, DB_HASH, NULL); if (aliasesdb == NULL) { log_warn("aliases_virtual_get: dbopen"); -- cgit v1.2.3