summaryrefslogtreecommitdiffstats
path: root/sbin/geom
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2009-08-16 21:27:35 +0000
committermarcel <marcel@FreeBSD.org>2009-08-16 21:27:35 +0000
commit5519023e6b69969b85d76840bc8fab00688047f4 (patch)
tree54e480eaec90db079973359506ac776370e1f6bc /sbin/geom
parent76b81e06287fed86b0a38cdf26c298ff565c57f6 (diff)
downloadFreeBSD-src-5519023e6b69969b85d76840bc8fab00688047f4.zip
FreeBSD-src-5519023e6b69969b85d76840bc8fab00688047f4.tar.gz
Emit a proper error message instead of dumping core when 1)
GEOM_PART does not exist in the kernel, and 2) the GEOM in question does not exist. Additionally abort in case of programming errors that result in neither the class nor geom not being present in the gctl request. Submitted by: "Andrey V. Elsukov" <bu7cher@yandex.ru> Approved by: re (kib)
Diffstat (limited to 'sbin/geom')
-rw-r--r--sbin/geom/class/part/geom_part.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c
index fc179a4..db3c5e9 100644
--- a/sbin/geom/class/part/geom_part.c
+++ b/sbin/geom/class/part/geom_part.c
@@ -274,8 +274,18 @@ gpart_autofill(struct gctl_req *req)
error = geom_gettree(&mesh);
if (error)
return (error);
- cp = find_class(&mesh, gctl_get_ascii(req, "class"));
- gp = find_geom(cp, gctl_get_ascii(req, "geom"));
+ s = gctl_get_ascii(req, "class");
+ if (s == NULL)
+ abort();
+ cp = find_class(&mesh, s);
+ if (cp == NULL)
+ errx(EXIT_FAILURE, "Class %s not found.", s);
+ s = gctl_get_ascii(req, "geom");
+ if (s == NULL)
+ abort();
+ gp = find_geom(cp, s);
+ if (gp == NULL)
+ errx(EXIT_FAILURE, "No such geom: %s.", s);
first = atoll(find_geomcfg(gp, "first"));
last = atoll(find_geomcfg(gp, "last"));
grade = ~0ULL;
@@ -536,6 +546,8 @@ gpart_write_partcode(struct gctl_req *req, int idx, void *code, ssize_t size)
errx(EXIT_FAILURE, "Class %s not found.", s);
}
s = gctl_get_ascii(req, "geom");
+ if (s == NULL)
+ abort();
gp = find_geom(classp, s);
if (gp == NULL)
errx(EXIT_FAILURE, "No such geom: %s.", s);
OpenPOWER on IntegriCloud