mirror of
https://github.com/google/cdc-file-transfer.git
synced 2026-09-13 01:10:44 +03:00
[common] Prevent command execution in ExpandPathVariables (#87)
Command execution is not something users would expect. Even though there is no security issue (right now), it's probably better to turn it off.
This commit is contained in:
+4
-1
@@ -219,9 +219,12 @@ absl::Status ExpandPathVariables(std::string* path) {
|
||||
*path = Util::WideToUtf8Str(wchar_expanded);
|
||||
return absl::OkStatus();
|
||||
#else
|
||||
// Exclude command substitution. It.s not what users of this method would
|
||||
// expect and could lead to security issues.
|
||||
wordexp_t res;
|
||||
wordexp(path->c_str(), &res, 0);
|
||||
wordexp(path->c_str(), &res, WRDE_NOCMD);
|
||||
if (res.we_wordc > 1) {
|
||||
wordfree(&res);
|
||||
return absl::InvalidArgumentError(
|
||||
"Path expands to multiple results (did you use * etc. ?");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user