Date: Tue, 25 Nov 2008 20:28:33 +0000 (UTC) From: Ulf Lilleengen <lulf@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r185318 - head/sys/geom Message-ID: <200811252028.mAPKSXnZ034315@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: lulf Date: Tue Nov 25 20:28:33 2008 New Revision: 185318 URL: http://svn.freebsd.org/changeset/base/185318 Log: - Fix a potential NULL pointer reference. Note that this should not happen in practice, but it is a good programming practice and allows the kernel to not depend on userland correctness. - While there, make sizeof usage match the rest of the code. Found with: Coverity Prevent(tm) CID: 660, 662 Modified: head/sys/geom/geom_ccd.c Modified: head/sys/geom/geom_ccd.c ============================================================================== --- head/sys/geom/geom_ccd.c Tue Nov 25 20:02:47 2008 (r185317) +++ head/sys/geom/geom_ccd.c Tue Nov 25 20:28:33 2008 (r185318) @@ -709,8 +709,20 @@ g_ccd_create(struct gctl_req *req, struc g_topology_assert(); unit = gctl_get_paraml(req, "unit", sizeof (*unit)); + if (unit == NULL) { + gctl_error(req, "unit parameter not given"); + return; + } ileave = gctl_get_paraml(req, "ileave", sizeof (*ileave)); + if (ileave == NULL) { + gctl_error(req, "ileave parameter not given"); + return; + } nprovider = gctl_get_paraml(req, "nprovider", sizeof (*nprovider)); + if (nprovider == NULL) { + gctl_error(req, "nprovider parameter not given"); + return; + } /* Check for duplicate unit */ LIST_FOREACH(gp, &mp->geom, geom) { @@ -838,7 +850,11 @@ g_ccd_list(struct gctl_req *req, struct struct g_geom *gp; int i, unit, *up; - up = gctl_get_paraml(req, "unit", sizeof (int)); + up = gctl_get_paraml(req, "unit", sizeof (*up)); + if (up == NULL) { + gctl_error(req, "unit parameter not given"); + return; + } unit = *up; sb = sbuf_new_auto(); LIST_FOREACH(gp, &mp->geom, geom) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811252028.mAPKSXnZ034315>