--- res/res_agi.c 2005-12-12 18:11:58.000000000 -0600 +++ res/res_agi.c.7446 2005-12-12 18:02:27.000000000 -0600 @@ -38,6 +38,7 @@ #include #include #include +#include #include "asterisk.h" @@ -224,7 +225,8 @@ int x; int res; sigset_t signal_set; - + struct stat statbuf; + if (!strncasecmp(script, "agi://", 6)) return launch_netscript(script, argv, fds, efd, opid); @@ -232,6 +234,14 @@ snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_AGI_DIR, script); script = tmp; } + if (stat(script, &statbuf) < 0) { + ast_log(LOG_WARNING, "Unable to execute %s: File does not exist\n", script); + return -1; + } + if (!(statbuf.st_mode & S_IXUSR)) { + ast_log(LOG_WARNING, "Unable to execute %s: File is not executable\n", script); + return -1; + } if (pipe(toast)) { ast_log(LOG_WARNING, "Unable to create toast pipe: %s\n",strerror(errno)); return -1;