setopt: allow HTTP3 when HTTP2 is not defined

Reported-by: Karthikdasari0423 on github
Fixes #10538
Closes #10544
This commit is contained in:
Stefan Eissing 2023-02-17 10:17:06 +01:00 committed by Daniel Stenberg
parent 85721574ed
commit 72bb489543
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -895,22 +895,38 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* the listed enums in curl/curl.h.
*/
arg = va_arg(param, long);
if(arg < CURL_HTTP_VERSION_NONE)
return CURLE_BAD_FUNCTION_ARGUMENT;
#ifdef ENABLE_QUIC
if(arg == CURL_HTTP_VERSION_3)
;
else
#endif
#ifndef USE_HTTP2
if(arg >= CURL_HTTP_VERSION_2)
return CURLE_UNSUPPORTED_PROTOCOL;
#else
if(arg >= CURL_HTTP_VERSION_LAST)
return CURLE_UNSUPPORTED_PROTOCOL;
if(arg == CURL_HTTP_VERSION_NONE)
switch(arg) {
case CURL_HTTP_VERSION_NONE:
#ifdef USE_HTTP2
/* TODO: this seems an undesirable quirk to force a behaviour on
* lower implementations that they should recognize independantly? */
arg = CURL_HTTP_VERSION_2TLS;
#endif
/* accepted */
break;
case CURL_HTTP_VERSION_1_0:
case CURL_HTTP_VERSION_1_1:
/* accepted */
break;
#ifdef USE_HTTP2
case CURL_HTTP_VERSION_2_0:
case CURL_HTTP_VERSION_2TLS:
case CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE:
/* accepted */
break;
#endif
#ifdef ENABLE_QUIC
case CURL_HTTP_VERSION_3:
case CURL_HTTP_VERSION_3ONLY:
/* accepted */
break;
#endif
default:
/* not accepted */
if(arg < CURL_HTTP_VERSION_NONE)
return CURLE_BAD_FUNCTION_ARGUMENT;
return CURLE_UNSUPPORTED_PROTOCOL;
}
data->set.httpwant = (unsigned char)arg;
break;