summaryrefslogtreecommitdiff
path: root/sbin/ncheck_ffs/ncheck_ffs.c
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2007-07-09 17:12:18 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2007-07-09 17:12:18 +0000
commit413195415205e807919dfe6a6c1604f720e8301c (patch)
tree421ec4343e4bfdcf767ba69d419c1849ed2a7cf8 /sbin/ncheck_ffs/ncheck_ffs.c
parent06a154af2a72305710f4f8ba5d842c6f423e9930 (diff)
correct a typo in an error message.
use realpath(3) to sanitize the path we're going to work with, prevents silly errors when passing ncheck_ffs paths from the shell with a trailing '/' since that doesnt match the entry in fstab. ok deraadt@,krw@
Diffstat (limited to 'sbin/ncheck_ffs/ncheck_ffs.c')
-rw-r--r--sbin/ncheck_ffs/ncheck_ffs.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/sbin/ncheck_ffs/ncheck_ffs.c b/sbin/ncheck_ffs/ncheck_ffs.c
index 2c8bc358361..04fb1a04582 100644
--- a/sbin/ncheck_ffs/ncheck_ffs.c
+++ b/sbin/ncheck_ffs/ncheck_ffs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ncheck_ffs.c,v 1.31 2007/06/29 03:37:09 deraadt Exp $ */
+/* $OpenBSD: ncheck_ffs.c,v 1.32 2007/07/09 17:12:17 thib Exp $ */
/*-
* Copyright (c) 1995, 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
@@ -55,7 +55,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: ncheck_ffs.c,v 1.31 2007/06/29 03:37:09 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: ncheck_ffs.c,v 1.32 2007/07/09 17:12:17 thib Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -81,6 +81,7 @@ static const char rcsid[] = "$OpenBSD: ncheck_ffs.c,v 1.31 2007/06/29 03:37:09 d
((struct ufs2_dinode *)(dp))->field)
char *disk; /* name of the disk file */
+char rdisk[PATH_MAX];/* resolved name of the disk file */
int diskfd; /* disk file descriptor */
struct fs *sblock; /* the file system super block */
char sblock_buf[MAXBSIZE];
@@ -495,7 +496,7 @@ main(int argc, char *argv[])
struct fstab *fsp;
unsigned long ulval;
ssize_t n;
- char *ep;
+ char *ep, *odisk;
int c, i;
while ((c = getopt(argc, argv, "af:i:ms")) != -1)
@@ -544,7 +545,10 @@ main(int argc, char *argv[])
if (optind != argc - 1 || (mflag && format))
usage();
- disk = argv[optind];
+ odisk = argv[optind];
+ if (realpath(odisk, rdisk) == NULL)
+ err(1, "cannot find real path for %s", odisk);
+ disk = rdisk;
if (stat(disk, &stblock) < 0)
err(1, "cannot stat %s", disk);
@@ -553,7 +557,7 @@ main(int argc, char *argv[])
disk = rawname(disk);
} else if (!S_ISCHR(stblock.st_mode)) {
if ((fsp = getfsfile(disk)) == NULL)
- err(1, "cound not find file system %s", disk);
+ err(1, "could not find file system %s", disk);
disk = rawname(fsp->fs_spec);
}