Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insonsitencies with usage of _WIN32_WINNT #24367

Open
edo9300 opened this issue May 10, 2024 · 1 comment
Open

Insonsitencies with usage of _WIN32_WINNT #24367

edo9300 opened this issue May 10, 2024 · 1 comment
Labels
branch: master Merge to master branch branch: 3.2 Merge to openssl-3.2 branch: 3.3 Merge to openssl-3.3 help wanted triaged: bug The issue/pr is/fixes a bug

Comments

@edo9300
Copy link

edo9300 commented May 10, 2024

Openssl has some logic in e_os.h to define the macro _WIN32_WINNT if not set by externally by the compiler, and then takes care of including windows.h.

# if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
/*
* Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
* Most notably we ought to check for availability of each specific
* routine that was introduced after denoted _WIN32_WINNT with
* GetProcAddress(). Normally newer functions are masked with higher
* _WIN32_WINNT in SDK headers. So that if you wish to use them in
* some module, you'd need to override _WIN32_WINNT definition in
* the target module in order to "reach for" prototypes, but replace
* calls to new functions with indirect calls. Alternatively it
* might be possible to achieve the goal by /DELAYLOAD-ing .DLLs
* and check for current OS version instead.
*/
# define _WIN32_WINNT 0x0501
# endif
# if defined(_WIN32_WINNT) || defined(_WIN32_WCE)

Supposedly this file should be the only one to be used internally by openssl to include windows headers, but in various places windows.h is included directly on top of the file, for example
#if defined(_WIN32)
# include <windows.h>
# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600
# define USE_RWLOCK
# endif
#endif

In other cases, depending on other internal headers included beforehand, either windows.h is manually included first, or it's included through e_os.h due to chain dependencies, in this case e_os.h is included by time-h
# include <openssl/configuration.h>
# include <openssl/e_os2.h>
# include "internal/time.h"
# if defined(_WIN32)
# include <windows.h>
# endif

These inconsistencies could lead to some files being possibly built with _WIN32_WINNT defined as 0x501 (if e_os is inclded first and it's not changed externally), while others being built with whatever the current sdk sets as default.

@edo9300 edo9300 added the issue: bug report The issue was opened to report a bug label May 10, 2024
@t8m t8m added branch: master Merge to master branch help wanted branch: 3.2 Merge to openssl-3.2 branch: 3.3 Merge to openssl-3.3 triaged: bug The issue/pr is/fixes a bug and removed issue: bug report The issue was opened to report a bug labels May 13, 2024
@t8m
Copy link
Member

t8m commented May 13, 2024

Yeah, windows.h should not be included directly. It should always be included via internal/e_os.h.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch: master Merge to master branch branch: 3.2 Merge to openssl-3.2 branch: 3.3 Merge to openssl-3.3 help wanted triaged: bug The issue/pr is/fixes a bug
Projects
Status: New
Development

No branches or pull requests

2 participants