Comment 9 for bug 735072

Revision history for this message
Johan Fornander (fornander-johan) wrote :

The source code in the official samba git (source/lib/util.c) seems to use HOST_NAME_MAX and I found an inconsistency in the code base:

source/lib/replace/replace.h:
 384 #ifndef HOST_NAME_MAX
 385 #define HOST_NAME_MAX 255

source/lib/replace/system/network.h
 269 #ifndef HOST_NAME_MAX
 270 #define HOST_NAME_MAX 256

Which one is used?

Then here is what I think my problem is:

The function get_myname() in util.c uses
char hostname[HOST_NAME_MAX];

Another function in the same file, set_netbios_aliases(), blindly uses this hostname through helper functions without checking its boundaries to match those of a valid NetBIOS name.

Now I could be wrong since I just took 5 minutes to check the source code while also skimming this link:
http://www.tech-faq.com/netbios-names.html

How this is supposed to work out of the box when windows machines, or osx for that matter, only recognizes NetBIOS names of length 15 is beyond me. Can this really have been overlooked since the inception of samba or am I missing something here?