Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Jan 2023 18:54:29 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 4b905478ffe4 - stable/13 - bhyve/snapshot: limit snapshot filename to NAME_MAX
Message-ID:  <202301261854.30QIsTOk034292@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=4b905478ffe43aaedf204064bd52554cbbecaa2e

commit 4b905478ffe43aaedf204064bd52554cbbecaa2e
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2022-03-18 05:51:31 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-01-26 18:48:54 +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
    
    (cherry picked from commit 961e6a12efdbd48d92516beaf0772ff50008457d)
---
 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 4bd2ea273171..a5217eaab1ec 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);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202301261854.30QIsTOk034292>