urlapi: typecast CURLU_URLDECODE to uint when toggling it off

In this use case 'unsigned value &= ~DEFINE;'

As otherwise the right side is treated as signed, which annoyingly
triggers UBSan.

Reported-by: xmoezzz on github
Fixes #20753
This commit is contained in:
Daniel Stenberg 2026-02-28 10:48:59 +01:00
parent 4b583b7585
commit 454181cd66
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -1555,7 +1555,7 @@ CURLUcode curl_url_get(const CURLU *u, CURLUPart what,
case CURLUPART_SCHEME:
ptr = u->scheme;
ifmissing = CURLUE_NO_SCHEME;
flags &= ~CURLU_URLDECODE; /* never for schemes */
flags &= ~(unsigned int)CURLU_URLDECODE; /* never for schemes */
if((flags & CURLU_NO_GUESS_SCHEME) && u->guessed_scheme)
return CURLUE_NO_SCHEME;
break;
@ -1582,7 +1582,7 @@ CURLUcode curl_url_get(const CURLU *u, CURLUPart what,
case CURLUPART_PORT:
ptr = u->port;
ifmissing = CURLUE_NO_PORT;
flags &= ~CURLU_URLDECODE; /* never for port */
flags &= ~(unsigned int)CURLU_URLDECODE; /* never for port */
if(!ptr && (flags & CURLU_DEFAULT_PORT) && u->scheme) {
/* there is no stored port number, but asked to deliver
a default one for the scheme */