From: Pierre Pronchery Date: Thu, 28 Dec 2017 07:37:09 +0000 (+0100) Subject: Avoid a crash in "script list" (#521) X-Git-Tag: v3.1.0~98 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/0f112d6f19ecf6e7d443eaf3464ebf916048be59?ds=inline;hp=-c Avoid a crash in "script list" (#521) This command crashes if the path to the executable directory could not be found. --- 0f112d6f19ecf6e7d443eaf3464ebf916048be59 diff --git a/client/cmdscript.c b/client/cmdscript.c index 23163aa9..0d19f496 100644 --- a/client/cmdscript.c +++ b/client/cmdscript.c @@ -76,8 +76,11 @@ int CmdList(const char *Cmd) { DIR *dp; struct dirent *ep; - char script_directory_path[strlen(get_my_executable_directory()) + strlen(LUA_SCRIPTS_DIRECTORY) + 1]; - strcpy(script_directory_path, get_my_executable_directory()); + char const * exedir = get_my_executable_directory(); + if (exedir == NULL) + return 0; + char script_directory_path[strlen(exedir) + strlen(LUA_SCRIPTS_DIRECTORY) + 1]; + strcpy(script_directory_path, exedir); strcat(script_directory_path, LUA_SCRIPTS_DIRECTORY); dp = opendir(script_directory_path);