windows: do not write LastStatus parameter of TEB when converting errors

The prior function updated the TEB's LastStatus member, which is not
what we want to be doing here. It's also not consistent with Microsoft's
own Go code for their pipe library, which properly uses the "NoTeb"
variant like this commit.

For good measure, we add a simple test case to make sure these paths are
being exercised.

Change-Id: I4080898f704bdc93a6048001b06ffce516fb412d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/298169
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Jason A. Donenfeld
2021-03-04 15:22:09 +00:00
parent 50617c2ba1
commit afaa3650a9
3 changed files with 13 additions and 5 deletions
+8
View File
@@ -494,3 +494,11 @@ func TestNTStatusString(t *testing.T) {
t.Errorf("NTStatus.Error did not return an expected error string - want %q; got %q", want, got)
}
}
func TestNTStatusConversion(t *testing.T) {
want := windows.ERROR_TOO_MANY_NAMES
got := windows.STATUS_TOO_MANY_NAMES.Errno()
if want != got {
t.Errorf("NTStatus.Errno = %q (0x%x); want %q (0x%x)", got.Error(), got, want.Error(), want)
}
}