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

CURL_GLOBAL_WIN32 should only control winsock #3313

jay opened this issue Nov 27, 2018 · 0 comments

CURL_GLOBAL_WIN32 should only control winsock #3313

jay opened this issue Nov 27, 2018 · 0 comments


Copy link

jay commented Nov 27, 2018


Lines 226 to 230 in 1966771

if(flags & CURL_GLOBAL_WIN32)
if(win32_init()) {
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));

CURL_GLOBAL_WIN32 is documented to control winsock initialization but controls win32_init which sounds (and is) more encompassing, as it does sspi initialization as well. I think we should split it off into win32_winsock_init for the flag and then a general win32_init that is always called, and we can move sspi init there.

This comes from my review of #3312, since it is only necessary to call QueryPerformanceFrequency once it makes more sense for us to do it at startup (like in win32_init) rather than every single time, and save the frequency in a global structure.

jay added a commit to jay/curl that referenced this issue Feb 16, 2019
- Change the behavior of win32_init so that the required initialization
  procedures are not affected by CURL_GLOBAL_WIN32 flag.

libcurl via curl_global_init supports initializing for win32 with an
optional flag CURL_GLOBAL_WIN32, which if omitted was meant to stop
Winsock initialization. It did so internally by skipping win32_init()
when that flag was set. Since then win32_init() has been expanded to
include required initialization routines that are separate from
Winsock and therefore must be called in all cases. This commit fixes
it so that CURL_GLOBAL_WIN32 only controls the optional win32
initialization (which is Winsock initialization, according to our doc).

The only users affected by this change are those that don't pass
CURL_GLOBAL_WIN32 to curl_global_init. For them this commit removes the
risk of a potential crash.

Ref: curl#3573

Fixes curl#3313
Closes #xxxx
@jay jay closed this as completed in f26bc29 Feb 18, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Successfully merging a pull request may close this issue.

2 participants