gsskrb5: CVE-2022-3437 Pass correct length to _gssapi_verify_pad()

We later subtract 8 when calculating the length of the output message
buffer. If padlength is excessively high, this calculation can underflow
and result in a very large positive value.

Now we properly constrain the value of padlength so underflow shouldn't
be possible.

Samba 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>
This commit is contained in:
Joseph Sutton
2022-10-12 13:57:33 +13:00
committed by Nicolas Williams
parent 22749e918f
commit 2a4210b7e9

View File

@@ -124,7 +124,7 @@ unwrap_des
} else {
/* check pad */
ret = _gssapi_verify_pad(input_message_buffer,
input_message_buffer->length - len,
input_message_buffer->length - len - 8,
&padlength);
if (ret)
return ret;
@@ -292,7 +292,7 @@ unwrap_des3
} else {
/* check pad */
ret = _gssapi_verify_pad(input_message_buffer,
input_message_buffer->length - len,
input_message_buffer->length - len - 8,
&padlength);
if (ret)
return ret;