MFC r205656:

Check that gl_pathc is bigger than zero before derefencing gl_pathv.
When gl_pathc == 0, the content of gl_pathv is undefined.

PR:		bin/144761
Submitted by:	David BERARD <contact davidberard fr>
Obtained from:	OpenBSD
This commit is contained in:
delphij 2010-04-01 00:38:38 +00:00
parent cb43f423ed
commit 0ab03ed413

View File

@ -110,10 +110,11 @@ ftpd_popen(char *program, char *type)
flags |= GLOB_LIMIT;
if (glob(argv[argc], flags, NULL, &gl))
gargv[gargc++] = strdup(argv[argc]);
else
else if (gl.gl_pathc > 0) {
for (pop = gl.gl_pathv; *pop && gargc < (MAXGLOBARGS-1);
pop++)
gargv[gargc++] = strdup(*pop);
}
globfree(&gl);
}
gargv[gargc] = NULL;