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

Fix memory leaks and improve error handling in req() function #47

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

SaSukiTB
Copy link
Contributor

@SaSukiTB SaSukiTB commented Feb 7, 2025

  1. Added curl_easy_cleanup(curl); to free resources after request
  2. Changed to 2L (Enforces full hostname verification)
  3. Added cleanup before calling error()
  4. Properly convert to C-string XorStr("keyauth.win").c_str()
  5. Proper Cleanup to Avoid Memory Leaks

Your original function doesn’t call curl_easy_cleanup(), which means CURL resources aren’t freed in case of errors.
this leads to memory leaks if the function is called multiple times (and its already called multiple times) almost every function
in keyAuth library use it.

Stronger SSL Security curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 1); only checks if the SSL certificate exists,
but does not verify the hostname properly.
Change it to curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
Enforces full hostname verification, preventing MITM attacks

1. Added curl_easy_cleanup(curl); to free resources after request
2. Changed to 2L (Enforces full hostname verification)
3. Added cleanup before calling error()
4. Properly convert to C-string XorStr("keyauth.win").c_str()
5. Proper Cleanup to Avoid Memory Leaks

Your original function doesn’t call curl_easy_cleanup(), which means CURL resources aren’t freed in case of errors.
this leads to memory leaks if the function is called multiple times (and its already called multiple times) almost every function 
in keyAuth library use it.

Stronger SSL Security curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 1); only checks if the SSL certificate exists, 
but does not verify the hostname properly.
Change it to curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
Enforces full hostname verification, preventing MITM attacks
Updated `req()` function declaration in `auth.hpp` to use `const std::string&` for parameters.
Copy link

github-actions bot commented Feb 7, 2025

The KeyAuth owner has been notified of your pull request. Please wait for him to review it. This could take several days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant