From: Daniel Stenberg Date: Tue, 31 May 2022 11:42:35 +0000 (+0200) Subject: urldata: store tcp_keepidle and tcp_keepintvl as ints X-Git-Tag: curl-7_84_0~104 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8b1ae28509b998676585c37e967fee70dad1cf23;p=thirdparty%2Fcurl.git urldata: store tcp_keepidle and tcp_keepintvl as ints They can't be set larger than INT_MAX in the setsocket API calls. Also document the max values in their respective man pages. Closes #8940 --- diff --git a/docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.3 b/docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.3 index 020d20ea02..7d803faef4 100644 --- a/docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.3 +++ b/docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.3 @@ -5,7 +5,7 @@ .\" * | (__| |_| | _ <| |___ .\" * \___|\___/|_| \_\_____| .\" * -.\" * Copyright (C) 1998 - 2021, Daniel Stenberg, , et al. +.\" * Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. .\" * .\" * This software is licensed as described in the file COPYING, which .\" * you should have received as part of this distribution. The terms @@ -33,6 +33,9 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPIDLE, long delay); Pass a long. Sets the \fIdelay\fP, in seconds, that the operating system will wait while the connection is idle before sending keepalive probes. Not all operating systems support this option. + +The maximum value this accepts is 2147483648. Any larger value will be capped +to this amount. .SH DEFAULT 60 .SH PROTOCOLS diff --git a/docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.3 b/docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.3 index a157e7fbea..4e5e94c363 100644 --- a/docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.3 +++ b/docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.3 @@ -5,7 +5,7 @@ .\" * | (__| |_| | _ <| |___ .\" * \___|\___/|_| \_\_____| .\" * -.\" * Copyright (C) 1998 - 2021, Daniel Stenberg, , et al. +.\" * Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. .\" * .\" * This software is licensed as described in the file COPYING, which .\" * you should have received as part of this distribution. The terms @@ -33,6 +33,9 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPINTVL, long interval); Pass a long. Sets the interval, in seconds, that the operating system will wait between sending keepalive probes. Not all operating systems support this option. (Added in 7.25.0) + +The maximum value this accepts is 2147483648. Any larger value will be capped +to this amount. .SH DEFAULT 60 .SH PROTOCOLS diff --git a/lib/setopt.c b/lib/setopt.c index fa3c4766f3..221ee4b409 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -2818,13 +2818,17 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) arg = va_arg(param, long); if(arg < 0) return CURLE_BAD_FUNCTION_ARGUMENT; - data->set.tcp_keepidle = arg; + else if(arg > INT_MAX) + arg = INT_MAX; + data->set.tcp_keepidle = (int)arg; break; case CURLOPT_TCP_KEEPINTVL: arg = va_arg(param, long); if(arg < 0) return CURLE_BAD_FUNCTION_ARGUMENT; - data->set.tcp_keepintvl = arg; + else if(arg > INT_MAX) + arg = INT_MAX; + data->set.tcp_keepintvl = (int)arg; break; case CURLOPT_TCP_FASTOPEN: #if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN) || \ diff --git a/lib/urldata.h b/lib/urldata.h index 63026063a5..3b70439718 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1770,8 +1770,8 @@ struct UserDefined { long gssapi_delegation; /* GSS-API credential delegation, see the documentation of CURLOPT_GSSAPI_DELEGATION */ - long tcp_keepidle; /* seconds in idle before sending keepalive probe */ - long tcp_keepintvl; /* seconds between TCP keepalive probes */ + int tcp_keepidle; /* seconds in idle before sending keepalive probe */ + int tcp_keepintvl; /* seconds between TCP keepalive probes */ size_t maxconnects; /* Max idle connections in the connection cache */