Bug 11427 - nmbd incorrectly matches netbios names as own name
Summary: nmbd incorrectly matches netbios names as own name
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.2.3
Hardware: All All
: P5 regression (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-04 14:30 UTC by Roel van Meer
Modified: 2021-02-11 14:14 UTC (History)
5 users (show)

See Also:


Attachments
Compare the maximum allowed length of a NetBIOS name (859 bytes, patch)
2015-08-04 14:57 UTC, Roel van Meer
no flags Details
git-am fix for 4.3.0, 4.2.next, 4.1.next. (1013 bytes, patch)
2015-08-25 21:19 UTC, Jeremy Allison
jra: review? (gd)
jra: review? (obnox)
jra: review? (ira)
vl: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roel van Meer 2015-08-04 14:30:13 UTC
This is a regression introduced by da2611adef32107f5a0eec97501c01232ab72efc.

If one of the registered netbios names of a Samba server is "FOO", then the function is_myname() in source3/lib/util.c will return true for all netbios names beginning with "FOO":

source3/lib/util.c:

  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) {
              ret=True;
              break;
          }
      }

Because the strncasecmp_m() only compares the length of nbt_name, it will return true if nbt_name is a substring of s.
Comment 1 Roel van Meer 2015-08-04 14:57:54 UTC
Created attachment 11306 [details]
Compare the maximum allowed length of a NetBIOS name

Possible fix
Comment 2 Roel van Meer 2015-08-06 07:16:39 UTC
For what it's worth, I can confirm that the included patch fixes the problem that was originally reported to us, which was that a PDC on domain FOO did not show up in the browse list of Windows clients named FOOanything, while logging:

  process_browse_packet: Discarding datagram from IP a.b.c.d.
  Source name FOO-S01<00> is one of our names !
Comment 3 Jeremy Allison 2015-08-25 21:19:37 UTC
Created attachment 11370 [details]
git-am fix for 4.3.0, 4.2.next, 4.1.next.

Master patch applies cleanly to 4.1.x and above.
Comment 4 Jeremy Allison 2015-08-27 21:19:02 UTC
Comment on attachment 11370 [details]
git-am fix for 4.3.0, 4.2.next, 4.1.next.

Trying to get reviewers so I can get this into 4.x.next :-).
Comment 5 Jeremy Allison 2015-08-28 15:55:22 UTC
Karolin please push to 4.3.0, 4.2.next, 4.1.next.

Cheers,

Jeremy.
Comment 6 Stefan Metzmacher 2015-08-31 08:09:55 UTC
Pushed to autobuild-v4-{1,2,3}-test
Comment 7 Stefan Metzmacher 2015-08-31 13:49:51 UTC
Pushed to v4-{1,2,3}-test