Check number of arguments before trying to read arg0. This prevents access

to arg0 and dumping core when `gpart bootcode` called without arguments.
This commit is contained in:
Andrey V. Elsukov 2010-12-21 17:24:32 +00:00
parent d26b794591
commit 5c98f5b0da

View File

@ -1133,6 +1133,8 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl)
geom_deletetree(&mesh);
errx(EXIT_FAILURE, "Class %s not found.", s);
}
if (gctl_get_int(req, "nargs") != 1)
errx(EXIT_FAILURE, "Invalid number of arguments.");
s = gctl_get_ascii(req, "arg0");
if (s == NULL)
abort();