s3-util: Compare the maximum allowed length of a NetBIOS name
authorRoel van Meer <roel@1afa.com>
Tue, 4 Aug 2015 14:50:43 +0000 (16:50 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 25 Aug 2015 16:43:14 +0000 (18:43 +0200)
This fixes a problem where is_myname() returns true if one of our names
is a substring of the specified name.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11427

Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/lib/util.c

index 2fd2b6b9f218634848f246d46b39ea5923483f72..d38d53a5cb8fd7f3234892dabd0e91563d2e554f 100644 (file)
@@ -1198,7 +1198,7 @@ bool is_myname(const char *s)
        for (n=0; my_netbios_names(n); n++) {
                const char *nbt_name = my_netbios_names(n);
 
-               if (strncasecmp_m(nbt_name, s, strlen(nbt_name)) == 0) {
+               if (strncasecmp_m(nbt_name, s, MAX_NETBIOSNAME_LEN-1) == 0) {
                        ret=True;
                        break;
                }