X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=support%2Fexport%2Fclient.c;h=1754aa0d0d630f25962c3a4abd89bab9a118e7cc;hb=4c337e2131123c339bc4921779b57b69b77be2fd;hp=33dfdb004efac38fa08269906abbf4b045351d45;hpb=93608a52655abf5ac23404c4b5cc05fe575a9c04;p=nfs-utils.git diff --git a/support/export/client.c b/support/export/client.c index 33dfdb0..1754aa0 100644 --- a/support/export/client.c +++ b/support/export/client.c @@ -118,6 +118,7 @@ client_dup(nfs_client *clp, struct hostent *hp) new = (nfs_client *) xmalloc(sizeof(*new)); memcpy(new, clp, sizeof(*new)); new->m_type = MCL_FQDN; + new->m_hostname = NULL; client_init(new, (char *) hp->h_name, hp); client_add(new); @@ -127,14 +128,11 @@ client_dup(nfs_client *clp, struct hostent *hp) static void client_init(nfs_client *clp, const char *hname, struct hostent *hp) { - if (hp) { - strncpy(clp->m_hostname, hp->h_name, - sizeof (clp->m_hostname) - 1); - } else { - strncpy(clp->m_hostname, hname, - sizeof (clp->m_hostname) - 1); - } - clp->m_hostname[sizeof (clp->m_hostname) - 1] = '\0'; + xfree(clp->m_hostname); + if (hp) + clp->m_hostname = xstrdup(hp->h_name); + else + clp->m_hostname = xstrdup(hname); clp->m_exported = 0; clp->m_count = 0; @@ -207,6 +205,7 @@ client_freeall(void) head = clientlist + i; while (*head) { *head = (clp = *head)->m_next; + xfree(clp->m_hostname); xfree(clp); } } @@ -262,6 +261,7 @@ client_compose(struct in_addr addr) name = add_name(name, clp->m_hostname); } } + free(he); return name; } @@ -329,6 +329,7 @@ add_name(char *old, char *add) strcat(new, ","); strcat(new, cp); } + free(old); return new; }