From ade74df2299739357ab0b89c3fd00fc245939532b307313be7e5c1e3074352f5 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Tue, 26 Jul 2011 19:25:29 +0000 Subject: [PATCH] - update hv_kvp_daemon: Cleanup kvp_get_domain_name(). If getaddrinfo() fails, deal with it properly (this can happen if no IP address has been assigned). Also, don't specify a specific service in the call to getaddrinfo() to make this code as generic as possible. OBS-URL: https://build.opensuse.org/package/show/Virtualization/hyper-v?expand=0&rev=15 --- hv_kvp_daemon.c | 8 +++----- hyper-v.changes | 9 +++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hv_kvp_daemon.c b/hv_kvp_daemon.c index ed45bc9..2e35359 100644 --- a/hv_kvp_daemon.c +++ b/hv_kvp_daemon.c @@ -274,22 +274,20 @@ static int kvp_get_domain_name(char *buffer, int length) { struct addrinfo hints, *info ; - gethostname(buffer, length); int error = 0; + gethostname(buffer, length); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; /*Get only ipv4 addrinfo. */ hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_CANONNAME; - error = getaddrinfo(buffer, "http", &hints, &info); + error = getaddrinfo(buffer, NULL, &hints, &info); if (error != 0) { strcpy(buffer, "getaddrinfo failed\n"); - error = 1; - goto get_domain_done; + return error; } strcpy(buffer, info->ai_canonname); -get_domain_done: freeaddrinfo(info); return error; } diff --git a/hyper-v.changes b/hyper-v.changes index c0a2b54..d666d70 100644 --- a/hyper-v.changes +++ b/hyper-v.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Tue Jul 26 21:24:25 CEST 2011 - ohering@suse.de + +- update hv_kvp_daemon: Cleanup kvp_get_domain_name(). If + getaddrinfo() fails, deal with it properly (this can happen if no + IP address has been assigned). Also, don't specify a specific + service in the call to getaddrinfo() to make this code as generic + as possible. + ------------------------------------------------------------------- Sun Jul 24 17:22:41 CEST 2011 - ohering@suse.de