aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2019-02-07 18:50:33 +0000
committerGitHub <[email protected]>2019-02-07 18:50:33 +0000
commitdad5b4a855658232ed6340714ad3c54257716595 (patch)
tree4d4826c6c4cd3fe56fbc9ddb359ef6ed5119a584
parentMerge pull request #210 from jengelh/twoaddr (diff)
parentUnbreak own hostname qualification on POSIX systems (diff)
downloadvmime-dad5b4a855658232ed6340714ad3c54257716595.tar.gz
vmime-dad5b4a855658232ed6340714ad3c54257716595.zip
Merge pull request #212 from jengelh/hostname
Unbreak own hostname qualification on POSIX systems
-rw-r--r--src/vmime/platforms/posix/posixHandler.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/vmime/platforms/posix/posixHandler.cpp b/src/vmime/platforms/posix/posixHandler.cpp
index f8861315..eecdbea9 100644
--- a/src/vmime/platforms/posix/posixHandler.cpp
+++ b/src/vmime/platforms/posix/posixHandler.cpp
@@ -159,6 +159,10 @@ static inline bool isAcceptableHostname(const vmime::string& str) {
const vmime::string posixHandler::getHostName() const {
+ char hostname[256];
+
+ ::gethostname(hostname, sizeof(hostname));
+ hostname[sizeof(hostname)-1] = '\0';
// Try to get official canonical name of this host
struct addrinfo hints;
@@ -169,8 +173,7 @@ const vmime::string posixHandler::getHostName() const {
struct addrinfo* info;
- if (getaddrinfo(NULL, "http", &hints, &info) == 0) {
-
+ if (getaddrinfo(hostname, "http", &hints, &info) == 0) {
// First, try to get a Fully-Qualified Domain Name (FQDN)
for (struct addrinfo* p = info ; p != NULL ; p = p->ai_next) {
@@ -202,11 +205,6 @@ const vmime::string posixHandler::getHostName() const {
freeaddrinfo(info);
}
- // Get host name
- char hostname[256];
- ::gethostname(hostname, sizeof(hostname));
- hostname[sizeof(hostname) - 1] = '\0';
-
if (::strlen(hostname) == 0 || !isAcceptableHostname(hostname)) {
::strcpy(hostname, "localhost.localdomain");
}