From owner-svn-src-all@FreeBSD.ORG Tue Nov 25 19:13:58 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7F54C1065672; Tue, 25 Nov 2008 19:13:58 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6EB528FC1C; Tue, 25 Nov 2008 19:13:58 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mAPJDwOx032242; Tue, 25 Nov 2008 19:13:58 GMT (envelope-from lulf@svn.freebsd.org) Received: (from lulf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mAPJDwrD032237; Tue, 25 Nov 2008 19:13:58 GMT (envelope-from lulf@svn.freebsd.org) Message-Id: <200811251913.mAPJDwrD032237@svn.freebsd.org> From: Ulf Lilleengen Date: Tue, 25 Nov 2008 19:13:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185309 - head/sys/geom/vinum X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Nov 2008 19:13:58 -0000 Author: lulf Date: Tue Nov 25 19:13:58 2008 New Revision: 185309 URL: http://svn.freebsd.org/changeset/base/185309 Log: - Fix a potential NULL pointer reference. Note that this cannot happen in practice, but it is a good programming practice nontheless and it allows the kernel to not depend on userland correctness. Found with: Coverity Prevent(tm) CID: 655-659, 664-667 Modified: head/sys/geom/vinum/geom_vinum.c head/sys/geom/vinum/geom_vinum_list.c head/sys/geom/vinum/geom_vinum_move.c head/sys/geom/vinum/geom_vinum_rename.c head/sys/geom/vinum/geom_vinum_rm.c Modified: head/sys/geom/vinum/geom_vinum.c ============================================================================== --- head/sys/geom/vinum/geom_vinum.c Tue Nov 25 19:06:20 2008 (r185308) +++ head/sys/geom/vinum/geom_vinum.c Tue Nov 25 19:13:58 2008 (r185309) @@ -165,12 +165,20 @@ gv_create(struct g_geom *gp, struct gctl plexes = gctl_get_paraml(req, "plexes", sizeof(*plexes)); subdisks = gctl_get_paraml(req, "subdisks", sizeof(*subdisks)); drives = gctl_get_paraml(req, "drives", sizeof(*drives)); + if (volumes == NULL || plexes == NULL || subdisks == NULL || + drives == NULL) { + gctl_error(req, "number of objects not given"); + return (-1); + } /* First, handle drive definitions ... */ for (i = 0; i < *drives; i++) { snprintf(buf, sizeof(buf), "drive%d", i); d2 = gctl_get_paraml(req, buf, sizeof(*d2)); - + if (d2 == NULL) { + gctl_error(req, "no drive definition given"); + return (-1); + } d = gv_find_drive(sc, d2->name); if (d != NULL) { gctl_error(req, "drive '%s' is already known", @@ -205,7 +213,10 @@ gv_create(struct g_geom *gp, struct gctl error = 0; snprintf(buf, sizeof(buf), "volume%d", i); v2 = gctl_get_paraml(req, buf, sizeof(*v2)); - + if (v2 == NULL) { + gctl_error(req, "no volume definition given"); + return (-1); + } v = gv_find_vol(sc, v2->name); if (v != NULL) { gctl_error(req, "volume '%s' is already known", @@ -226,7 +237,10 @@ gv_create(struct g_geom *gp, struct gctl error = 0; snprintf(buf, sizeof(buf), "plex%d", i); p2 = gctl_get_paraml(req, buf, sizeof(*p2)); - + if (p2 == NULL) { + gctl_error(req, "no plex definition given"); + return (-1); + } p = gv_find_plex(sc, p2->name); if (p != NULL) { gctl_error(req, "plex '%s' is already known", p->name); @@ -260,7 +274,10 @@ gv_create(struct g_geom *gp, struct gctl error = 0; snprintf(buf, sizeof(buf), "sd%d", i); s2 = gctl_get_paraml(req, buf, sizeof(*s2)); - + if (s2 == NULL) { + gctl_error(req, "no subdisk definition given"); + return (-1); + } s = gv_find_sd(sc, s2->name); if (s != NULL) { gctl_error(req, "subdisk '%s' is already known", @@ -405,7 +422,10 @@ gv_config(struct gctl_req *req, struct g /* Return configuration in string form. */ } else if (!strcmp(verb, "getconfig")) { comment = gctl_get_param(req, "comment", NULL); - + if (comment == NULL) { + gctl_error(req, "no comment parameter given"); + return; + } sb = sbuf_new(NULL, NULL, GV_CFG_LEN, SBUF_FIXEDLEN); gv_format_config(sc, sb, 0, comment); sbuf_finish(sb); Modified: head/sys/geom/vinum/geom_vinum_list.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_list.c Tue Nov 25 19:06:20 2008 (r185308) +++ head/sys/geom/vinum/geom_vinum_list.c Tue Nov 25 19:13:58 2008 (r185309) @@ -62,6 +62,10 @@ gv_list(struct g_geom *gp, struct gctl_r } flags = gctl_get_paraml(req, "flags", sizeof(*flags)); + if (flags == NULL) { + gctl_error(req, "no flags given"); + return; + } sc = gp->softc; @@ -69,6 +73,10 @@ gv_list(struct g_geom *gp, struct gctl_r /* Figure out which command was given. */ cmd = gctl_get_param(req, "cmd", NULL); + if (cmd == NULL) { + gctl_error(req, "no command given"); + return; + } /* List specific objects or everything. */ if (!strcmp(cmd, "list") || !strcmp(cmd, "l")) { Modified: head/sys/geom/vinum/geom_vinum_move.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_move.c Tue Nov 25 19:06:20 2008 (r185308) +++ head/sys/geom/vinum/geom_vinum_move.c Tue Nov 25 19:13:58 2008 (r185309) @@ -56,7 +56,15 @@ gv_move(struct g_geom *gp, struct gctl_r sc = gp->softc; argc = gctl_get_paraml(req, "argc", sizeof(*argc)); + if (argc == NULL) { + gctl_error(req, "no arguments given"); + return; + } flags = gctl_get_paraml(req, "flags", sizeof(*flags)); + if (flags == NULL) { + gctl_error(req, "no flags given"); + return; + } destination = gctl_get_param(req, "destination", NULL); if (destination == NULL) { gctl_error(req, "no destination given"); Modified: head/sys/geom/vinum/geom_vinum_rename.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_rename.c Tue Nov 25 19:06:20 2008 (r185308) +++ head/sys/geom/vinum/geom_vinum_rename.c Tue Nov 25 19:13:58 2008 (r185309) @@ -65,6 +65,10 @@ gv_rename(struct g_geom *gp, struct gctl sc = gp->softc; flags = gctl_get_paraml(req, "flags", sizeof(*flags)); + if (flags == NULL) { + gctl_error(req, "no flags given"); + return; + } newname = gctl_get_param(req, "newname", NULL); if (newname == NULL) { Modified: head/sys/geom/vinum/geom_vinum_rm.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_rm.c Tue Nov 25 19:06:20 2008 (r185308) +++ head/sys/geom/vinum/geom_vinum_rm.c Tue Nov 25 19:13:58 2008 (r185309) @@ -59,13 +59,18 @@ gv_remove(struct g_geom *gp, struct gctl int i, type, err; argc = gctl_get_paraml(req, "argc", sizeof(*argc)); - flags = gctl_get_paraml(req, "flags", sizeof(*flags)); if (argc == NULL || *argc == 0) { gctl_error(req, "no arguments given"); return; } + flags = gctl_get_paraml(req, "flags", sizeof(*flags)); + if (flags == NULL) { + gctl_error(req, "no flags given"); + return; + } + sc = gp->softc; for (i = 0; i < *argc; i++) {