summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreric <eric@openbsd.org>2011-12-18 18:43:30 +0000
committereric <eric@openbsd.org>2011-12-18 18:43:30 +0000
commitd91b4a8bf4edcfa53762ea6c56b06991ef69f5e1 (patch)
tree5970a152b612554a8820a8c039b9bc11890e5f9b
parentDon't lie the number of estabilished connections. nconns is the number (diff)
downloadwireguard-openbsd-d91b4a8bf4edcfa53762ea6c56b06991ef69f5e1.tar.xz
wireguard-openbsd-d91b4a8bf4edcfa53762ea6c56b06991ef69f5e1.zip
- use envelope_set_errormsg() where possible.
- make it use sizeof() rather than a hardcoded limit. ok chl@ gilles@
-rw-r--r--usr.sbin/smtpd/mda.c5
-rw-r--r--usr.sbin/smtpd/mta.c7
-rw-r--r--usr.sbin/smtpd/util.c11
3 files changed, 10 insertions, 13 deletions
diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c
index 0fa9e49be93..ed3ee873ac2 100644
--- a/usr.sbin/smtpd/mda.c
+++ b/usr.sbin/smtpd/mda.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mda.c,v 1.64 2011/12/13 21:44:47 gilles Exp $ */
+/* $OpenBSD: mda.c,v 1.65 2011/12/18 18:43:30 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -201,8 +201,7 @@ mda_imsg(struct imsgev *iev, struct imsg *imsg)
if (error == NULL)
s->msg.status = DS_ACCEPTED;
else
- strlcpy(s->msg.errorline, error,
- sizeof s->msg.errorline);
+ envelope_set_errormsg(&s->msg, "%s", error);
imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_MESSAGE_UPDATE, 0, 0, -1, &s->msg,
sizeof s->msg);
diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c
index c362a2fdcc0..46163a80942 100644
--- a/usr.sbin/smtpd/mta.c
+++ b/usr.sbin/smtpd/mta.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta.c,v 1.120 2011/12/11 17:02:10 eric Exp $ */
+/* $OpenBSD: mta.c,v 1.121 2011/12/18 18:43:30 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -137,8 +137,7 @@ mta_imsg(struct imsgev *iev, struct imsg *imsg)
if (e == NULL)
fatal(NULL);
*e = *(struct envelope *)imsg->data;
- strlcpy(e->errorline, "000 init",
- sizeof(e->errorline));
+ envelope_set_errormsg(e, "000 init");
if (s->host == NULL) {
s->host = strdup(e->dest.domain);
@@ -682,7 +681,7 @@ mta_message_status(struct envelope *e, char *status)
/* change status */
log_debug("mta: new status for %s@%s: %s", e->dest.user,
e->dest.domain, status);
- strlcpy(e->errorline, status, sizeof(e->errorline));
+ envelope_set_errormsg(e, "%s", status);
}
static void
diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c
index a36eda191d6..c76bca0aadc 100644
--- a/usr.sbin/smtpd/util.c
+++ b/usr.sbin/smtpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.52 2011/12/11 19:58:09 eric Exp $ */
+/* $OpenBSD: util.c,v 1.53 2011/12/18 18:43:30 eric Exp $ */
/*
* Copyright (c) 2000,2001 Markus Friedl. All rights reserved.
@@ -417,16 +417,15 @@ envelope_set_errormsg(struct envelope *e, char *fmt, ...)
va_list ap;
va_start(ap, fmt);
-
- ret = vsnprintf(e->errorline, MAX_LINE_SIZE, fmt, ap);
- if (ret >= MAX_LINE_SIZE)
- strlcpy(e->errorline + (MAX_LINE_SIZE - 4), "...", 4);
+ ret = vsnprintf(e->errorline, sizeof(e->errorline), fmt, ap);
+ va_end(ap);
/* this should not happen */
if (ret == -1)
err(1, "vsnprintf");
- va_end(ap);
+ if ((size_t)ret >= sizeof(e->errorline))
+ strlcpy(e->errorline + (sizeof(e->errorline) - 4), "...", 4);
}
char *