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; }