From 26baf139955d7d9b8d03e7775f68609ff098406e Mon Sep 17 00:00:00 2001 From: rwatson Date: Mon, 3 Jan 2005 19:03:40 +0000 Subject: 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 --- sbin/badsect/badsect.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sbin/badsect') 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 #include +#include #include #include #include @@ -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; /* -- cgit v1.1