Skip to content

curl_easy_setopt type checking failed #6818

Closed

Description

@locpyl-tidnyd

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

Activity

  1. bagder commented on Mar 31, 2021

    @bagder
    Member

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

  2. added a commit that references this issue on Mar 31, 2021
    7d2355b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions