diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2011-12-18 18:43:31 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2011-12-18 18:43:31 +0000 |
commit | 95ece4d7a3f30a21320901b87ca4e068505cfa84 (patch) | |
tree | 3b14b7fb088bcbd99783ca6b38cddcf09147a9fd /usr.sbin/smtpd/util.c | |
parent | 6cf7544bfe16414bf7f964a06f6a085f7505f5f4 (diff) |
- use envelope_set_errormsg() where possible.
- make it use sizeof() rather than a hardcoded limit.
ok chl@ gilles@
Diffstat (limited to 'usr.sbin/smtpd/util.c')
-rw-r--r-- | usr.sbin/smtpd/util.c | 11 |
1 files changed, 5 insertions, 6 deletions
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 * |