From: Kefu Chai Date: Wed, 28 Jun 2017 06:38:37 +0000 (+0800) Subject: common/dns_resolve: do not assert with misconfigured SRV RR X-Git-Tag: v12.1.1~188^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cf384a18dc5abcd08276b42f7888fa5626f064c4;p=ceph.git common/dns_resolve: do not assert with misconfigured SRV RR Signed-off-by: Kefu Chai --- diff --git a/src/common/dns_resolve.cc b/src/common/dns_resolve.cc index c94d8a448eb5..3b984a61c82c 100644 --- a/src/common/dns_resolve.cc +++ b/src/common/dns_resolve.cc @@ -350,8 +350,13 @@ int DNSResolver::resolve_srv_hosts(CephContext *cct, const string& service_name, if (r == 0) { addr.set_port(port); string target = full_target; - assert(target.find(srv_domain) != target.npos); - target = target.substr(0, target.find(srv_domain)); + auto end = target.find(srv_domain); + if (end == target.npos) { + lderr(cct) << "resolved target not in search domain: " + << target << " / " << srv_domain << dendl; + return -EINVAL; + } + target = target.substr(0, end); (*srv_hosts)[target] = {priority, addr}; } }