mirror of https://gitee.com/bigwinds/arangodb
fix underflow in copying code (#10263)
This commit is contained in:
parent
4edc016be8
commit
7eb53e0645
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue