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
This commit is contained in:
Robert Watson 2005-01-03 19:03:40 +00:00
parent 7bb84191e6
commit d266903483

View File

@ -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;
/*