include: mask computed auth/proto bitmasks to 32 bits

GCC 15.2 warns when assigning computed "all" bitmask macros to 32-bit
flag types because negated masks expand to the full width of unsigned
long/long on 64-bit platforms.

Mask these macros to a 32-bit domain so they do not set high bits and
avoid -Woverflow/-Wconversion warnings in callers.

Reported-by: Patrick Monnerat
Fixes #20242
Closes #20416
This commit is contained in:
Arnav-Purushotam-CUBoulder 2026-01-24 10:11:14 -07:00 committed by Daniel Stenberg
parent 2f8c9812b1
commit 9b20a672b8
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 9 additions and 6 deletions

View file

@ -842,10 +842,13 @@ typedef enum {
#define CURLAUTH_BEARER (((unsigned long)1) << 6)
#define CURLAUTH_AWS_SIGV4 (((unsigned long)1) << 7)
#define CURLAUTH_ONLY (((unsigned long)1) << 31)
#define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE)
#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC | CURLAUTH_DIGEST_IE))
#define CURLAUTH_ANY ((~CURLAUTH_DIGEST_IE) & \
((unsigned long)0xffffffff))
#define CURLAUTH_ANYSAFE ((~(CURLAUTH_BASIC | CURLAUTH_DIGEST_IE)) & \
((unsigned long)0xffffffff))
#define CURLSSH_AUTH_ANY ~0L /* all types supported by server */
/* all types supported by server */
#define CURLSSH_AUTH_ANY ((unsigned long)0xffffffff)
#define CURLSSH_AUTH_NONE 0L /* none allowed, silly but complete */
#define CURLSSH_AUTH_PUBLICKEY (1L << 0) /* public/private key files */
#define CURLSSH_AUTH_PASSWORD (1L << 1) /* password */
@ -1101,7 +1104,7 @@ typedef CURLSTScode (*curl_hstswrite_callback)(CURL *easy,
#define CURLPROTO_MQTT (1L << 28)
#define CURLPROTO_GOPHERS (1L << 29)
#define CURLPROTO_MQTTS (1L << 30)
#define CURLPROTO_ALL (~0L) /* enable everything */
#define CURLPROTO_ALL ((unsigned long)0xffffffff) /* enable everything */
/* long may be 32 or 64 bits, but we should never depend on anything else
but 32 */