changeset 4717:20ba35462dba

6579753 segmentation fault if zfs mount -o with very long options 6579780 zfs mount -o <invalid dataset> should report an error but does not
author rm160521
date Tue, 24 Jul 2007 10:57:04 -0700
parents c06a3889ba02
children 4e06f379632e
files usr/src/cmd/zfs/zfs_main.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/zfs/zfs_main.c	Tue Jul 24 10:39:52 2007 -0700
+++ b/usr/src/cmd/zfs/zfs_main.c	Tue Jul 24 10:57:04 2007 -0700
@@ -3019,8 +3019,16 @@
 			do_all = 1;
 			break;
 		case 'o':
-			options = optarg;
+			if (strlen(optarg) <= MNT_LINE_MAX) {
+				options = optarg;
+				break;
+			}
+			(void) fprintf(stderr, gettext("the opts argument for "
+			    "'%c' option is too long (more than %d chars)\n"),
+			    optopt, MNT_LINE_MAX);
+			usage(B_FALSE);
 			break;
+
 		case 'O':
 			flags |= MS_OVERLAY;
 			break;
@@ -3086,9 +3094,9 @@
 	} else if (argc == 0) {
 		struct mnttab entry;
 
-		if (op == OP_SHARE) {
+		if ((op == OP_SHARE) || (options != NULL)) {
 			(void) fprintf(stderr, gettext("missing filesystem "
-			    "argument\n"));
+			    "argument (specify -a for all)\n"));
 			usage(B_FALSE);
 		}