From 0f34102c926d307023a15778a36ac8163a9e02fe Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 19 Jan 2021 17:02:21 +0100 Subject: fixup assert that the minimum buffer size is larger enough for SOCKS --- lib/socks.c | 3 +++ lib/url.h | 16 ---------------- lib/urldata.h | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/socks.c b/lib/socks.c index 64ebbec74..9252e2c17 100644 --- a/lib/socks.c +++ b/lib/socks.c @@ -203,6 +203,9 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user, ssize_t actualread; ssize_t written; + /* make sure that the buffer is at least 600 bytes */ + DEBUGASSERT(READBUFFER_MIN >= 600); + if(!SOCKS_STATE(sx->state) && !*done) sxstate(data, CONNECT_SOCKS_INIT); diff --git a/lib/url.h b/lib/url.h index 6c71c1f75..ce4870ea6 100644 --- a/lib/url.h +++ b/lib/url.h @@ -23,22 +23,6 @@ ***************************************************************************/ #include "curl_setup.h" -#define READBUFFER_SIZE CURL_MAX_WRITE_SIZE -#define READBUFFER_MAX CURL_MAX_READ_SIZE -#define READBUFFER_MIN 1024 - -/* The default upload buffer size, should not be smaller than - CURL_MAX_WRITE_SIZE, as it needs to hold a full buffer as could be sent in - a write callback. - - The size was 16KB for many years but was bumped to 64KB because it makes - libcurl able to do significantly faster uploads in some circumstances. Even - larger buffers can help further, but this is deemed a fair memory/speed - compromise. */ -#define UPLOADBUFFER_DEFAULT 65536 -#define UPLOADBUFFER_MAX (2*1024*1024) -#define UPLOADBUFFER_MIN CURL_MAX_WRITE_SIZE - /* * Prototypes for library-wide functions provided by url.c */ diff --git a/lib/urldata.h b/lib/urldata.h index 4afcbf9be..e00d035f1 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -160,6 +160,22 @@ typedef CURLcode (*Curl_datastream)(struct Curl_easy *data, #include #endif /* HAVE_LIBSSH2_H */ +#define READBUFFER_SIZE CURL_MAX_WRITE_SIZE +#define READBUFFER_MAX CURL_MAX_READ_SIZE +#define READBUFFER_MIN 1024 + +/* The default upload buffer size, should not be smaller than + CURL_MAX_WRITE_SIZE, as it needs to hold a full buffer as could be sent in + a write callback. + + The size was 16KB for many years but was bumped to 64KB because it makes + libcurl able to do significantly faster uploads in some circumstances. Even + larger buffers can help further, but this is deemed a fair memory/speed + compromise. */ +#define UPLOADBUFFER_DEFAULT 65536 +#define UPLOADBUFFER_MAX (2*1024*1024) +#define UPLOADBUFFER_MIN CURL_MAX_WRITE_SIZE + #define CURLEASY_MAGIC_NUMBER 0xc0dedbadU #define GOOD_EASY_HANDLE(x) \ ((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER)) -- cgit v1.2.1