1
0
Fork 0

fix underflow in copying code (#10263)

This commit is contained in:
Jan 2019-10-16 15:23:28 +02:00 committed by KVS85
parent 4edc016be8
commit 7eb53e0645
2 changed files with 28 additions and 25 deletions

View File

@ -507,7 +507,6 @@ void V8DealerFeature::copyInstallationFiles() {
// don't copy files in .bin // don't copy files in .bin
return true; return true;
} }
if (filename.size() >= nodeModulesPath.size()) {
std::string normalized = filename; std::string normalized = filename;
FileUtils::normalizePath(normalized); FileUtils::normalizePath(normalized);
if ((!nodeModulesPath.empty() && if ((!nodeModulesPath.empty() &&
@ -519,7 +518,6 @@ void V8DealerFeature::copyInstallationFiles() {
// filter it out! // filter it out!
return true; return true;
} }
}
// let the file/directory pass through // let the file/directory pass through
return false; return false;
}; };

View File

@ -276,19 +276,24 @@ void V8ShellFeature::copyInstallationFiles() {
std::string const nodeModulesPathVersioned = std::string const nodeModulesPathVersioned =
basics::FileUtils::buildFilename("js", versionAppendix, "node", basics::FileUtils::buildFilename("js", versionAppendix, "node",
"node_modules"); "node_modules");
auto filter = [&nodeModulesPath, std::regex const binRegex("[/\\\\]\\.bin[/\\\\]", std::regex::ECMAScript);
&nodeModulesPathVersioned](std::string const& filename) -> bool {
if (filename.size() >= nodeModulesPath.size()) { auto filter = [&nodeModulesPath, &nodeModulesPathVersioned, &binRegex](std::string const& filename) -> bool {
std::string normalized = filename; if (std::regex_search(filename, binRegex)) {
FileUtils::normalizePath(normalized); // don't copy files in .bin
TRI_ASSERT(filename.size() == normalized.size());
if (normalized.substr(normalized.size() - nodeModulesPath.size(),
nodeModulesPath.size()) == nodeModulesPath ||
normalized.substr(normalized.size() - nodeModulesPathVersioned.size(),
nodeModulesPathVersioned.size()) == nodeModulesPathVersioned) {
// filter it out!
return true; return true;
} }
std::string normalized = filename;
FileUtils::normalizePath(normalized);
if ((!nodeModulesPath.empty() &&
normalized.size() >= nodeModulesPath.size() &&
normalized.substr(normalized.size() - nodeModulesPath.size(), nodeModulesPath.size()) == nodeModulesPath) ||
(!nodeModulesPathVersioned.empty() &&
normalized.size() >= nodeModulesPathVersioned.size() &&
normalized.substr(normalized.size() - nodeModulesPathVersioned.size(), nodeModulesPathVersioned.size()) == nodeModulesPathVersioned)) {
// filter it out!
return true;
} }
// let the file/directory pass through // let the file/directory pass through
return false; return false;