[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 56/73: setopt: avoid integer overflows when setting
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 56/73: setopt: avoid integer overflows when setting millsecond values |
Date: |
Tue, 24 Oct 2017 18:54:37 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 172ce9cc19a72342243c0cb06b2144ac16a84f89
Author: Daniel Stenberg <address@hidden>
AuthorDate: Tue Oct 3 17:00:18 2017 +0200
setopt: avoid integer overflows when setting millsecond values
... that are multiplied by 1000 when stored.
For 32 bit long systems, the max value accepted (2147483 seconds) is >
596 hours which is unlikely to ever be set by a legitimate application -
and previously it didn't work either, it just caused undefined behavior.
Also updated the man pages for these timeout options to mention the
return code.
Closes #1938
---
docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT.3 | 7 ++++---
docs/libcurl/opts/CURLOPT_FTP_RESPONSE_TIMEOUT.3 | 4 +++-
docs/libcurl/opts/CURLOPT_TIMEOUT.3 | 7 ++++---
lib/url.c | 18 +++++++++++++++---
4 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT.3
b/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT.3
index a4bf32e06..2adb9bb09 100644
--- a/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT.3
+++ b/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <address@hidden>, et al.
+.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <address@hidden>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@@ -58,7 +58,8 @@ if(curl) {
.SH AVAILABILITY
Always
.SH RETURN VALUE
-Returns CURLE_OK
+Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative
+value or a value that when converted to milliseconds is too large.
.SH "SEE ALSO"
-.BR CURLOPT_CONNECTTIMEOUT_MS "(3), "
+.BR CURLOPT_CONNECTTIMEOUT_MS "(3), "
.BR CURLOPT_TIMEOUT "(3), " CURLOPT_LOW_SPEED_LIMIT "(3), "
diff --git a/docs/libcurl/opts/CURLOPT_FTP_RESPONSE_TIMEOUT.3
b/docs/libcurl/opts/CURLOPT_FTP_RESPONSE_TIMEOUT.3
index cc8cc7b21..86b6073ff 100644
--- a/docs/libcurl/opts/CURLOPT_FTP_RESPONSE_TIMEOUT.3
+++ b/docs/libcurl/opts/CURLOPT_FTP_RESPONSE_TIMEOUT.3
@@ -54,7 +54,9 @@ if(curl) {
.SH AVAILABILITY
Added in 7.10.8
.SH RETURN VALUE
-Returns CURLE_OK if FTP is supported, and CURLE_UNKNOWN_OPTION if not.
+Returns CURLE_OK if FTP is supported, and CURLE_UNKNOWN_OPTION if not. Returns
+CURLE_BAD_FUNCTION_ARGUMENT if set to a negative value or a value that when
+converted to milliseconds is too large.
.SH "SEE ALSO"
.BR CURLOPT_TIMEOUT "(3), " CURLOPT_CONNECTTIMEOUT "(3), "
.BR CURLOPT_LOW_SPEED_LIMIT "(3), "
diff --git a/docs/libcurl/opts/CURLOPT_TIMEOUT.3
b/docs/libcurl/opts/CURLOPT_TIMEOUT.3
index 45e69b4d5..dafe142d0 100644
--- a/docs/libcurl/opts/CURLOPT_TIMEOUT.3
+++ b/docs/libcurl/opts/CURLOPT_TIMEOUT.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <address@hidden>, et al.
+.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <address@hidden>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@@ -64,7 +64,8 @@ if(curl) {
.SH AVAILABILITY
Always
.SH RETURN VALUE
-Returns CURLE_OK
+Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative
+value or a value that when converted to milliseconds is too large.
.SH "SEE ALSO"
-.BR CURLOPT_TIMEOUT_MS "(3), "
+.BR CURLOPT_TIMEOUT_MS "(3), "
.BR CURLOPT_CONNECTTIMEOUT "(3), " CURLOPT_LOW_SPEED_LIMIT "(3), "
diff --git a/lib/url.c b/lib/url.c
index 8eba5fd00..177952372 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -875,7 +875,11 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption
option,
* Option that specifies how quickly an server response must be obtained
* before it is considered failure. For pingpong protocols.
*/
- data->set.server_response_timeout = va_arg(param, long) * 1000;
+ arg = va_arg(param, long);
+ if((arg>=0) && (arg < (INT_MAX/1000)))
+ data->set.server_response_timeout = arg * 1000;
+ else
+ return CURLE_BAD_FUNCTION_ARGUMENT;
break;
case CURLOPT_TFTP_NO_OPTIONS:
/*
@@ -1725,7 +1729,11 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption
option,
* The maximum time you allow curl to use for a single transfer
* operation.
*/
- data->set.timeout = va_arg(param, long) * 1000L;
+ arg = va_arg(param, long);
+ if((arg>=0) && (arg < (INT_MAX/1000)))
+ data->set.timeout = arg * 1000;
+ else
+ return CURLE_BAD_FUNCTION_ARGUMENT;
break;
case CURLOPT_TIMEOUT_MS:
@@ -1736,7 +1744,11 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption
option,
/*
* The maximum time you allow curl to use to connect.
*/
- data->set.connecttimeout = va_arg(param, long) * 1000L;
+ arg = va_arg(param, long);
+ if((arg>=0) && (arg < (INT_MAX/1000)))
+ data->set.connecttimeout = arg * 1000;
+ else
+ return CURLE_BAD_FUNCTION_ARGUMENT;
break;
case CURLOPT_CONNECTTIMEOUT_MS:
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 39/73: test950; verify SMTP with custom request, (continued)
- [GNUnet-SVN] [gnurl] 39/73: test950; verify SMTP with custom request, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 30/73: curl: don't pass semicolons when parsing Content-Disposition, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 42/73: RELEASE-NOTES: synced with 5505df7d2, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 44/73: winbuild/BUILD.WINDOWS.txt: mention WITH_NGHTTP2, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 15/73: pingpong: return error when trying to send without connection, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 45/73: cli tool: reimplement stdin buffering in -F option., gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 67/73: ftp: reject illegal IP/port in PASV 227 response, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 54/73: ldap: silence clang warning, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 51/73: configure: remove the C++ compiler check, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 47/73: mime: keep "text/plain" content type if user-specified., gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 56/73: setopt: avoid integer overflows when setting millsecond values,
gnunet <=
- [GNUnet-SVN] [gnurl] 52/73: memdebug: trace send, recv and socket, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 64/73: test308: disable if MultiSSL feature enabled, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 71/73: THANKS: update at 7.56.1 release time, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 68/73: imap: if a FETCH response has no size, don't call write callback, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 61/73: os400: add missing symbols in config file., gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 17/73: remove_handle: call multi_done() first, then clear dns cache pointer, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 38/73: ftpserver: support case insensitive commands, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 16/73: multi_done: wait for name resolve to finish if still ongoing, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 06/73: docs: fix typo in curl_mime_data_cb man page, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 11/73: strtoofft: Remove extraneous null check, gnunet, 2017/10/24