The function lp_servicename() can return NULL string. Also there
is no guarantee that string is not empty. Add explicit checks for
both cases to avoid invalid access in net_name[len - 1].
Also remove use of True/False.
Pair-Programmed-With: Dmitry Mikhalchenko <tascad@altlinux.org>
Signed-off-by: Daniil Sarafannikov <sarafannikovda@sgu.ru>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Jul 1 07:18:54 UTC 2026 on atb-devel-224
loadparm_s3_global_substitution();
const char *net_name = lp_servicename(talloc_tos(), lp_sub, snum);
- return (net_name[strlen(net_name) - 1] == '$') ? True : False;
+ if (net_name == NULL || net_name[0] == '\0') {
+ return false;
+ }
+
+ return net_name[strlen(net_name) - 1] == '$';
}
/*******************************************************************