git: 961e6a12efdb - main - bhyve/snapshot: limit snapshot filename to NAME_MAX

From: Robert Wing <rew_at_FreeBSD.org>
Date: Fri, 18 Mar 2022 05:53:28 UTC
The branch main has been updated by rew:

URL: https://cgit.FreeBSD.org/src/commit/?id=961e6a12efdbd48d92516beaf0772ff50008457d

commit 961e6a12efdbd48d92516beaf0772ff50008457d
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2022-03-18 05:51:31 +0000
Commit:     Robert Wing <rew@FreeBSD.org>
CommitDate: 2022-03-18 05:51:31 +0000

    bhyve/snapshot: limit snapshot filename to NAME_MAX
    
    NAME_MAX is a better fit since strcat_extension() constructs the
    filename of the snapshot file.
    
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D34291
---
 usr.sbin/bhyve/snapshot.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c
index 13154c68c3e7..585fc2bc6f47 100644
--- a/usr.sbin/bhyve/snapshot.c
+++ b/usr.sbin/bhyve/snapshot.c
@@ -181,10 +181,10 @@ strcat_extension(const char *base_str, const char *ext)
 	char *res;
 	size_t base_len, ext_len;
 
-	base_len = strnlen(base_str, MAX_VMNAME);
-	ext_len = strnlen(ext, MAX_VMNAME);
+	base_len = strnlen(base_str, NAME_MAX);
+	ext_len = strnlen(ext, NAME_MAX);
 
-	if (base_len + ext_len > MAX_VMNAME) {
+	if (base_len + ext_len > NAME_MAX) {
 		fprintf(stderr, "Filename exceeds maximum length.\n");
 		return (NULL);
 	}