From 5c98f5b0da4f7f420a1397526c457ceb579c5683 Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Tue, 21 Dec 2010 17:24:32 +0000 Subject: [PATCH] Check number of arguments before trying to read arg0. This prevents access to arg0 and dumping core when `gpart bootcode` called without arguments. --- sbin/geom/class/part/geom_part.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c index 482b02950392..2da09ccef37d 100644 --- a/sbin/geom/class/part/geom_part.c +++ b/sbin/geom/class/part/geom_part.c @@ -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();