From: Justin Cinkelj <justin.cink...@xlab.si>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

command line: check for empty cmdline case after parsing cmdline

Always parse app_cmdline. It there is nothing to run, commands array
will be empty.

Signed-off-by: Justin Cinkelj <justin.cink...@xlab.si>
Message-Id: <20170913120516.17024-7-justin.cink...@xlab.si>

---
diff --git a/loader.cc b/loader.cc
--- a/loader.cc
+++ b/loader.cc
@@ -295,10 +295,6 @@ void parse_options(int loader_argc, char** loader_argv)
 // return the std::string and the commands_args poiting to them as a move
 std::vector<std::vector<std::string> > prepare_commands(char* app_cmdline)
 {
-    if (strlen(app_cmdline) == 0) {
-        puts("This image has an empty command line. Nothing to run.");
-        osv::poweroff();
-    }
     std::vector<std::vector<std::string> > commands;
     bool ok;

@@ -308,6 +304,10 @@ std::vector<std::vector<std::string> > prepare_commands(char* app_cmdline)
         puts("Failed to parse command line.");
         osv::poweroff();
     }
+    if (commands.size() == 0) {
+        puts("This image has an empty command line. Nothing to run.");
+        osv::poweroff();
+    }

     return commands;
 }

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to