From 50e307aa7f5759dc87abadded85318be68ea4299 Mon Sep 17 00:00:00 2001 From: gilles Date: Tue, 6 Oct 2015 08:51:35 +0000 Subject: [PATCH] we don't need this temporary buffer since we're going to strdup() it right away anyways ok eric@ --- usr.sbin/smtpd/smtpd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index abc3856ee84..0efe70716d9 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.241 2015/10/06 06:04:46 gilles Exp $ */ +/* $OpenBSD: smtpd.c,v 1.242 2015/10/06 08:51:35 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -1048,19 +1048,22 @@ offline_scan(int fd, short ev, void *arg) static int offline_enqueue(char *name) { - char t[PATH_MAX], *path; + char *path; struct stat sb; pid_t pid; struct child *child; struct passwd *pw; + int pathlen; - if (!bsnprintf(t, sizeof t, "%s/%s", PATH_SPOOL PATH_OFFLINE, name)) { - log_warnx("warn: smtpd: path name too long"); + pathlen = asprintf(&path, "%s/%s", PATH_SPOOL PATH_OFFLINE, name); + if (pathlen == -1) { + log_warnx("warn: smtpd: asprintf"); return (-1); } - if ((path = strdup(t)) == NULL) { - log_warn("warn: smtpd: strdup"); + if (pathlen >= PATH_MAX) { + log_warnx("warn: smtpd: pathname exceeds PATH_MAX"); + free(path); return (-1); } -- 2.20.1