The vulnerability (CVE-2024-37371) describes invalid memory reads during GSS message token handling due to invalid length fields. The provided commit (55fbf435edbe2e92dd8101669b1ce7144bc96fef) modifies three key functions involved in unsealing GSS tokens: gss_krb5int_unseal_token_v3, gss_krb5int_unseal_v3_iov, and kg_unseal_iov_token.
In gss_krb5int_unseal_token_v3, new checks are added to validate the plaintext length and the 'Extra Count' (ec) field within the token header.
In gss_krb5int_unseal_v3_iov, a similar check for the 'Extra Count' field is added.
In kg_unseal_iov_token, the logic for parsing and validating the ASN.1 wrapper and token header lengths is significantly refactored, introducing a new helper function verify_detached_wrapper.
These changes directly address the vulnerability by adding stricter validation of length fields within the GSS tokens processed by these functions. The commit message further corroborates this by detailing the fixes for CVE-2024-37370 and CVE-2024-37371, explicitly mentioning these functions and the nature of the fixes related to length validation. The test file t_invalid.c was also updated to include test cases for these specific scenarios, further confirming the vulnerable code paths in the original versions of these functions.