Commit 22bb1ddc authored by Simon Morlat's avatar Simon Morlat

avoid resolving "" by getaddrinfo()

parent 2f3edf04
......@@ -461,11 +461,16 @@ void Agent::loadConfig(GenericManager *cm) {
std::string Agent::computeResolvedPublicIp(const std::string &host) const {
int err;
struct addrinfo hints;
string dest = (host[0] == '[') ? host.substr(1, host.size() - 2) : host;
string dest;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
struct addrinfo *result;
dest.clear();
if (host.empty())
return dest;
dest = (host[0] == '[') ? host.substr(1, host.size() - 2) : host;
err = getaddrinfo(dest.c_str(), NULL, &hints, &result);
if (err == 0) {
char ip[NI_MAXHOST];
......
......@@ -178,7 +178,6 @@ void AuthDbBackend::createAccount(const char* user, const char* host, const char
}
AuthDbBackend::CacheResult AuthDbBackend::getCachedUserWithPhone(const string &phone, const string &domain, string &user) {
time_t now = getCurrentTime();
unique_lock<mutex> lck(mCachedUserWithPhoneMutex);
auto it = mPhone2User.find(phone + "@" + domain);
if (it == mPhone2User.end()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment