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

error: -Wshorten-64-to-32 with openssl3 quic and Windows 64-bit #12861

Closed
dtretyakov opened this issue Feb 5, 2024 · 3 comments
Closed

error: -Wshorten-64-to-32 with openssl3 quic and Windows 64-bit #12861

dtretyakov opened this issue Feb 5, 2024 · 3 comments
Assignees

Comments

@dtretyakov
Copy link

I did this

Compile curl for Windows x86_64 with openssl3 and nghttp3:

vquic/curl_osslq.c:1081:30: error: implicit conversion loses integer precision: 'curl_socket_t' (aka 'unsigned long long') to 'int' [-Werror,-Wshorten-64-to-32]
 1081 |   bio = BIO_new_dgram(ctx->q.sockfd, BIO_NOCLOSE);
      |         ~~~~~~~~~~~~~ ~~~~~~~^~~~~~
1 error generated.

Configuration:

  Host setup:       x86_64-w64-mingw32
  Install prefix:   /data/curl
  Compiler:         x86_64-w64-mingw32-clang
   CFLAGS:          -DCARES_STATICLIB -DCURL_STATICLIB -DNGHTTP2_STATICLIB -DNGHTTP3_STATICLIB -DNGTCP2_STATICLIB -Qunused-arguments -O2 -pedantic -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wsign-compare -Wno-multichar -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wcast-align -Wno-system-headers -Wshorten-64-to-32 -Wunused -Waddress -Wattributes -Wbad-function-cast -Wconversion -Wdiv-by-zero -Wformat-security -Wempty-body -Wmissing-field-initializers -Wmissing-noreturn -Wold-style-definition -Wredundant-decls -Wtype-limits -Wunreachable-code -Wunused-parameter -Wignored-qualifiers -Wvla -Wsign-conversion -Wno-error=sign-conversion -Wshift-sign-overflow -Wlanguage-extension-token -Wformat=2 -Wenum-conversion -Wsometimes-uninitialized -Wheader-guard -Wunused-const-variable -Wpragmas -Wunreachable-code-break -Wdouble-promotion -Wcomma -Wassign-enum -Wextra-semi-stmt -Wimplicit-fallthrough -Wno-pointer-bool-conversion
   CPPFLAGS:        -isystem /opt/llvm-mingw/generic-w64-mingw32/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include
   LDFLAGS:         -L/opt/llvm-mingw/x86_64-w64-mingw32/lib -L/data/curl/lib -L/data/curl/lib64 -L/data/curl/lib -L/data/curl/lib -L/data/curl/lib -L/data/curl/lib64 -L/data/curl/lib -L/data/curl/lib64 -L/data/curl/lib -L/data/curl/lib64 -L/data/curl/lib -L/data/curl/lib -L/data/curl/lib -L/data/curl/lib
   LIBS:            -lcares -lws2_32 -liphlpapi -lnghttp3 -lnghttp2 -lidn2 -lunistring -lssh2 -lssh2 -lws2_32 -lssl -lcrypto -lws2_32 -lssl -lcrypto -lssl -lcrypto -lws2_32 -lgdi32 -lcrypt32 -lz -lpsl -lbcrypt -ladvapi32 -lcrypt32 -lssl -lcrypto -lssl -lcrypto -lws2_32 -lgdi32 -lcrypt32 -lgdi32 -lzstd -lzstd -lbrotlidec -lbrotlidec -lbrotlicommon -lz -lws2_32

Reference to the called function BIO *BIO_new_dgram(int fd, int close_flag).

I expected the following

No compilation error. As a worakround it's possible to disable convertion check -Wno-error=shorten-64-to-32

curl/libcurl version

curl 8.6.0

operating system

ubuntu 20.04, x86_64

@dtretyakov
Copy link
Author

To reproduce it's possible to uncomment the following line in build script:
https://github.com/stunnel/static-curl/blob/4e5e8b69d368a1aeea5f039528745b1207034c38/curl-static-win.sh#L619

and then run the following: ARCH=x86_64 CURL_VERSION=8.6.0 TLS_LIB=openssl sh curl-static-win.sh

@icing
Copy link
Contributor

icing commented Feb 5, 2024

Thanks for the report. That is indeed an unfortunate mix of OpenSSL's definition of a socket handle and Microsoft's choice of defining their SOCKET type on 64 bit platforms. See also this stackoverflow issue.

I'll add code that checks the SOCKET value before casting it to int explicitly. This will probably never fail, since Microsoft is unlikely to ever use the upper 32 bits and break many OpenSSL applications. But stranger things have happened.

@icing
Copy link
Contributor

icing commented Feb 5, 2024

Added #12865 for this.

@bagder bagder closed this as completed in d6825df Feb 5, 2024
bagder added a commit that referenced this issue Feb 5, 2024
... since I missed to give credit to the report in the fix of #12861
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants