From e0437e4e4e481f77f457b3fc3c8f7185696b767e Mon Sep 17 00:00:00 2001 From: Alex Alabuzhev Date: Sun, 12 Jun 2016 11:57:16 +0000 Subject: [PATCH] #3254 --- far/changelog | 4 ++++ far/execute.cpp | 27 +++++++++++++++++++++------ far/vbuild.m4 | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/far/changelog b/far/changelog index 92fb78462d..b150ec3dc5 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,7 @@ +drkns 12.06.2016 14:55:52 +0200 - build 4703 + +1. 0003254: Far 3.0 build 4700-4702 crashes on long file lists (!&) + drkns 11.06.2016 22:55:07 +0200 - build 4702 1. Ещё одно уточнение работы запускателя. diff --git a/far/execute.cpp b/far/execute.cpp index 02a08551aa..5cb50c5f11 100644 --- a/far/execute.cpp +++ b/far/execute.cpp @@ -341,14 +341,24 @@ static bool FindObject(const string& Module, string &strDest, bool &Internal) */ static bool PartCmdLine(const string& CmdStr, string &strNewCmdStr, string &strNewCmdPar) { - if (Global->Opt->Exec.ComspecConditionRe.Pattern != Global->Opt->Exec.ComspecCondition.Get()) + auto UseFallbackCondition = false; + try { - Global->Opt->Exec.ComspecConditionRe.Re.assign(Global->Opt->Exec.ComspecCondition.Get(), std::regex::optimize); - Global->Opt->Exec.ComspecConditionRe.Pattern = Global->Opt->Exec.ComspecCondition; - } + if (Global->Opt->Exec.ComspecConditionRe.Pattern != Global->Opt->Exec.ComspecCondition.Get()) + { + Global->Opt->Exec.ComspecConditionRe.Re.assign(Global->Opt->Exec.ComspecCondition.Get(), std::regex::optimize); + Global->Opt->Exec.ComspecConditionRe.Pattern = Global->Opt->Exec.ComspecCondition; + } - if (std::regex_search(CmdStr, Global->Opt->Exec.ComspecConditionRe.Re)) - return false; + if (std::regex_search(CmdStr, Global->Opt->Exec.ComspecConditionRe.Re)) + return false; + } + catch(const std::regex_error&) + { + // - regex is provided by user and it might be incorrect + // - string might be too long + UseFallbackCondition = true; + } const auto Begin = CmdStr.cbegin() + CmdStr.find_first_not_of(L' '); const auto End = CmdStr.cend(); @@ -363,6 +373,11 @@ static bool PartCmdLine(const string& CmdStr, string &strNewCmdStr, string &strN InQuotes = !InQuotes; } + if (!InQuotes && UseFallbackCondition && wcschr(L"<>|&", *i)) + { + return false; + } + if (!InQuotes && *i == L' ') { CmdEnd = i; diff --git a/far/vbuild.m4 b/far/vbuild.m4 index fb1e68caa4..209514c639 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -m4_define(BUILD,4702)m4_dnl +m4_define(BUILD,4703)m4_dnl