nmblib: avoid undefined behaviour in handle_name_ptrs()
commitf50790c1be70af62cb2d0231cc05bdf59344b4c1
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Sun, 19 Jan 2020 02:08:58 +0000 (19 15:08 +1300)
committerKarolin Seeger <kseeger@samba.org>
Wed, 18 Mar 2020 12:26:05 +0000 (18 12:26 +0000)
tree6cb6ef2406e431fb6b207bc8ab8f2008f7d932bd
parent8b86109e5deca6b19883828ff02b4cf19e751641
nmblib: avoid undefined behaviour in handle_name_ptrs()

If *offset is length - 1, we would read ubuf[(*offset)+1] as the lower
bits of the new *offset. This value is undefined, but because it is
checked against the valid range, there is no way to read further
beyond that one byte.

Credit to oss-fuzz.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14242
OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20193

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Feb  7 10:19:39 UTC 2020 on sn-devel-184

(cherry picked from commit 3bc7acc62646b105b03fd3c65e9170a373f95392)

Autobuild-User(v4-12-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-12-test): Wed Mar 18 12:26:06 UTC 2020 on sn-devel-184
source3/libsmb/nmblib.c