summaryrefslogtreecommitdiffstats
path: root/sbin/badsect
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-01-03 19:03:40 +0000
committerrwatson <rwatson@FreeBSD.org>2005-01-03 19:03:40 +0000
commit26baf139955d7d9b8d03e7775f68609ff098406e (patch)
tree2ad7b721f31dd1495295d880e2d10ee082a23566 /sbin/badsect
parent2f28c551e1b7dfd0e591c9777600740eff3551d4 (diff)
downloadFreeBSD-src-26baf139955d7d9b8d03e7775f68609ff098406e.zip
FreeBSD-src-26baf139955d7d9b8d03e7775f68609ff098406e.tar.gz
The badsect(8) utility uses atol(), which doesn't allow very good error
checking and only recognizes numbers in base 10. The attached patch checks errno after strtol() and uses a base of 0 to allow octal, or hex sector numbers too. PR: 73112 Submitted by: keramida MFC after: 2 weeks
Diffstat (limited to 'sbin/badsect')
-rw-r--r--sbin/badsect/badsect.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sbin/badsect/badsect.c b/sbin/badsect/badsect.c
index 96c319d..9389171 100644
--- a/sbin/badsect/badsect.c
+++ b/sbin/badsect/badsect.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <ufs/ffs/fs.h>
#include <err.h>
+#include <errno.h>
#include <dirent.h>
#include <fcntl.h>
#include <libufs.h>
@@ -123,7 +124,9 @@ main(int argc, char *argv[])
err(7, "%s", name);
}
for (argc -= 2, argv += 2; argc > 0; argc--, argv++) {
- number = atol(*argv);
+ number = strtol(*argv, NULL, 0);
+ if (errno == EINVAL || errno == ERANGE)
+ err(8, "%s", *argv);
if (chkuse(number, 1))
continue;
/*
OpenPOWER on IntegriCloud