Verify we parse the entire address argument.
Fixes: https://tracker.ceph.com/issues/48336
Signed-off-by: Brad Hubbard <bhubbard@redhat.com>
Signed-off-by: Kefu Chai <kchai@redhat.com>
o.push_back(a);
}
+bool entity_addr_t::parse(const std::string_view s)
+{
+ const char* start = s.data();
+ const char* end = nullptr;
+ bool got = parse(start, &end);
+ return got && end == start + s.size();
+}
+
bool entity_addr_t::parse(const char *s, const char **end, int default_type)
{
*this = entity_addr_t();
return ss.str();
}
+ bool parse(const std::string_view s);
bool parse(const char *s, const char **end = 0, int type=0);
void decode_legacy_addr_after_marker(ceph::buffer::list::const_iterator& bl)
if (i == args.end())
helpful_exit();
entity_addr_t addr;
- if (!addr.parse(*i)) {
+ if (!addr.parse(string_view{*i})) {
+ // Either we couldn't parse the address or we didn't consume the entire token
cerr << me << ": invalid ip:port '" << *i << "'" << std::endl;
return -1;
}