X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcollectd.c;h=5484322f16eb5feabe8dce1039db7fcda56932cf;hb=6ddbe0026dea748db40ccc494b4f5048817b346a;hp=a3f63b48007336bc48621fa366cbf90a96ccff4c;hpb=c60c6dfa5960b23bdc59341ae73e701dd59d4305;p=collectd.git diff --git a/src/collectd.c b/src/collectd.c index a3f63b48..5484322f 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -90,8 +90,7 @@ static int init_hostname (void) str = global_option_get ("Hostname"); if (str != NULL) { - strncpy (hostname_g, str, sizeof (hostname_g)); - hostname_g[sizeof (hostname_g) - 1] = '\0'; + sstrncpy (hostname_g, str, sizeof (hostname_g)); return (0); } @@ -127,8 +126,7 @@ static int init_hostname (void) if (ai_ptr->ai_canonname == NULL) continue; - strncpy (hostname_g, ai_ptr->ai_canonname, sizeof (hostname_g)); - hostname_g[sizeof (hostname_g) - 1] = '\0'; + sstrncpy (hostname_g, ai_ptr->ai_canonname, sizeof (hostname_g)); break; }