diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-04-01 16:42:38 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-04-01 16:42:38 +0900 |
| commit | b9471d745280a3615b623514a8468ffb4b8d7d1c (patch) | |
| tree | 33d158bf3c07d59d1e0883b492fdcf08ba131f23 /src/SocketCore.cc | |
| parent | b68e0a5527bad4faa9bc665c3d069ddbf0bb7c1a (diff) | |
Compare IPAddress in commonName as string.
Added test for net::verifyHostname().
Diffstat (limited to 'src/SocketCore.cc')
| -rw-r--r-- | src/SocketCore.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/SocketCore.cc b/src/SocketCore.cc index aeac675f..823d302a 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -1330,16 +1330,15 @@ bool verifyHostname(const std::string& hostname, const std::string& commonName) { if(util::isNumericHost(hostname)) { + if(ipAddrs.empty()) { + return commonName == hostname; + } // We need max 16 bytes to store IPv6 address. unsigned char binAddr[16]; size_t addrLen = getBinAddr(binAddr, hostname); if(addrLen == 0) { return false; } - if(ipAddrs.empty()) { - return addrLen == commonName.size() && - memcmp(binAddr, commonName.c_str(), addrLen) == 0; - } for(std::vector<std::string>::const_iterator i = ipAddrs.begin(), eoi = ipAddrs.end(); i != eoi; ++i) { if(addrLen == (*i).size() && |
