From: op Date: Thu, 30 Mar 2023 07:26:15 +0000 (+0000) Subject: strncpy -> strlcpy to properly NUL-terminate the copy of the path X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3d7ba31d954bb46eab9fcf6282a962b65122567f;p=openbsd strncpy -> strlcpy to properly NUL-terminate the copy of the path otherwise paths longer than NFILEN (1024) given with -u won't NUL-terminate `file'. --- diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c index 65a77d11ce1..6493c6c7e04 100644 --- a/usr.bin/mg/fileio.c +++ b/usr.bin/mg/fileio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fileio.c,v 1.109 2023/03/08 04:43:11 guenther Exp $ */ +/* $OpenBSD: fileio.c,v 1.110 2023/03/30 07:26:15 op Exp $ */ /* This file is in the public domain. */ @@ -339,7 +339,7 @@ startupfile(char *suffix, char *conffile) goto nohome; if (conffile != NULL) { - (void)strncpy(file, conffile, NFILEN); + (void)strlcpy(file, conffile, NFILEN); } else if (suffix == NULL) { ret = snprintf(file, sizeof(file), _PATH_MG_STARTUP, home); if (ret < 0 || ret >= sizeof(file))