Module Name: src Committed By: mrg Date: Tue Aug 8 06:31:58 UTC 2023
Modified Files: src/usr.sbin/timed/timed: timed.c Log Message: use standard strncpy() idiom to completely zero a buffer, including explicitly nul the final char. found by GCC 12. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/timed/timed/timed.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/timed/timed/timed.c diff -u src/usr.sbin/timed/timed/timed.c:1.29 src/usr.sbin/timed/timed/timed.c:1.30 --- src/usr.sbin/timed/timed/timed.c:1.29 Sun Oct 16 16:44:15 2022 +++ src/usr.sbin/timed/timed/timed.c Tue Aug 8 06:31:58 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: timed.c,v 1.29 2022/10/16 16:44:15 rillig Exp $ */ +/* $NetBSD: timed.c,v 1.30 2023/08/08 06:31:58 mrg Exp $ */ /*- * Copyright (c) 1985, 1993 The Regents of the University of California. @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 19 #if 0 static char sccsid[] = "@(#)timed.c 8.2 (Berkeley) 3/26/95"; #else -__RCSID("$NetBSD: timed.c,v 1.29 2022/10/16 16:44:15 rillig Exp $"); +__RCSID("$NetBSD: timed.c,v 1.30 2023/08/08 06:31:58 mrg Exp $"); #endif #endif /* not lint */ @@ -688,7 +688,8 @@ add_good_host(const char* name, exit(EXIT_FAILURE); } - (void)strncpy(&ghp->name[0], name, sizeof(ghp->name)); + (void)strncpy(&ghp->name[0], name, sizeof(ghp->name) - 1); + ghp->name[sizeof(ghp->name) - 1] = 0; ghp->next = goodhosts; ghp->perm = perm; goodhosts = ghp;