A possible small bug in SPNEGO handling when dealing with NETAPP server
From Richard Sharpe@21:1/5 to All on Mon Jun 29 15:22:22 2020
I have recently had to deal with a problem when calling
gss_init_sec_context after receiving an SPNEGO negTokenTarg from
NetApp C-Mode and 7-Mode servers.
After some investigation, I tracked it down to src/lib/gssapi/spnego/spnego_mech.c in get_mech_oid when handling the supportedMech OID.
The code was directly extracting the length from the buffer but (as
you can see from the capture attached in the Session Setup Response)
NetApp encodes the length of the OID in a longer form as 0x82 0x00
0x09 instead of the short-form 0x09.
To fix this I simply changed the code to call gssint_get_der_length to
retrieve the OID length. The following patch shows the change:
if (length < 1 || **buff_in != MECH_OID)
@@ -3264,9 +3265,11 @@
end = start + length;
- toid.length = *(*buff_in)++;
- if ((*buff_in + toid.length) > end)
+ /* Get the length in a way that allows more impls to work */
+ toid.length = gssint_get_der_length(buff_in, length - 1, &bytes);
+ if (toid.length < 0 || (*buff_in + toid.length) > end)