Lift scope of buf[] to make it extend to a potential access via *basename

It can be assumed that the contents of the buffer was still allocated and
valid at the point of the out-of-scope access, so there was no security
issue in practice.

Reported by:	Coverity Scan CID 1437697
MFC after:	3 days
This commit is contained in:
Stefan Eßer 2020-12-10 09:31:05 +00:00
parent bb24ee2b7e
commit 7483b9e4dc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=368503

View File

@ -114,6 +114,7 @@ main(int argc, char **argv, char **envp)
{
struct stub *ep = NULL;
const char *basename = NULL;
char buf[MAXPATHLEN];
/*
* Look at __progname first (this will be set if the crunched binary is
@ -141,7 +142,6 @@ main(int argc, char **argv, char **envp)
* try AT_EXECPATH to get the actual binary that was executed.
*/
if (ep == NULL) {
char buf[MAXPATHLEN];
int error = elf_aux_info(AT_EXECPATH, &buf, sizeof(buf));
if (error == 0) {