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_easy_setopt type checking failed #6818

Closed
locpyl-tidnyd opened this issue Mar 31, 2021 · 1 comment
Closed

curl_easy_setopt type checking failed #6818

locpyl-tidnyd opened this issue Mar 31, 2021 · 1 comment
Labels

Comments

@locpyl-tidnyd
Copy link

@locpyl-tidnyd locpyl-tidnyd commented Mar 31, 2021

I am calling curl_easy_setopt to set an SSL context callback to use an in-memory CA store. My callback is declared as

static CURLcode
_curl_ssl_ctx_cb(CURL* curl, SSL_CTX* sslctx, void* param)

to avoid gratuitous casting from void* to SSL_CTX*. GCC 10.2.0 compiles this without warnings on -O0, but with optimization enabled it produces a typecheck warning:

In file included from ../curl/include/curl/curl.h:3024,
                 from daemon/main.c:17:
daemon/main.c: In function '_setup_ssl_curl':
../curl/include/curl/typecheck-gcc.h:80:13: warning: call to '_curl_easy_setopt_err_ssl_ctx_cb' declared with attribute warning: curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option [-Wattribute-warning]
   80 |             _curl_easy_setopt_err_ssl_ctx_cb();                         \
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../curl/include/curl/typecheck-gcc.h:80:13: note: in definition of macro 'curl_easy_setopt'
   80 |             _curl_easy_setopt_err_ssl_ctx_cb();                         \
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and of course with -Werror on compilation fails. Confusingly, GCC 9.3.0 on Linux compiles the same input without warnings regardless of optimization setting. The root cause appears to be that the callback declarations in curl/typecheck-gcc.h take SSL_CTX by value, whereas the actual callsite passes the SSL context by pointer, as it should (since SSL_CTX is an opaque struct). This issue is similar to #5432.

curl/libcurl version

libcurl 7.75.0

operating system

MINGW64_NT-10.0-1xxxxx REDACTED x86_64 Msys
gcc.exe (Rev9, Built by MSYS2 project) 10.2.0
@bagder
Copy link
Member

@bagder bagder commented Mar 31, 2021

To be clear, that's setting the CURLOPT_SSL_CTX_FUNCTION right?

bagder added a commit that referenced this issue Mar 31, 2021
... not value.

Reported-by: locpyl-tidnyd on github
Fixes #6818
@bagder bagder added the build label Mar 31, 2021
@bagder bagder closed this in 77db2a0 Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants