Permalink
Browse files

Use INET6_ADDRSTRLEN instead of magic number 40.

Also 40 is too small, the string can be longer.
  • Loading branch information...
1 parent c48a686 commit 6bf774d8536b63a95d59ef73ed142bdfd5ab9528 @DarthGandalf DarthGandalf committed Apr 18, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/Socket.cpp
View
@@ -262,11 +262,11 @@ void CSockManager::SetTDNSThreadFinished(TDNSTask* task, bool bBind, addrinfo* a
CString sBindhost;
CString sTargetHost;
if (!task->sBindhost.empty()) {
- char s[40] = {}; // 40 is enough for both ipv4 and ipv6 addresses, including 0 terminator.
+ char s[INET6_ADDRSTRLEN] = {};
getnameinfo(aiBind->ai_addr, aiBind->ai_addrlen, s, sizeof(s), NULL, 0, NI_NUMERICHOST);
sBindhost = s;
}
- char s[40] = {};
+ char s[INET6_ADDRSTRLEN] = {};
getnameinfo(aiTarget->ai_addr, aiTarget->ai_addrlen, s, sizeof(s), NULL, 0, NI_NUMERICHOST);
sTargetHost = s;

0 comments on commit 6bf774d

Please sign in to comment.