Address Daira's further comments

This commit is contained in:
Jack Grigg
2017-04-21 13:15:39 +12:00
parent 0b431fbdb5
commit d15cab21bc
2 changed files with 11 additions and 1 deletions

View File

@@ -327,7 +327,7 @@ static std::map<std::string,std::string> ParseTorReplyMapping(const std::string
// Octal escape sequences have a limit of three octal digits,
// but terminate at the first character that is not a valid
// octal digit if encountered sooner.
for (j = 1; '0' <= value[i+j] && value[i+j] <= '7' && j < 3; ++j) {}
for (j = 1; j < 3 && (i+j) < value.size() && '0' <= value[i+j] && value[i+j] <= '7'; ++j) {}
// Tor restricts first digit to 0-3 for three-digit octals.
if (j < 3 || ('0' <= value[i] && value[i] <= '3')) {
escaped_value.push_back(strtol(value.substr(i, j).c_str(), NULL, 8));