traeak commented on code in PR #13837:
URL: https://github.com/apache/trafficserver/pull/13837#discussion_r4276072865
##########
src/proxy/http/remap/NextHopStrategyFactory.cc:
##########
@@ -251,17 +251,27 @@ NextHopStrategyFactory::loadConfigFile(const std::string
&fileName, std::strings
std::ifstream file(fileName);
if (file.is_open()) {
while (std::getline(file, line)) {
- if (line[0] == '#') {
- tok = strtok_r(const_cast<char *>(line.c_str()), sep, &last);
- if (tok != nullptr && strcmp(tok, "#include") == 0) {
- std::string f = strtok_r(nullptr, sep, &last);
+ std::string_view line_view{line};
+ if (line_view.starts_with('#')) {
+ const auto directive_end = line_view.find_first_of(separators);
+ if (line_view.substr(0, directive_end) == "#include") {
+ if (directive_end == std::string_view::npos) {
+ throw std::invalid_argument("'#include' without a file name in
'" + fileName + "'");
+ }
+ const auto include_start = line_view.find_first_not_of(separators,
directive_end);
+ if (include_start == std::string_view::npos) {
+ throw std::invalid_argument("'#include' without a file name in
'" + fileName + "'");
+ }
Review Comment:
taken
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]