Save and restore the Windows error around TlsGetValue.
authorDavid Benjamin <davidben@google.com>
Sun, 20 May 2018 21:24:30 +0000 (17:24 -0400)
committerDavid Benjamin <davidben@google.com>
Thu, 24 May 2018 19:49:33 +0000 (15:49 -0400)
commit1ae891c6b15e28b280845858326fb50ea5b61ac7
tree92b3941bbc56e8dc39dc339e26cb1661543b7e5d
parent926b21117df939241f1cd63f2f9e3ab87819f0ed
Save and restore the Windows error around TlsGetValue.

TlsGetValue clears the last error even on success, so that callers may
distinguish it successfully returning NULL or failing. This error-mangling
behavior interferes with the caller's use of GetLastError. In particular
SSL_get_error queries the error queue to determine whether the caller should
look at the OS's errors. To avoid destroying state, save and restore the
Windows error.

Fixes #6299.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 2de108dfa343c3e06eb98beb122cd06306bb12fd)

(Merged from https://github.com/openssl/openssl/pull/6349)
crypto/threads_win.c
test/build.info
test/errtest.c [new file with mode: 0644]
test/recipes/04-test_err.t [new file with mode: 0644]