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)
committerKarolin Seeger <kseeger@samba.org>
Mon, 21 Jan 2019 08:48:14 +0000 (09:48 +0100)
commit38c459223d217bf8be6858bfc7066c9c9d3adbdd
tree37f702d85fa43d6a2dea1d27697f28f65a893cb9
parent0a3a26179f8cd7b78ea7f970dd21fc75da2c46cd
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]).

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

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

(cherry picked from commit 3634e20c7603103b0f2e00e5b61cc63f905d780d)
source3/libsmb/nmblib.c