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
This commit is contained in:
truckman 2016-05-13 06:15:05 +00:00
parent 7e4340d511
commit 6957aa1da6

View File

@ -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)