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);
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;
head = clientlist + i;
while (*head) {
*head = (clp = *head)->m_next;
+ xfree(clp->m_hostname);
xfree(clp);
}
}
*error = unknown_host;
if (!n)
return NULL;
- strcpy(my_client.m_hostname, *n?n:"DEFAULT");
- free(n);
+ free(my_client.m_hostname);
+ if (*n) {
+ my_client.m_hostname = n;
+ } else {
+ free(n);
+ my_client.m_hostname = xstrdup("DEFAULT");
+ }
my_client.m_naddr = 1;
my_exp.m_client = &my_client;