summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/lka_session.c13
-rw-r--r--usr.sbin/smtpd/mta.c6
-rw-r--r--usr.sbin/smtpd/smtpd.h3
-rw-r--r--usr.sbin/smtpd/util.c14
4 files changed, 21 insertions, 15 deletions
diff --git a/usr.sbin/smtpd/lka_session.c b/usr.sbin/smtpd/lka_session.c
index a33977b536c..ebfb374d512 100644
--- a/usr.sbin/smtpd/lka_session.c
+++ b/usr.sbin/smtpd/lka_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka_session.c,v 1.25 2012/09/18 13:42:39 eric Exp $ */
+/* $OpenBSD: lka_session.c,v 1.26 2012/09/18 14:23:01 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -91,7 +91,7 @@ lka_session_envelope_expand(struct lka_session *lks, struct envelope *ep)
switch (ep->rule.r_condition.c_type) {
case C_ALL:
- case C_DOM: {
+ case C_DOM:
if (ep->agent.mda.to.user[0] == '\0')
user = ep->dest.user;
else
@@ -153,9 +153,8 @@ lka_session_envelope_expand(struct lka_session *lks, struct envelope *ep)
lka_session_request_forwardfile(lks, ep, u.username);
return 1;
- }
- case C_VDOM: {
+ case C_VDOM:
if (aliases_virtual_exist(ep->rule.r_condition.c_map, &ep->dest)) {
if (! aliases_virtual_get(ep->rule.r_condition.c_map,
&lks->expandtree, &ep->dest))
@@ -163,7 +162,6 @@ lka_session_envelope_expand(struct lka_session *lks, struct envelope *ep)
return 1;
}
return 0;
- }
default:
fatalx("lka_session_envelope_expand: unexpected type");
@@ -344,10 +342,7 @@ lka_session_deliver(struct lka_session *lks, struct envelope *ep)
{
struct envelope *new_ep;
- new_ep = calloc(1, sizeof (*ep));
- if (new_ep == NULL)
- fatal("lka_session_deliver: calloc");
- *new_ep = *ep;
+ new_ep = xmemdup(ep, sizeof *ep, "lka_session_deliver");
if (new_ep->type == D_MDA) {
switch (new_ep->agent.mda.method) {
case A_MAILDIR:
diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c
index 264a0f82372..e0aa972fd2b 100644
--- a/usr.sbin/smtpd/mta.c
+++ b/usr.sbin/smtpd/mta.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta.c,v 1.141 2012/09/16 16:43:28 chl Exp $ */
+/* $OpenBSD: mta.c,v 1.142 2012/09/18 14:23:01 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -93,9 +93,7 @@ mta_imsg(struct imsgev *iev, struct imsg *imsg)
return;
case IMSG_BATCH_APPEND:
- e = xmalloc(sizeof *e, "mta:envelope");
- memmove(e, imsg->data, sizeof *e);
-
+ e = xmemdup(imsg->data, sizeof *e, "mta:envelope");
route = mta_route_for(e);
batch = tree_xget(&batches, e->batch_id);
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 781e787da02..b74e445d6be 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.355 2012/09/18 13:42:39 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.356 2012/09/18 14:23:01 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -1210,3 +1210,4 @@ int text_to_relayhost(struct relayhost *, char *);
void *xmalloc(size_t, const char *);
void *xcalloc(size_t, size_t, const char *);
char *xstrdup(const char *, const char *);
+void *xmemdup(const void *, size_t, const char *);
diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c
index 3458a54599f..05b98c4a05d 100644
--- a/usr.sbin/smtpd/util.c
+++ b/usr.sbin/smtpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.77 2012/09/16 11:53:57 gilles Exp $ */
+/* $OpenBSD: util.c,v 1.78 2012/09/18 14:23:01 eric Exp $ */
/*
* Copyright (c) 2000,2001 Markus Friedl. All rights reserved.
@@ -88,6 +88,18 @@ xstrdup(const char *str, const char *where)
return (r);
}
+void *
+xmemdup(const void *ptr, size_t size, const char *where)
+{
+ void *r;
+
+ if ((r = malloc(size)) == NULL)
+ errx(1, "%s: malloc(%zu)", where, size);
+ memmove(r, ptr, size);
+
+ return (r);
+}
+
int
bsnprintf(char *str, size_t size, const char *format, ...)
{