1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
samba-mirror/source4/nbt_server
Joseph Sutton edad945339 librpc/nbt: Avoid reading invalid member of union
WACK packets use the ‘data’ member of the ‘nbt_rdata’ union, but they
claim to be a different type — NBT_QTYPE_NETBIOS — than would normally
be used with that union member. This means that if rr_type is equal to
NBT_QTYPE_NETBIOS, ndr_push_nbt_res_rec() has to guess which type the
structure really is by examining the data member. However, if the
structure is actually of a different type, that union member will not be
valid and accessing it will invoke undefined behaviour.

To fix this, eliminate all the guesswork and introduce a new type,
NBT_QTYPE_WACK, which can never appear on the wire, and which indicates
that although the ‘data’ union member should be used, the wire type is
actually NBT_QTYPE_NETBIOS.

This means that as far as NDR is concerned, the ‘netbios’ member of the
‘nbt_rdata’ union will consistently be used for all NBT_QTYPE_NETBIOS
structures; we shall no longer access the wrong member of the union.

Credit to OSS-Fuzz.

REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38480

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>

Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Fri Jul  7 01:14:06 UTC 2023 on atb-devel-224
2023-07-07 01:14:06 +00:00
..
dgram s4: rename source4/smbd/ to source4/samba/ 2020-11-27 10:07:18 +00:00
wins CVE-2022-32746 ldb: Make use of functions for appending to an ldb_message 2022-07-27 10:52:36 +00:00
defense.c
interfaces.c lib: Remove idtree from samba_util.h 2023-01-10 00:28:37 +00:00
irpc.c s4: rename source4/smbd/ to source4/samba/ 2020-11-27 10:07:18 +00:00
nbt_server.c s4: rename source4/smbd/ to source4/samba/ 2020-11-27 10:07:18 +00:00
nbt_server.h
nodestatus.c nbt_server: Factor out nbtd_node_status_reply_packet 2018-04-17 21:27:23 +02:00
packet.c librpc/nbt: Avoid reading invalid member of union 2023-07-07 01:14:06 +00:00
query.c s4: rename source4/smbd/ to source4/samba/ 2020-11-27 10:07:18 +00:00
register.c s4: rename source4/smbd/ to source4/samba/ 2020-11-27 10:07:18 +00:00
wscript_build