[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[dm-devel] Avoiding lvm shell crashes on white space only line



Hi all,

  lvm shell crashes on white-space only lines.

===>
# lvm
lvm>      <== white spaces
Segmentation fault (core dumped)
<===

  lvm always assuming that argv[0] is accessible. Here's attached a
tentative fix for this issue.
Please consider it for upstream conclusion. ;)

  Thanks
diff --git a/tools/lvm.c b/tools/lvm.c
index d1c2f9b..782b642 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -217,6 +217,11 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline)
 			continue;
 		}
 
+		if (argc == 0) {
+			log_debug("Empty input, sorry.");
+			continue;
+		}
+
 		if (!strcmp(argv[0], "lvm")) {
 			argv++;
 			argc--;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]