TS-898: fix minor regex_remap parsing bug If the line contains only whitespace, don't index into the string.
Coverity #1021882 Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/c945682e Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/c945682e Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/c945682e Branch: refs/heads/5.0.x Commit: c945682e7c746b3036b64527b03b886a2b23dc14 Parents: ba6d0c7 Author: James Peach <[email protected]> Authored: Sat Apr 12 12:23:01 2014 -0700 Committer: James Peach <[email protected]> Committed: Sat Apr 12 12:36:27 2014 -0700 ---------------------------------------------------------------------- CHANGES | 2 ++ plugins/regex_remap/regex_remap.cc | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c945682e/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index a276d93..8c6e195 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ -*- coding: utf-8 -*- Changes with Apache Traffic Server 5.0.0 + *) [TS-898] Fix minor regex_remap parsing bug. + *) [TS-2711] Include Lua JIT as a Submodule. *) [TS-898] Ensure the cache span probe always closes file descriptors. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c945682e/plugins/regex_remap/regex_remap.cc ---------------------------------------------------------------------- diff --git a/plugins/regex_remap/regex_remap.cc b/plugins/regex_remap/regex_remap.cc index 416f90c..efd3d24 100644 --- a/plugins/regex_remap/regex_remap.cc +++ b/plugins/regex_remap/regex_remap.cc @@ -733,12 +733,14 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED if (line.empty()) { continue; } - pos1 = line.find_first_not_of(" \t\n"); - if (line[pos1] == '#') { - continue; // Skip comment lines - } + pos1 = line.find_first_not_of(" \t\n"); if (pos1 != std::string::npos) { + + if (line[pos1] == '#') { + continue; // Skip comment lines + } + pos2 = line.find_first_of(" \t\n", pos1); if (pos2 != std::string::npos) { regex = line.substr(pos1, pos2-pos1);
