Fix ManagedNtlm on big-endian architectures#124598
Conversation
|
Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones |
src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.ManagedNtlm.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.ManagedNtlm.cs
Outdated
Show resolved
Hide resolved
| readonly get =>BitConverter.IsLittleEndian? _payloadOffset: BinaryPrimitives.ReverseEndianness(_payloadOffset); | ||
| set =>_payloadOffset = BitConverter.IsLittleEndian? value: BinaryPrimitives.ReverseEndianness(value); |
There was a problem hiding this comment.
Nit:
| readonly get =>BitConverter.IsLittleEndian? _payloadOffset: BinaryPrimitives.ReverseEndianness(_payloadOffset); | |
| set =>_payloadOffset = BitConverter.IsLittleEndian? value: BinaryPrimitives.ReverseEndianness(value); | |
| readonly get => BitConverter.IsLittleEndian? _payloadOffset: BinaryPrimitives.ReverseEndianness(_payloadOffset); | |
| set => _payloadOffset = BitConverter.IsLittleEndian? value: BinaryPrimitives.ReverseEndianness(value); |
| readonly get =>BitConverter.IsLittleEndian? _productBuild: BinaryPrimitives.ReverseEndianness(_productBuild); | ||
| set =>_productBuild = BitConverter.IsLittleEndian? value: BinaryPrimitives.ReverseEndianness(value); |
There was a problem hiding this comment.
| readonly get =>BitConverter.IsLittleEndian? _productBuild: BinaryPrimitives.ReverseEndianness(_productBuild); | |
| set =>_productBuild = BitConverter.IsLittleEndian? value: BinaryPrimitives.ReverseEndianness(value); | |
| readonly get => BitConverter.IsLittleEndian? _productBuild: BinaryPrimitives.ReverseEndianness(_productBuild); | |
| set => _productBuild = BitConverter.IsLittleEndian? value: BinaryPrimitives.ReverseEndianness(value); |
| readonly get =>BitConverter.IsLittleEndian? _flags: (Flags)BinaryPrimitives.ReverseEndianness((uint)_flags); | ||
| set =>_flags = BitConverter.IsLittleEndian? value: (Flags)BinaryPrimitives.ReverseEndianness((uint)value); |
There was a problem hiding this comment.
| readonly get =>BitConverter.IsLittleEndian? _flags: (Flags)BinaryPrimitives.ReverseEndianness((uint)_flags); | |
| set =>_flags = BitConverter.IsLittleEndian? value: (Flags)BinaryPrimitives.ReverseEndianness((uint)value); | |
| readonly get => BitConverter.IsLittleEndian? _flags: (Flags)BinaryPrimitives.ReverseEndianness((uint)_flags); | |
| set => _flags = BitConverter.IsLittleEndian? value: (Flags)BinaryPrimitives.ReverseEndianness((uint)value); |
|
MemoryMarshal.AsRef is writing the fields in little-endian, not in the correct byte order overwriting the struct fields with little-endian data. |
|
MemoryMarshal.AsRef is not writing anything, if you cast Can you point to the specific piece of code where you see the problem, or give a code example where the pattern does not work? |
|
https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.ManagedNtlm.cs#L582 Here, challengeMessage.TargetInfo.Length and challengeMessage.TargetInfo.MaximumLength are endian flipped. Can you help me with this? |
|
I believe that is because the Length and MaximumLength fields are not corrected for endianness when reading |
Fixes multiple endianness bugs in ManagedNtlm that caused incorrect behavior on big-endian platforms. Validated via existing Ntlm test cases.
|
@rzikm I think runtime/src/libraries/Common/tests/System/Net/Security/FakeNtlmServer.cs Lines 306 to 307 in c30eec2 we don't write in little endian order here, since while the original commit did handle this (the case where the test passed) can't we reuse those? |
- Fixed several endian bugs in ManagedNTLM implementation. - This is a follow-up to PR dotnet#124598
|
#125039 should be addressing these, let's move conversation there if necessary. |
Fixes multiple endianness bugs in ManagedNtlm that caused incorrect behavior on big-endian platforms.
Validated via existing Ntlm test cases.