Fix incorrect string length calculation (#76127)
authorSparin <sparin285@gmail.com>
Tue, 27 Sep 2022 15:33:33 +0000 (18:33 +0300)
committerGitHub <noreply@github.com>
Tue, 27 Sep 2022 15:33:33 +0000 (08:33 -0700)
commit94c6fe6cf5667967f6cf0ebc5c381501b8363b9b
tree8804da626efeeab3b8bb43ff4c7100e446e24db3
parent36bd4286032ac5d1c3e9b95ec31558fbb1c70902
Fix incorrect string length calculation (#76127)

ANSI string depends on system encoding charset. Unix's implementation of Marshal.StringToHGlobalAnsi encodes in UTF8. UTF8 characters which are out of 8-bit range (otcet) encodes in multiple bytes (otcets). ASCII characters usually are in 0x00-0x7F range but cyrillic and other characters are not. For example, 'Зфыы123;' (eq. 'Pass123$') will be encoded in 12 bytes instead of 8

Fix #76125
src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/LdapPal.Linux.cs