changeset 14106:1923bb79231f

3953 Calling ::list without specifying the name of the next member causes mdb to core dump Reviewed by: Christopher Siden <christopher.siden@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Dan McDonald <danmcd@nexenta.com>
author Max Grossman <max.grossman@delphix.com>
date Fri, 02 Aug 2013 12:02:33 -0800
parents b7147f4e608b
children 3d9eb655623f
files usr/src/cmd/mdb/common/mdb/mdb_print.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/mdb/common/mdb/mdb_print.c	Tue Apr 09 18:13:34 2013 +0000
+++ b/usr/src/cmd/mdb/common/mdb/mdb_print.c	Fri Aug 02 12:02:33 2013 -0800
@@ -24,7 +24,7 @@
  */
 
 /*
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
  * Copyright (c) 2012 Joyent, Inc. All rights reserved.
  */
 
@@ -707,9 +707,10 @@
 	if (argv->a_type != MDB_TYPE_STRING) {
 		/*
 		 * We are being given a raw offset in lieu of a type and
-		 * member; confirm the arguments.
+		 * member; confirm the number of arguments and argument
+		 * type.
 		 */
-		if (argv->a_type != MDB_TYPE_IMMEDIATE)
+		if (argc != 1 || argv->a_type != MDB_TYPE_IMMEDIATE)
 			return (DCMD_USAGE);
 
 		offset = argv->a_un.a_val;
@@ -726,6 +727,13 @@
 		char buf[MDB_SYM_NAMLEN];
 		int ret;
 
+		/*
+		 * Check that we were provided 2 arguments: a type name
+		 * and a member of that type.
+		 */
+		if (argc != 2)
+			return (DCMD_USAGE);
+
 		ret = args_to_typename(&argc, &argv, buf, sizeof (buf));
 		if (ret != 0)
 			return (ret);