mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
Check that specified in the command line path is actually a directory,
otherwise we are risking to coredump later on.
This commit is contained in:
parent
3c96564d00
commit
b7abc67ea4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=128742
@ -32,6 +32,7 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/queue.h>
|
||||
@ -272,6 +273,7 @@ main(int argc, char *argv[])
|
||||
FTS *ftsp;
|
||||
FTSENT *p;
|
||||
int opt, fts_options, ival;
|
||||
struct stat sb;
|
||||
|
||||
fts_options = FTS_PHYSICAL;
|
||||
/* SLIST_INIT(&kldlist);*/
|
||||
@ -300,6 +302,13 @@ main(int argc, char *argv[])
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (stat(argv[0], &sb) != 0)
|
||||
err(1, "%s", argv[0]);
|
||||
if ((sb.st_mode & S_IFDIR) == 0) {
|
||||
errno = ENOTDIR;
|
||||
err(1, "%s", argv[0]);
|
||||
}
|
||||
|
||||
ftsp = fts_open(argv, fts_options, 0);
|
||||
if (ftsp == NULL)
|
||||
exit(1);
|
||||
|
Loading…
Reference in New Issue
Block a user