Module Name: src Committed By: mrg Date: Mon Apr 12 09:18:14 UTC 2021
Modified Files: src/sbin/mount_portal: pt_filter.c Log Message: properly terminate a buffer after strncpy(). To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sbin/mount_portal/pt_filter.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/mount_portal/pt_filter.c diff -u src/sbin/mount_portal/pt_filter.c:1.12 src/sbin/mount_portal/pt_filter.c:1.13 --- src/sbin/mount_portal/pt_filter.c:1.12 Thu May 14 08:34:17 2020 +++ src/sbin/mount_portal/pt_filter.c Mon Apr 12 09:18:14 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pt_filter.c,v 1.12 2020/05/14 08:34:17 msaitoh Exp $ */ +/* $NetBSD: pt_filter.c,v 1.13 2021/04/12 09:18:14 mrg Exp $ */ /* * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: pt_filter.c,v 1.12 2020/05/14 08:34:17 msaitoh Exp $"); +__RCSID("$NetBSD: pt_filter.c,v 1.13 2021/04/12 09:18:14 mrg Exp $"); #endif /* not lint */ #include <stdio.h> @@ -65,7 +65,8 @@ fill_cmd(char **cmdv, char *path, char * if (tempbuff == NULL) err(1, NULL); - strncpy(tempbuff, cmdv[0], n); + strncpy(tempbuff, cmdv[0], n - 1); + tempbuff[n - 1] = '\0'; for (i = 1; cmdv[i]; i++) { strncat(tempbuff, " ", n - strlen(tempbuff)); strncat(tempbuff, cmdv[i], n - strlen(tempbuff));