Navigation Menu

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 7.87.0 breaks zabbix' use of curl_easy_setopt #10148

Closed
0-wiz-0 opened this issue Dec 23, 2022 · 4 comments
Closed

curl 7.87.0 breaks zabbix' use of curl_easy_setopt #10148

0-wiz-0 opened this issue Dec 23, 2022 · 4 comments
Labels

Comments

@0-wiz-0
Copy link

0-wiz-0 commented Dec 23, 2022

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.

@bagder bagder added the build label Dec 23, 2022
@bagder
Copy link
Member

bagder commented Dec 23, 2022

/cc @monnerat

@bagder
Copy link
Member

bagder commented Dec 23, 2022

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

@0-wiz-0
Copy link
Author

0-wiz-0 commented Dec 23, 2022

Thanks, CURL_DISABLE_TYPECHECK works as well!

@monnerat
Copy link
Contributor

Confirmed. A tentative PR comes soon.

monnerat added a commit to monnerat/curl that referenced this issue Dec 23, 2022
monnerat added a commit to monnerat/curl that referenced this issue Dec 23, 2022
monnerat added a commit to monnerat/curl that referenced this issue Dec 23, 2022
As expressions can have side effects, evaluate only once.

To enable deprecation reporting only once, get rid of the __typeof__
use to define the local temporary variable and use the target type
(CURLoption/CURLINFO). This also avoids multiple reports on type
conflicts (if some) by the curlcheck_* macros.

Note that CURLOPT_* and CURLINFO_* symbols may be deprecated, but not
their values: a curl_easy_setopt call with an integer constant as option
will never report a deprecation.

Reported-by: Thomas Klausner
Fixes curl#10148
@bagder bagder closed this as completed in e2aed00 Dec 26, 2022
algitbot pushed a commit to alpinelinux/aports that referenced this issue Jan 12, 2023
algitbot pushed a commit to alpinelinux/aports that referenced this issue Jan 12, 2023
bell-sw pushed a commit to bell-sw/alpaquita-aports that referenced this issue Mar 16, 2023
[ commit f3e6f81620c2d24dc6ad0e7bd1fae057d3422bc3 ]

curl/curl#10146
curl/curl#10148
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants