summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2018-12-27 15:05:00 +0000
committerEric Faurot <eric@cvs.openbsd.org>2018-12-27 15:05:00 +0000
commit5ad1bbdbdc081ee2d9d820e8f4edafc1d05dbacc (patch)
treec0df10ce1f01bdaa0dba835a1fdd2e785873f451
parent69086d6d6e422e7b88cb3669c4799570061a1897 (diff)
table_fetch() always expect a valid dst pointer.
ok gilles@
-rw-r--r--usr.sbin/smtpd/table.c13
-rw-r--r--usr.sbin/smtpd/table_db.c10
-rw-r--r--usr.sbin/smtpd/table_static.c7
3 files changed, 11 insertions, 19 deletions
diff --git a/usr.sbin/smtpd/table.c b/usr.sbin/smtpd/table.c
index f43e52973ea..397d850ee9a 100644
--- a/usr.sbin/smtpd/table.c
+++ b/usr.sbin/smtpd/table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table.c,v 1.42 2018/12/27 14:23:41 eric Exp $ */
+/* $OpenBSD: table.c,v 1.43 2018/12/27 15:04:59 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -174,18 +174,15 @@ table_fetch(struct table *table, enum table_service kind, union lookup *lk)
if (table->t_backend->fetch == NULL)
return (-1);
- r = table->t_backend->fetch(table, kind, lk ? &buf : NULL);
+ r = table->t_backend->fetch(table, kind, &buf);
if (r == 1) {
- log_trace(TRACE_LOOKUP, "lookup: fetch %s from table %s:%s -> %s%s%s",
+ log_trace(TRACE_LOOKUP, "lookup: fetch %s from table %s:%s -> \"%s\"",
table_service_name(kind),
table->t_backend->name,
table->t_name,
- lk ? "\"" : "",
- (lk) ? buf : "found",
- lk ? "\"" : "");
- if (buf)
- r = table_parse_lookup(kind, NULL, buf, lk);
+ buf);
+ r = table_parse_lookup(kind, NULL, buf, lk);
}
else
log_trace(TRACE_LOOKUP, "lookup: fetch %s from table %s:%s -> %d",
diff --git a/usr.sbin/smtpd/table_db.c b/usr.sbin/smtpd/table_db.c
index fde3983eb3d..426d0f7cf90 100644
--- a/usr.sbin/smtpd/table_db.c
+++ b/usr.sbin/smtpd/table_db.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table_db.c,v 1.19 2018/12/27 14:41:45 eric Exp $ */
+/* $OpenBSD: table_db.c,v 1.20 2018/12/27 15:04:59 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
@@ -221,11 +221,9 @@ table_db_fetch(struct table *table, enum table_service service, char **dst)
return 0;
}
- if (dst) {
- *dst = strdup(dbk.data);
- if (*dst == NULL)
- return -1;
- }
+ *dst = strdup(dbk.data);
+ if (*dst == NULL)
+ return -1;
return 1;
}
diff --git a/usr.sbin/smtpd/table_static.c b/usr.sbin/smtpd/table_static.c
index c0d122fe1f6..361be8f4834 100644
--- a/usr.sbin/smtpd/table_static.c
+++ b/usr.sbin/smtpd/table_static.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table_static.c,v 1.28 2018/12/27 14:23:41 eric Exp $ */
+/* $OpenBSD: table_static.c,v 1.29 2018/12/27 15:04:59 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -307,7 +307,7 @@ table_static_lookup(struct table *m, enum table_service service, const char *key
static int
table_static_fetch(struct table *t, enum table_service service, char **dst)
{
- const char *k;
+ const char *k;
if (!dict_iter(&t->t_dict, &t->t_iter, &k, (void **)NULL)) {
t->t_iter = NULL;
@@ -315,9 +315,6 @@ table_static_fetch(struct table *t, enum table_service service, char **dst)
return 0;
}
- if (dst == NULL)
- return 1;
-
*dst = strdup(k);
if (*dst == NULL)
return -1;