Skip to content

curl 7.87.0 breaks zabbix' use of curl_easy_setopt #10148

Closed

Description

@0-wiz-0

I did this

Compile zabbix-5.0.17 after updating curl from 7.86.0 to 7.87.0.

zabbix uses the following piece of code to set options:

        if (CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_USERAGENT, "Zabbix " ZABBIX_VERSION)) ||
                CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_URL, https_host)) ||
                CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_PORT, (long)port)) ||
                CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_NOBODY, 1L)) ||
                CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_SSL_VERIFYPEER, 0L)) ||
                CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_SSL_VERIFYHOST, 0L)) ||
                CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_TIMEOUT, (long)timeout)))
        {
                zabbix_log(LOG_LEVEL_DEBUG, "%s: could not set cURL option [%d]: %s",
                                __func__, (int)opt, curl_easy_strerror(err));
                goto clean;
        }

i.e. it sets a variable for the value it passes to have better error messages if one of them fails by using that variable, in a compact way.

This code broke with the recent deprecation macro changes. zabbix now fails to compile with:

In file included from /home/pbulk/build/sysutils/zabbix50-agent/work/.buildlink/include/curl/curl.h:3195,
                 from ../../../../include/sysinc.h:384,
                 from ../../../../include/common.h:23,
                 from simple.c:20:
simple.c: In function 'check_https':
simple.c:167:65: error: invalid use of void expression
  167 |         if (CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_USERAGENT, "Zabbix " ZABBIX_VERSION)) ||
      |                                                                 ^
/home/pbulk/build/sysutils/zabbix50-agent/work/.buildlink/include/curl/typecheck-gcc.h:47:16: note: in definition of macro 'curl_easy_setopt'
   47 |         (void) option;                                                  \
      |                ^~~~~~
simple.c:168:69: error: invalid use of void expression
  168 |                 CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_URL, https_host)) ||
      |                                                                     ^
/home/pbulk/build/sysutils/zabbix50-agent/work/.buildlink/include/curl/typecheck-gcc.h:47:16: note: in definition of macro 'curl_easy_setopt'
   47 |         (void) option;                                                  \
      |                ^~~~~~
simple.c:169:69: error: invalid use of void expression
  169 |                 CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_PORT, (long)port)) ||
      |                                                                     ^
/home/pbulk/build/sysutils/zabbix50-agent/work/.buildlink/include/curl/typecheck-gcc.h:47:16: note: in definition of macro 'curl_easy_setopt'
   47 |         (void) option;                                                  \
      |                ^~~~~~
simple.c:170:69: error: invalid use of void expression
  170 |                 CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_NOBODY, 1L)) ||
      |                                                                     ^
/home/pbulk/build/sysutils/zabbix50-agent/work/.buildlink/include/curl/typecheck-gcc.h:47:16: note: in definition of macro 'curl_easy_setopt'
   47 |         (void) option;                                                  \
      |                ^~~~~~
simple.c:171:69: error: invalid use of void expression
  171 |                 CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_SSL_VERIFYPEER, 0L)) ||
      |                                                                     ^
/home/pbulk/build/sysutils/zabbix50-agent/work/.buildlink/include/curl/typecheck-gcc.h:47:16: note: in definition of macro 'curl_easy_setopt'
   47 |         (void) option;                                                  \
      |                ^~~~~~
simple.c:172:69: error: invalid use of void expression
  172 |                 CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_SSL_VERIFYHOST, 0L)) ||
      |                                                                     ^
/home/pbulk/build/sysutils/zabbix50-agent/work/.buildlink/include/curl/typecheck-gcc.h:47:16: note: in definition of macro 'curl_easy_setopt'
   47 |         (void) option;                                                  \
      |                ^~~~~~
simple.c:173:69: error: invalid use of void expression
  173 |                 CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_TIMEOUT, (long)timeout)))
      |                                                                     ^
/home/pbulk/build/sysutils/zabbix50-agent/work/.buildlink/include/curl/typecheck-gcc.h:47:16: note: in definition of macro 'curl_easy_setopt'
   47 |         (void) option;                                                  \
      |                ^~~~~~
simple.c:182:73: error: invalid use of void expression
  182 |                 if (CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_INTERFACE, CONFIG_SOURCE_IP)))
      |                                                                         ^
/home/pbulk/build/sysutils/zabbix50-agent/work/.buildlink/include/curl/typecheck-gcc.h:47:16: note: in definition of macro 'curl_easy_setopt'
   47 |         (void) option;                                                  \
      |                ^~~~~~

Perhaps there's a way to write the deprecation macro that doesn't break zabbix' code?

(My workaround was to remove the 'opt' assignments.)

I expected the following

zabbix to still build.

curl/libcurl version

# curl -V
curl 7.87.0 (x86_64--netbsd) libcurl/7.87.0 OpenSSL/1.1.1n zlib/1.2.13 libidn2/2.3.4 nghttp2/1.51.0
Release-Date: 2022-12-21
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB SPNEGO SSL threadsafe TLS-SRP UnixSockets

operating system

NetBSD 9.99.106/amd64, but I don't think that's relevant here, this is with gcc 10.4.0 and will most probably happen on other platforms as well.

Activity

  1. bagder commented on Dec 23, 2022

    @bagder
    Member
  2. bagder commented on Dec 23, 2022

    @bagder
    Member

    Another work-around is to define CURL_DISABLE_TYPECHECK in the build.

  3. 0-wiz-0 commented on Dec 23, 2022

    @0-wiz-0
    ContributorAuthor

    Thanks, CURL_DISABLE_TYPECHECK works as well!

  4. monnerat commented on Dec 23, 2022

    @monnerat
    Contributor

    Confirmed. A tentative PR comes soon.

  5. added a commit that references this issue on Mar 16, 2023
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