From da18a8c7eab4075ed1f4a6f799468e0923b678a6 Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Sat, 20 Oct 2012 14:17:19 -0400 Subject: [PATCH] Detect edge case when argc == 0 --- src/frontend/mosh-client.cc | 4 ++++ src/frontend/mosh-server.cc | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/frontend/mosh-client.cc b/src/frontend/mosh-client.cc index a9644e3..69038ec 100644 --- a/src/frontend/mosh-client.cc +++ b/src/frontend/mosh-client.cc @@ -39,6 +39,7 @@ #include "stmclient.h" #include "crypto.h" #include "locale_utils.h" +#include "fatal_assert.h" /* these need to be included last because of conflicting defines */ #include @@ -72,6 +73,9 @@ int main( int argc, char *argv[] ) /* For security, make sure we don't dump core */ Crypto::disable_dumping_core(); + /* Detect edge case */ + fatal_assert( argc > 0 ); + /* Get arguments */ int opt; while ( (opt = getopt( argc, argv, "c" )) != -1 ) { diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index d8be58e..de6d6bf 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -81,6 +81,7 @@ #include "pty_compat.h" #include "select.h" #include "timestamp.h" +#include "fatal_assert.h" #ifndef _PATH_BSHELL #define _PATH_BSHELL "/bin/sh" @@ -159,6 +160,9 @@ int main( int argc, char *argv[] ) /* For security, make sure we don't dump core */ Crypto::disable_dumping_core(); + /* Detect edge case */ + fatal_assert( argc > 0 ); + char *desired_ip = NULL; char *desired_port = NULL; string command_path;