On a Linux platform, I have C++ code that goes like this:
// ...
std::string myDir;
myDir = argv[1]; // myDir is initialized using user input from the command line.
std::string command;
command = "mkdir " + myDir;
if (system(command.c_str()) != 0) {
return 1;
}
// continue....
- Is passing user input to a system() call safe at all?
- Should the user input be escaped / sanitized?
- How?
- How could the above code be exploited for malicious purposes?
Thanks.