From b000f97bd38ca8f1686942fb40940eec23ab164f Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 11 Jul 2005 20:37:47 +0000 Subject: [PATCH] sanity check getdomainname --- src/sigar.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sigar.c b/src/sigar.c index 05b6fa1f..57e9db40 100644 --- a/src/sigar.c +++ b/src/sigar.c @@ -880,8 +880,12 @@ int sigar_net_info_get(sigar_t *sigar, fclose(fp); - getdomainname(netinfo->domain, sizeof(netinfo->domain)); - netinfo->domain[sizeof(netinfo->domain)-1] = '\0'; + if (getdomainname(netinfo->domain, sizeof(netinfo->domain)) == 0) { + netinfo->domain[sizeof(netinfo->domain)-1] = '\0'; + } + else { + netinfo->domain[0] = '\0'; + } return SIGAR_OK; }