git: 8c211a00d3b4 - stable/14 - ctld: Require a mask if / is specified in an initiator portal

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 27 Jan 2026 18:44:32 UTC
The branch stable/14 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=8c211a00d3b45b46b00e3fb99d803b65e7aadeee

commit 8c211a00d3b45b46b00e3fb99d803b65e7aadeee
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-04-11 14:02:09 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-01-27 18:15:58 +0000

    ctld: Require a mask if / is specified in an initiator portal
    
    If the / separator in a portal string is the last character in the
    string, treat the portal as invalid.
    
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D49648
    
    (cherry picked from commit 4449cf28a3152cf6e87a45176ae15ae250e543de)
---
 usr.sbin/ctld/ctld.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/usr.sbin/ctld/ctld.cc b/usr.sbin/ctld/ctld.cc
index 51983a42a8bf..bcde2f1ae433 100644
--- a/usr.sbin/ctld/ctld.cc
+++ b/usr.sbin/ctld/ctld.cc
@@ -350,6 +350,8 @@ auth_portal_new(struct auth_group *ag, const char *portal)
 		dm = 32;
 	}
 	if (mask != NULL) {
+		if (mask[0] == '\0')
+			goto error;
 		m = strtol(mask, &tmp, 0);
 		if (m < 0 || m > dm || tmp[0] != 0)
 			goto error;