s3: lib: nmbname: Ensure we limit the NetBIOS name correctly. CID: 1433607
authorJeremy Allison <jra@samba.org>
Mon, 12 Nov 2018 19:37:31 +0000 (11:37 -0800)
committerDavid Disseldorp <ddiss@samba.org>
Tue, 13 Nov 2018 19:54:56 +0000 (20:54 +0100)
commit3634e20c7603103b0f2e00e5b61cc63f905d780d
treef1164c709cef9baf5c6e129b95afdc327fa88acc
parent5a8583ed701be97c33a20b2a20f6bbb8ac2f8e99
s3: lib: nmbname: Ensure we limit the NetBIOS name correctly. CID: 1433607

Firstly, make the exit condition from the loop explicit (we must
never write into byte n, where n >= sizeof(name->name).

Secondly ensure exiting from the loop that n==MAX_NETBIOSNAME_LEN,
as this is the sign of a correct NetBIOS name encoding (RFC1002)
in order to properly read the NetBIOS name type (which is always
encoded in byte 16 == name->name[15]).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): David Disseldorp <ddiss@samba.org>
Autobuild-Date(master): Tue Nov 13 20:54:56 CET 2018 on sn-devel-144
source3/libsmb/nmblib.c