From: Nelson Ferreira Date: Sun, 4 Mar 2012 21:55:45 +0000 (-0500) Subject: xstrncpy saga X-Git-Tag: v22.1.15~21^2~2 X-Git-Url: http://cgit.sxemacs.org/?a=commitdiff_plain;h=1706db16f1408aacb1cbff6d8731c9b7b0fad1ad;p=sxemacs xstrncpy saga * src/sysdep.c (init_system_name): use xstrncpy instead of strcpy Signed-off-by: Nelson Ferreira --- diff --git a/src/sysdep.c b/src/sysdep.c index 84457f1..f4a9404 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -2102,6 +2102,7 @@ void init_system_name(void) # endif if (hp) { const char *fqdn = (const char *)hp->h_name; + size_t len = 0; if (!strchr(fqdn, '.')) { /* We still don't have a fully qualified domain name. @@ -2112,8 +2113,9 @@ void init_system_name(void) if (*alias) fqdn = *alias; } - hostname = (char *)alloca(strlen(fqdn) + 1); - strcpy(hostname, fqdn); + len = strlen(fqdn) + 1; + hostname = (char *)alloca(len); + xstrncpy(hostname, fqdn,len); } # else /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */ struct addrinfo hints, *res;