libcpr / cpr

C++ Requests: Curl for People, a spiritual port of Python Requests.
https://docs.libcpr.org/
Other
6.29k stars 903 forks source link

cpr not working on Windows XP because of missing ReleaseSRWLockExclusive in kernel32.dll #983

Closed zvanjak closed 6 months ago

zvanjak commented 7 months ago

Description

I am using cpr (as a static library, through vcpkg, Visual Studio 2022 as IDE) in my app for a simple task of posting zip file to web server after doing some analysis, it is perfect for the job and works flawlessly, but because the above mentioned function is only part of Windows Vista onward, I can't use my app on Windows XP.

So, what are my options if I really, really must run it on Win XP?

I did some investigation and those SRW functions added on Vista are for performance improvements, so I figure it might be possible to use older functions instead of them, but before digging into cpr source, I figure it is best to see what others have to say (maybe I am on the wrong track, or there is a simple(r) solution).

Code where I am using cpr is really, really simple:

cpr::Response resp = Post(cpr::Url{webAddress + "/scan?filename=" + fileToUpload},
                                          cpr::Multipart{{"filename", cpr::File{fileToUpload}}});

Example/How to Reproduce

  1. using cpr as static library on Windows XP

Possible Fix

No response

Where did you get it from?

vcpkg

Additional Context/Your Environment

ts826848 commented 7 months ago

Looks like ReleaseSRWLockExclusive might be from curl rather than cpr.

It appears curl added the call in 23af112f5556d6a785c17e09f2422ac931405f61, which was first included in curl 7.84.0.

cpr upgraded curl from 7.80.0 to 8.4.0 relatively recently. Downgrading to curl 7.83.0 or earlier might allow you to use cpr on Windows XP, though obviously you'd be missing out on bugfixes/features from 7.84.0 and later.

An alternative would be to replace the AcquireSRWLockExclusive/ReleaseSRWLockExclusive calls in curl with corresponding Windows XP calls if there are any. I have no idea how easy/hard that may be, though.

COM8 commented 7 months ago

@ts826848 thanks for looking into this!

Yes, we updated curl to 8.4.0 to circumvent CVE-2023-38545. But if you are not using SOCKS5 poxy, you can downgrade curl to <= 7.83.0 and it should all work with WindowsXP.

zvanjak commented 7 months ago

Thank you both for quick response, it is greatly appreciated 🤗.

So, if I really must do it, course of action is: fork current cpr, downgrade curl that it uses to 7.83¸, build new static libraries and deploy instead of current ones.

No way it is going to be that easy 🤣, but it is a plan.

COM8 commented 7 months ago

@zvanjak try using older cpr versions first that ship with older curl versions, as mentioned in my comment. This should fix your issues.

COM8 commented 6 months ago

Closing as no further response. Feel free to reopen if the issue persists.