diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index 2c01b562f3..21ab55195a 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -21,16 +21,13 @@ #include #include #include -#include #include -#include - -#include #include -#include +#include #include #include +#include /** Default control port */ const std::string DEFAULT_TOR_CONTROL = "127.0.0.1:9051"; @@ -273,9 +270,15 @@ std::map ParseTorReplyMapping(const std::string &s) if (j == 3 && value[i] > '3') { j--; } - escaped_value.push_back(strtol(value.substr(i, j).c_str(), nullptr, 8)); + const auto end{i + j}; + uint8_t val{0}; + while (i < end) { + val *= 8; + val += value[i++] - '0'; + } + escaped_value.push_back(char(val)); // Account for automatic incrementing at loop end - i += j - 1; + --i; } else { escaped_value.push_back(value[i]); } diff --git a/test/lint/lint-locale-dependence.sh b/test/lint/lint-locale-dependence.sh index 2531d0b501..18f0a793f0 100755 --- a/test/lint/lint-locale-dependence.sh +++ b/test/lint/lint-locale-dependence.sh @@ -47,7 +47,6 @@ KNOWN_VIOLATIONS=( "src/test/dbwrapper_tests.cpp:.*snprintf" "src/test/fuzz/locale.cpp" "src/test/fuzz/string.cpp" - "src/torcontrol.cpp:.*strtol" "src/util/strencodings.cpp:.*strtoll" "src/util/system.cpp:.*fprintf" )