diff options
author | cflip <cflip@cflip.net> | 2022-09-20 11:08:11 -0600 |
---|---|---|
committer | cflip <cflip@cflip.net> | 2022-09-20 11:10:47 -0600 |
commit | ce173bd3d1c66f937a958419a2c82786404e0d2e (patch) | |
tree | 3a3ae72125c42ade78ee29e14009dd612713772e /src/main.cpp | |
parent | 08a43acee041e6de83c5b9e8c16265fa2de0983e (diff) |
Validate CGI script paths before starting up the server
This still doesn't throw up an error when attepting to run scripts
without the leading './', but it's a start
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 89a8139..ee7c673 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,7 @@ #include <filesystem> #include <fstream> #include <iostream> +#include <sstream> #include "CGIScript.h" #include "ClientConnection.h" @@ -115,6 +116,11 @@ int main(int argc, char** argv) } } + // Check the script path to ensure that it is a valid executable + // script before attempting to start the server. + if (in_cgi_mode) + CGIScript::validate_path(cgi_program_name); + ServerConnection server(port); std::cout << "Serving a " << (in_cgi_mode ? "CGI script" : "directory") << " on port " << port << std::endl; |