aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/kldxref/kldxref.c
diff options
context:
space:
mode:
authorMaxim Sobolev <sobomax@FreeBSD.org>2004-04-30 00:20:58 +0000
committerMaxim Sobolev <sobomax@FreeBSD.org>2004-04-30 00:20:58 +0000
commitb7abc67ea4c16e284842d1bfbf053b34d860f46e (patch)
tree47877f1b05e6df67d076af1963b411854d839b54 /usr.sbin/kldxref/kldxref.c
parent3c96564d0064982cfcbf729ff7571856cedd4146 (diff)
downloadsrc-b7abc67ea4c16e284842d1bfbf053b34d860f46e.tar.gz
src-b7abc67ea4c16e284842d1bfbf053b34d860f46e.zip
Check that specified in the command line path is actually a directory,
otherwise we are risking to coredump later on.
Notes
Notes: svn path=/head/; revision=128742
Diffstat (limited to 'usr.sbin/kldxref/kldxref.c')
-rw-r--r--usr.sbin/kldxref/kldxref.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/usr.sbin/kldxref/kldxref.c b/usr.sbin/kldxref/kldxref.c
index 1a640ca52446..396cf93df25f 100644
--- a/usr.sbin/kldxref/kldxref.c
+++ b/usr.sbin/kldxref/kldxref.c
@@ -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);