The x/sys/windows.NewNTString helper currently delegates length initialization to RtlInitString and does not reject strings that cannot fit in NTString's uint16 Length and MaximumLength fields. For overlong inputs, RtlInitString cannot accurately represent the source string, and the resulting NTString can have inconsistent length fields.
NewNTUnicodeString already rejects inputs that cannot fit in the corresponding 16-bit fields. NewNTString should do the same for ANSI strings and return syscall.EINVAL instead of returning a malformed NTString.
A pending fix and regression test are in CL 793100:
https://go-review.googlesource.com/c/sys/+/793100
Related GitHub PR:
golang/sys#281
The x/sys/windows.NewNTString helper currently delegates length initialization to RtlInitString and does not reject strings that cannot fit in NTString's uint16 Length and MaximumLength fields. For overlong inputs, RtlInitString cannot accurately represent the source string, and the resulting NTString can have inconsistent length fields.
NewNTUnicodeString already rejects inputs that cannot fit in the corresponding 16-bit fields. NewNTString should do the same for ANSI strings and return syscall.EINVAL instead of returning a malformed NTString.
A pending fix and regression test are in CL 793100:
https://go-review.googlesource.com/c/sys/+/793100
Related GitHub PR:
golang/sys#281