windows: avoid length overflow in NewNTString

NewNTString initializes an NTString with RtlInitString, which cannot accurately represent sources whose NUL-terminated byte length exceeds MAX_USHORT. Reject strings whose byte representation cannot fit in the uint16 length fields before calling RtlInitString.

Add a boundary round-trip test for NTString.

Fixes golang/go#80103

Change-Id: Id38882a952330305e6c23d0adc86a8bf7920d30e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/793100
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
3 files changed
tree: 533cad1359465c66c0621aa5956858ba300d8918
  1. cpu/
  2. execabs/
  3. plan9/
  4. unix/
  5. windows/
  6. .gitattributes
  7. .gitignore
  8. codereview.cfg
  9. CONTRIBUTING.md
  10. go.mod
  11. LICENSE
  12. PATENTS
  13. README.md
README.md

sys

Go Reference

This repository holds supplemental Go packages for low-level interactions with the operating system.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://go.dev/doc/contribute.

The git repository is https://go.googlesource.com/sys.

The main issue tracker for the sys repository is located at https://go.dev/issues. Prefix your issue with “x/sys:” in the subject line, so it is easy to find.