-
Notifications
You must be signed in to change notification settings - Fork 144
Closed
Description
template <class T, class... Ps>
Result<T> read(const std::string_view _xml_str) {
pugi::xml_document doc;
const auto result = doc.load_string(_xml_str.data());
if (!result) {
return error("XML string could not be parsed: " +
std::string(result.description()));
}
const auto var = InputVarType(doc.first_child());
return read<T, Ps...>(var);
}https://github.com/getml/reflect-cpp/blob/main/include%2Frfl%2Fxml%2Fread.hpp#L32-L42
doc.load_string expects a null terminated string so it knows the length, this could easily lead to security vulnerabilities with non-null yerminated inputs
Solutions:
-
Take
const std::string&as parameter instead. (cheap if user already passes astd::stringbut limits the user from passing pther string types implicitly. -
Keep
std::string_viewin parameter but construct astd::stringinside the function (more expensive) -
Use another function internally that accepts a
const char* str,std::size_t lenpair
Metadata
Metadata
Assignees
Labels
No labels