]> git.ipfire.org Git - thirdparty/samba.git/commit
CVE-2022-3437 source4/heimdal: Avoid undefined behaviour in _gssapi_verify_pad()
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 15 Aug 2022 04:53:45 +0000 (16:53 +1200)
committerJule Anger <janger@samba.org>
Mon, 24 Oct 2022 05:27:02 +0000 (07:27 +0200)
commit5a62eb5734d50fe556934aefa3bac5698372f00e
tree75a8f454b4d4fec73b3a7990258329c284f1e1a1
parent9f6f1e01aca4f00a5d23127803c81939253e0577
CVE-2022-3437 source4/heimdal: Avoid undefined behaviour in _gssapi_verify_pad()

By decrementing 'pad' only when we know it's safe, we ensure we can't
stray backwards past the start of a buffer, which would be undefined
behaviour.

In the previous version of the loop, 'i' is the number of bytes left to
check, and 'pad' is the current byte we're checking. 'pad' was
decremented at the end of each loop iteration. If 'i' was 1 (so we
checked the final byte), 'pad' could potentially be pointing to the
first byte of the input buffer, and the decrement would put it one
byte behind the buffer.

That would be undefined behaviour.

The patch changes it so that 'pad' is the byte we previously checked,
which allows us to ensure that we only decrement it when we know we
have a byte to check.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/heimdal/lib/gssapi/krb5/decapsulate.c