[libvirt] [PATCH] virConnectGetHostname: return a fully qualified hostname

The attached patch makes virConnectGetHostname try a little harder to get a FQDN on systems where gethostname only returns a short name without a domain (which is pretty useless). The behavior is equivalent to 'hostname --fqdn'.
From 2ae57d0c8c68c453b3f9715fcc9f83af0ebe84a0 Mon Sep 17 00:00:00 2001 From: David Lutterkort <lutter@redhat.com> Date: Wed, 10 Dec 2008 18:34:39 -0800 Subject: [PATCH] virConnectGetHostname: return a fully qualified hostname
Instead of doing the equivalent of 'hostname', do 'hostname --fqdn', i.e. try to qualify the local host name by an additional call to gethostbyname(3) --- src/libvirt_sym.version.in | 1 + src/qemu_driver.c | 16 ++++------------ src/test.c | 16 +++++----------- src/uml_driver.c | 15 ++++----------- src/util.c | 17 +++++++++++++++++ src/util.h | 2 ++ src/xen_unified.c | 15 +++++---------- 7 files changed, 38 insertions(+), 44 deletions(-) diff --git a/src/libvirt_sym.version.in b/src/libvirt_sym.version.in index de0bc4a..f02d9e0 100644 --- a/src/libvirt_sym.version.in +++ b/src/libvirt_sym.version.in @@ -594,6 +594,7 @@ LIBVIRT_PRIVATE_@VERSION@ { virFileReadLimFD; virFileReadPid; virFileLinkPointsTo; + virGetHostname; virParseNumber; virRun; virSkipSpaces; diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 5f6fbd1..d6b7515 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -1562,23 +1562,16 @@ cleanup: static char * qemudGetHostname (virConnectPtr conn) { - int r; - char hostname[HOST_NAME_MAX+1], *str; + char *result; - r = gethostname (hostname, HOST_NAME_MAX+1); - if (r == -1) { + result = virGetHostname(); + if (result == NULL) { qemudReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR, "%s", strerror (errno)); return NULL; } /* Caller frees this string. */ - str = strdup (hostname); - if (str == NULL) { - qemudReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR, - "%s", strerror (errno)); - return NULL; - } - return str; + return result; } static int qemudListDomains(virConnectPtr conn, int *ids, int nids) { @@ -4249,4 +4242,3 @@ int qemuRegister(void) { virRegisterStateDriver(&qemuStateDriver); return 0; } - diff --git a/src/test.c b/src/test.c index 257fc8a..cb623ed 100644 --- a/src/test.c +++ b/src/test.c @@ -651,22 +651,16 @@ static int testGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED, static char *testGetHostname (virConnectPtr conn) { - int r; - char hostname [HOST_NAME_MAX+1], *str; + char *result; - r = gethostname (hostname, HOST_NAME_MAX+1); - if (r == -1) { + result = virGetHostname(); + if (result == NULL) { testError (conn, VIR_ERR_SYSTEM_ERROR, "%s", strerror (errno)); return NULL; } - str = strdup (hostname); - if (str == NULL) { - testError (conn, VIR_ERR_SYSTEM_ERROR, "%s", - strerror (errno)); - return NULL; - } - return str; + /* Caller frees this string. */ + return result; } static int testGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED, diff --git a/src/uml_driver.c b/src/uml_driver.c index 408096e..52a4e5b 100644 --- a/src/uml_driver.c +++ b/src/uml_driver.c @@ -1150,23 +1150,16 @@ cleanup: static char * umlGetHostname (virConnectPtr conn) { - int r; - char hostname[HOST_NAME_MAX+1], *str; + char *result; - r = gethostname (hostname, HOST_NAME_MAX+1); - if (r == -1) { + result = virGetHostname(); + if (result == NULL) { umlReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR, "%s", strerror (errno)); return NULL; } /* Caller frees this string. */ - str = strdup (hostname); - if (str == NULL) { - umlReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR, - "%s", strerror (errno)); - return NULL; - } - return str; + return result; } static int umlListDomains(virConnectPtr conn, int *ids, int nids) { diff --git a/src/util.c b/src/util.c index da26009..7188239 100644 --- a/src/util.c +++ b/src/util.c @@ -47,6 +47,7 @@ #ifdef HAVE_PATHS_H #include <paths.h> #endif +#include <netdb.h> #include "virterror_internal.h" #include "logging.h" @@ -1306,3 +1307,19 @@ int virDiskNameToIndex(const char *name) { return idx; } + +char *virGetHostname(void) +{ + int r; + char hostname[HOST_NAME_MAX+1], *str; + struct hostent *he; + + r = gethostname (hostname, HOST_NAME_MAX+1); + if (r == -1) + return NULL; + if (!(he = gethostbyname(hostname))) + return NULL; + + /* Caller frees this string. */ + return strdup (he->h_name); +} diff --git a/src/util.h b/src/util.h index 0748cbf..f85a61e 100644 --- a/src/util.h +++ b/src/util.h @@ -161,4 +161,6 @@ static inline int getuid (void) { return 0; } static inline int getgid (void) { return 0; } #endif +char *virGetHostname(void); + #endif /* __VIR_UTIL_H__ */ diff --git a/src/xen_unified.c b/src/xen_unified.c index a60bc79..dbda3b5 100644 --- a/src/xen_unified.c +++ b/src/xen_unified.c @@ -447,20 +447,15 @@ xenUnifiedGetVersion (virConnectPtr conn, unsigned long *hvVer) static char * xenUnifiedGetHostname (virConnectPtr conn) { - int r; - char hostname [HOST_NAME_MAX+1], *str; + char *result; - r = gethostname (hostname, HOST_NAME_MAX+1); - if (r == -1) { - xenUnifiedError (conn, VIR_ERR_SYSTEM_ERROR, "%s", strerror(errno)); - return NULL; - } - str = strdup (hostname); - if (str == NULL) { + result = virGetHostname(); + if (result == NULL) { xenUnifiedError (conn, VIR_ERR_SYSTEM_ERROR, "%s", strerror(errno)); return NULL; } - return str; + /* Caller frees this string. */ + return result; } static int -- 1.6.0.4

David Lutterkort <lutter@redhat.com> wrote: > The attached patch makes virConnectGetHostname try a little harder to get a > FQDN on systems where gethostname only returns a short name without a > domain (which is pretty useless). The behavior is equivalent to 'hostname > --fqdn'. Hi David, ACK, modulo some nits: >> From 2ae57d0c8c68c453b3f9715fcc9f83af0ebe84a0 Mon Sep 17 00:00:00 2001 > From: David Lutterkort <lutter@redhat.com> > Date: Wed, 10 Dec 2008 18:34:39 -0800 > Subject: [PATCH] virConnectGetHostname: return a fully qualified hostname ... > diff --git a/src/libvirt_sym.version.in b/src/libvirt_sym.version.in > index de0bc4a..f02d9e0 100644 > --- a/src/libvirt_sym.version.in > +++ b/src/libvirt_sym.version.in > @@ -594,6 +594,7 @@ LIBVIRT_PRIVATE_@VERSION@ { > virFileReadLimFD; > virFileReadPid; > virFileLinkPointsTo; > + virGetHostname; While all the C code uses spaces for indentation, this file uses TABs, so using spaces here looks weird when quoted. > virParseNumber; > virRun; > virSkipSpaces; ... > diff --git a/src/util.c b/src/util.c ... > +char *virGetHostname(void) > +{ > + int r; > + char hostname[HOST_NAME_MAX+1], *str; > + struct hostent *he; > + > + r = gethostname (hostname, HOST_NAME_MAX+1); Avoid duplicating constants like that: s/HOST_NAME_MAX+1/sizeof hostname/

On Wed, Dec 10, 2008 at 07:33:17PM -0800, David Lutterkort wrote:
The attached patch makes virConnectGetHostname try a little harder to get a FQDN on systems where gethostname only returns a short name without a domain (which is pretty useless). The behavior is equivalent to 'hostname --fqdn'.
+ +char *virGetHostname(void) +{ + int r; + char hostname[HOST_NAME_MAX+1], *str; + struct hostent *he; + + r = gethostname (hostname, HOST_NAME_MAX+1); + if (r == -1) + return NULL;
The original code for this was broken too - potentially having an unterminated string "In case the null-terminated hostname does not fit, no error is returned, but the hostname is truncated. It is unspecified whether the truncated hostname will be null- terminated." So for safety we need to add a line following gethostname() to always do NUL_TERMINATE(hostname); (that's a convenient macro we have) ACK to the rest of the patch - particularly the removal of all those duplicated impls ! Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Thu, 2008-12-11 at 10:29 +0000, Daniel P. Berrange wrote:
ACK to the rest of the patch - particularly the removal of all those duplicated impls !
I would have liked to have just one impl of virConnectGetHostname that does the whole gethostname dance, but each driver uses slightly different ways to report errors, and I didn't feel like getting into that for this simple change, though it should definitely be simplified. David

On Wed, Dec 10, 2008 at 07:33:17PM -0800, David Lutterkort wrote:
The attached patch makes virConnectGetHostname try a little harder to get a FQDN on systems where gethostname only returns a short name without a domain (which is pretty useless). The behavior is equivalent to 'hostname --fqdn'.
From 2ae57d0c8c68c453b3f9715fcc9f83af0ebe84a0 Mon Sep 17 00:00:00 2001 From: David Lutterkort <lutter@redhat.com> Date: Wed, 10 Dec 2008 18:34:39 -0800 Subject: [PATCH] virConnectGetHostname: return a fully qualified hostname
Instead of doing the equivalent of 'hostname', do 'hostname --fqdn', i.e. try to qualify the local host name by an additional call to gethostbyname(3) + +char *virGetHostname(void) +{ + int r; + char hostname[HOST_NAME_MAX+1], *str; + struct hostent *he; + + r = gethostname (hostname, HOST_NAME_MAX+1); + if (r == -1) + return NULL; + if (!(he = gethostbyname(hostname))) + return NULL;
Actually, gethostbyname should never be used in any modern code as it is not thread safe. Instead use getaddrinfo() and the AI_CANONNAME flag Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Wed, Dec 10, 2008 at 07:33:17PM -0800, David Lutterkort wrote:
The attached patch makes virConnectGetHostname try a little harder to get a FQDN on systems where gethostname only returns a short name without a domain (which is pretty useless). The behavior is equivalent to 'hostname --fqdn'.
From 2ae57d0c8c68c453b3f9715fcc9f83af0ebe84a0 Mon Sep 17 00:00:00 2001 From: David Lutterkort <lutter@redhat.com> Date: Wed, 10 Dec 2008 18:34:39 -0800 Subject: [PATCH] virConnectGetHostname: return a fully qualified hostname
Instead of doing the equivalent of 'hostname', do 'hostname --fqdn', i.e. try to qualify the local host name by an additional call to gethostbyname(3) + +char *virGetHostname(void) +{ + int r; + char hostname[HOST_NAME_MAX+1], *str; + struct hostent *he; + + r = gethostname (hostname, HOST_NAME_MAX+1); + if (r == -1) + return NULL; + if (!(he = gethostbyname(hostname))) + return NULL;
Actually, gethostbyname should never be used in any modern code as it is not thread safe. Instead use getaddrinfo() and the AI_CANONNAME flag
Good point. Yet another reason not to use gethostbyname. I think it's time to make the prohibition official. Here's a patch to do that:
From 5105125b7a91d701ce2dc9f549814a8fa4e352d7 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Thu, 11 Dec 2008 11:49:40 +0100 Subject: [PATCH] syntax-check: prohibit all new uses of gethostby* functions
* Makefile.maint (sc_prohibit_gethostby): New rule. * .x-sc_prohibit_gethostby: Exempt the few existing uses. --- .x-sc_prohibit_gethostby | 3 +++ Makefile.maint | 6 ++++++ 2 files changed, 9 insertions(+), 0 deletions(-) create mode 100644 .x-sc_prohibit_gethostby diff --git a/.x-sc_prohibit_gethostby b/.x-sc_prohibit_gethostby new file mode 100644 index 0000000..d74ea40 --- /dev/null +++ b/.x-sc_prohibit_gethostby @@ -0,0 +1,3 @@ +gnulib/lib/getaddrinfo.c +gnulib/m4/getaddrinfo.m4 +src/xend_internal.c diff --git a/Makefile.maint b/Makefile.maint index 10d481b..051e4c0 100644 --- a/Makefile.maint +++ b/Makefile.maint @@ -390,6 +390,12 @@ sc_prohibit_virBufferAdd_with_string_literal: { echo '$(ME): use virBufferAddLit, not virBufferAdd,' \ 'with a string literal' 1>&2; exit 1; } || : +# Not only do they fail to deal well with ipv6, but the gethostby* +# functions are also not thread-safe. +sc_prohibit_gethostby: + @grep -nE '\<gethostby(addr|name2?) *\(' $$($(VC_LIST_EXCEPT)) && \ + { echo '$(ME): use getaddrinfo, not gethostby*' 1>&2; exit 1; } || : + # Avoid useless parentheses like those in this example: # #if defined (SYMBOL) || defined (SYM2) sc_useless_cpp_parens: -- 1.6.0.4.1044.g77718

On Thu, Dec 11, 2008 at 11:55:08AM +0100, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Wed, Dec 10, 2008 at 07:33:17PM -0800, David Lutterkort wrote:
The attached patch makes virConnectGetHostname try a little harder to get a FQDN on systems where gethostname only returns a short name without a domain (which is pretty useless). The behavior is equivalent to 'hostname --fqdn'. [...] Actually, gethostbyname should never be used in any modern code as it is not thread safe. Instead use getaddrinfo() and the AI_CANONNAME flag
Good point. Yet another reason not to use gethostbyname. I think it's time to make the prohibition official. Here's a patch to do that:
+1 to both patches, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Thu, 11 Dec 2008, Jim Meyering wrote:
Good point. Yet another reason not to use gethostbyname. I think it's time to make the prohibition official.
I sure hope the Cygwin 1.7, which just released yesterday to formal beta trial, and brings in getaddrinfo() for my win 2000 porting box, _works_ -- perhaps deprecate it for a while first (understanding it is stated as 'prohibit all new uses ...')?
+# Not only do they fail to deal well with ipv6, but the gethostby* +# functions are also not thread-safe.
I think you mean to say here that the implementation you are encountering is not thread safe
# Avoid useless parentheses like those in this example: # #if defined (SYMBOL) || defined (SYM2) sc_useless_cpp_parens:
I infer you can divine the future as to how the g++ 4.7.x implementers will decide parenthesizing will be first warned, and then error-ed ;) -- Russ herrold

On Thu, Dec 11, 2008 at 09:28:12AM -0500, R P Herrold wrote:
On Thu, 11 Dec 2008, Jim Meyering wrote:
Good point. Yet another reason not to use gethostbyname. I think it's time to make the prohibition official.
I sure hope the Cygwin 1.7, which just released yesterday to formal beta trial, and brings in getaddrinfo() for my win 2000 porting box, _works_ -- perhaps deprecate it for a while first (understanding it is stated as 'prohibit all new uses ...')?
We use GNULIB which provides compatability for broken/incomplete OS like cygwin
+# Not only do they fail to deal well with ipv6, but the gethostby* +# functions are also not thread-safe.
I think you mean to say here that the implementation you are encountering is not thread safe
POSIX leaves thread safety undefined, which is just as bad as marking it explicitly unsafe. "The functions gethostbyname() and gethostbyaddr() may return pointers to static data, which may be overwritten by later calls. " No code can use this function and expect to be safe when using threads. Even on an OS where its currently safe, there's no guarentee it'll stay safe in the future Furthermore they're explicitly deprecated "POSIX.1-2001 marks gethostbyaddr() and gethostbyname() obsolescent. See getaddrinfo(3), getnameinfo(3), gai_strerror(3)." Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Here is a revised patch that addresses all the comments from Jim and Dan: * Use getaddrinfo instead of gethostbyname * Terminate hostname explicitly with NUL_TERMINATE * Do not repeat constant HOST_NAME_MAX+1 * Use tabs, not spaces in libvirt_sym.version.in David
From 65bee217eb80a3be39f80a7c229305180e5786c6 Mon Sep 17 00:00:00 2001 From: David Lutterkort <lutter@redhat.com> Date: Wed, 10 Dec 2008 18:34:39 -0800 Subject: [PATCH] virConnectGetHostname: return a fully qualified hostname
Instead of doing the equivalent of 'hostname', do 'hostname --fqdn', i.e. try to qualify the local host name by an additional call to getaddrinfo(3) --- src/libvirt_sym.version.in | 1 + src/qemu_driver.c | 16 ++++------------ src/test.c | 16 +++++----------- src/uml_driver.c | 15 ++++----------- src/util.c | 33 +++++++++++++++++++++++++++++++++ src/util.h | 2 ++ src/xen_unified.c | 15 +++++---------- 7 files changed, 54 insertions(+), 44 deletions(-) diff --git a/src/libvirt_sym.version.in b/src/libvirt_sym.version.in index de0bc4a..71a47b7 100644 --- a/src/libvirt_sym.version.in +++ b/src/libvirt_sym.version.in @@ -594,6 +594,7 @@ LIBVIRT_PRIVATE_@VERSION@ { virFileReadLimFD; virFileReadPid; virFileLinkPointsTo; + virGetHostname; virParseNumber; virRun; virSkipSpaces; diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 5f6fbd1..d6b7515 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -1562,23 +1562,16 @@ cleanup: static char * qemudGetHostname (virConnectPtr conn) { - int r; - char hostname[HOST_NAME_MAX+1], *str; + char *result; - r = gethostname (hostname, HOST_NAME_MAX+1); - if (r == -1) { + result = virGetHostname(); + if (result == NULL) { qemudReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR, "%s", strerror (errno)); return NULL; } /* Caller frees this string. */ - str = strdup (hostname); - if (str == NULL) { - qemudReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR, - "%s", strerror (errno)); - return NULL; - } - return str; + return result; } static int qemudListDomains(virConnectPtr conn, int *ids, int nids) { @@ -4249,4 +4242,3 @@ int qemuRegister(void) { virRegisterStateDriver(&qemuStateDriver); return 0; } - diff --git a/src/test.c b/src/test.c index 257fc8a..cb623ed 100644 --- a/src/test.c +++ b/src/test.c @@ -651,22 +651,16 @@ static int testGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED, static char *testGetHostname (virConnectPtr conn) { - int r; - char hostname [HOST_NAME_MAX+1], *str; + char *result; - r = gethostname (hostname, HOST_NAME_MAX+1); - if (r == -1) { + result = virGetHostname(); + if (result == NULL) { testError (conn, VIR_ERR_SYSTEM_ERROR, "%s", strerror (errno)); return NULL; } - str = strdup (hostname); - if (str == NULL) { - testError (conn, VIR_ERR_SYSTEM_ERROR, "%s", - strerror (errno)); - return NULL; - } - return str; + /* Caller frees this string. */ + return result; } static int testGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED, diff --git a/src/uml_driver.c b/src/uml_driver.c index 408096e..52a4e5b 100644 --- a/src/uml_driver.c +++ b/src/uml_driver.c @@ -1150,23 +1150,16 @@ cleanup: static char * umlGetHostname (virConnectPtr conn) { - int r; - char hostname[HOST_NAME_MAX+1], *str; + char *result; - r = gethostname (hostname, HOST_NAME_MAX+1); - if (r == -1) { + result = virGetHostname(); + if (result == NULL) { umlReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR, "%s", strerror (errno)); return NULL; } /* Caller frees this string. */ - str = strdup (hostname); - if (str == NULL) { - umlReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR, - "%s", strerror (errno)); - return NULL; - } - return str; + return result; } static int umlListDomains(virConnectPtr conn, int *ids, int nids) { diff --git a/src/util.c b/src/util.c index da26009..c5e406b 100644 --- a/src/util.c +++ b/src/util.c @@ -47,6 +47,7 @@ #ifdef HAVE_PATHS_H #include <paths.h> #endif +#include <netdb.h> #include "virterror_internal.h" #include "logging.h" @@ -1306,3 +1307,35 @@ int virDiskNameToIndex(const char *name) { return idx; } + +#ifndef AI_CANONIDN +#define AI_CANONIDN 0 +#endif + +char *virGetHostname(void) +{ + int r; + char hostname[HOST_NAME_MAX+1], *result; + struct addrinfo hints, *info; + + r = gethostname (hostname, sizeof(hostname)); + if (r == -1) + return NULL; + NUL_TERMINATE(hostname); + + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_CANONNAME|AI_CANONIDN; + hints.ai_family = AF_UNSPEC; + r = getaddrinfo(hostname, NULL, &hints, &info); + if (r != 0) + return NULL; + if (info->ai_canonname == NULL) { + freeaddrinfo(info); + return NULL; + } + + /* Caller frees this string. */ + result = strdup (info->ai_canonname); + freeaddrinfo(info); + return result; +} diff --git a/src/util.h b/src/util.h index 0748cbf..f85a61e 100644 --- a/src/util.h +++ b/src/util.h @@ -161,4 +161,6 @@ static inline int getuid (void) { return 0; } static inline int getgid (void) { return 0; } #endif +char *virGetHostname(void); + #endif /* __VIR_UTIL_H__ */ diff --git a/src/xen_unified.c b/src/xen_unified.c index a60bc79..dbda3b5 100644 --- a/src/xen_unified.c +++ b/src/xen_unified.c @@ -447,20 +447,15 @@ xenUnifiedGetVersion (virConnectPtr conn, unsigned long *hvVer) static char * xenUnifiedGetHostname (virConnectPtr conn) { - int r; - char hostname [HOST_NAME_MAX+1], *str; + char *result; - r = gethostname (hostname, HOST_NAME_MAX+1); - if (r == -1) { - xenUnifiedError (conn, VIR_ERR_SYSTEM_ERROR, "%s", strerror(errno)); - return NULL; - } - str = strdup (hostname); - if (str == NULL) { + result = virGetHostname(); + if (result == NULL) { xenUnifiedError (conn, VIR_ERR_SYSTEM_ERROR, "%s", strerror(errno)); return NULL; } - return str; + /* Caller frees this string. */ + return result; } static int -- 1.6.0.4

On Thu, Dec 11, 2008 at 09:24:27PM +0000, David Lutterkort wrote:
Here is a revised patch that addresses all the comments from Jim and Dan:
* Use getaddrinfo instead of gethostbyname * Terminate hostname explicitly with NUL_TERMINATE * Do not repeat constant HOST_NAME_MAX+1 * Use tabs, not spaces in libvirt_sym.version.in
Better late than never, I applied that cleanup, it needed just a bit of adjustment to use src/libvirt_private.syms instead of libvirt_sym.version thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (5)
-
Daniel P. Berrange
-
Daniel Veillard
-
David Lutterkort
-
Jim Meyering
-
R P Herrold