Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 May 2016 06:15:05 +0000 (UTC)
From:      Don Lewis <truckman@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r299591 - head/usr.bin/mail
Message-ID:  <201605130615.u4D6F5Im021575@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: truckman
Date: Fri May 13 06:15:05 2016
New Revision: 299591
URL: https://svnweb.freebsd.org/changeset/base/299591

Log:
  Always return either a dynamically allocated string or NULL from
  expand().  Never return the name parameter, which could be a the buf[]
  buffer which is allocated on the stack by getdeadletter() and which
  would then be used after getdeadletter() has returned.
  
  Reported by:	Coverity
  CID:		1199383
  MFC after:	1 week

Modified:
  head/usr.bin/mail/fio.c

Modified: head/usr.bin/mail/fio.c
==============================================================================
--- head/usr.bin/mail/fio.c	Fri May 13 05:57:21 2016	(r299590)
+++ head/usr.bin/mail/fio.c	Fri May 13 06:15:05 2016	(r299591)
@@ -367,10 +367,10 @@ expand(char *name)
 		name = savestr(xname);
 	}
 	if (!strpbrk(name, "~{[*?$`'\"\\"))
-		return (name);
+		return (savestr(name));
 	if (pipe(pivec) < 0) {
 		warn("pipe");
-		return (name);
+		return (NULL);
 	}
 	(void)snprintf(cmdbuf, sizeof(cmdbuf), "echo %s", name);
 	if ((sh = value("SHELL")) == NULL)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605130615.u4D6F5Im021575>