Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Aug 2009 21:32:12 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r196279 - in stable/8/sbin/geom: . class/part
Message-ID:  <200908162132.n7GLWCGm032669@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Sun Aug 16 21:32:12 2009
New Revision: 196279
URL: http://svn.freebsd.org/changeset/base/196279

Log:
  MFC change 196278:
   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.
  
  Approved by:	re (kib)

Modified:
  stable/8/sbin/geom/   (props changed)
  stable/8/sbin/geom/class/part/geom_part.c

Modified: stable/8/sbin/geom/class/part/geom_part.c
==============================================================================
--- stable/8/sbin/geom/class/part/geom_part.c	Sun Aug 16 21:27:35 2009	(r196278)
+++ stable/8/sbin/geom/class/part/geom_part.c	Sun Aug 16 21:32:12 2009	(r196279)
@@ -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 *re
 		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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908162132.n7GLWCGm032669>