diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-01-03 19:03:40 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-01-03 19:03:40 +0000 |
commit | 26baf139955d7d9b8d03e7775f68609ff098406e (patch) | |
tree | 2ad7b721f31dd1495295d880e2d10ee082a23566 /sbin | |
parent | 2f28c551e1b7dfd0e591c9777600740eff3551d4 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sbin/badsect/badsect.c | 5 |
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; /* |