git: 4449cf28a315 - main - ctld: Require a mask if / is specified in an initiator portal

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 11 Apr 2025 14:04:01 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=4449cf28a3152cf6e87a45176ae15ae250e543de

commit 4449cf28a3152cf6e87a45176ae15ae250e543de
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-04-11 14:02:09 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-04-11 14:02:09 +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
---
 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 bc794815830c..ff23db6c5293 100644
--- a/usr.sbin/ctld/ctld.cc
+++ b/usr.sbin/ctld/ctld.cc
@@ -349,6 +349,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;