# HG changeset patch # User Matt Johnston # Date 1634052730 -28800 # Node ID 94dc11094e263b571fbeb6d6ba90cd57a490af5a # Parent 870f6e386a0bb2919c705d44369bd820f67540d2 Increase max window size to 10MB, fallback rather than exiting if an invalid value is given. diff -r 870f6e386a0b -r 94dc11094e26 cli-runopts.c --- a/cli-runopts.c Tue Oct 12 23:31:09 2021 +0800 +++ b/cli-runopts.c Tue Oct 12 23:32:10 2021 +0800 @@ -79,7 +79,7 @@ #if DROPBEAR_CLI_REMOTETCPFWD "-R <[listenaddress:]listenport:remotehost:remoteport> Remote port forwarding\n" #endif - "-W (default %d, larger may be faster, max 1MB)\n" + "-W (default %d, larger may be faster, max 10MB)\n" "-K (0 is never, default %d)\n" "-I (0 is never, default %d)\n" #if DROPBEAR_CLI_NETCAT @@ -451,12 +451,9 @@ && cli_opts.no_cmd == 0) { dropbear_exit("Command required for -f"); } - + if (recv_window_arg) { - opts.recv_window = atol(recv_window_arg); - if (opts.recv_window == 0 || opts.recv_window > MAX_RECV_WINDOW) { - dropbear_exit("Bad recv window '%s'", recv_window_arg); - } + parse_recv_window(recv_window_arg); } if (keepalive_arg) { unsigned int val; diff -r 870f6e386a0b -r 94dc11094e26 common-runopts.c --- a/common-runopts.c Tue Oct 12 23:31:09 2021 +0800 +++ b/common-runopts.c Tue Oct 12 23:32:10 2021 +0800 @@ -101,4 +101,20 @@ fprintf(stderr, "Dropbear v%s\n", DROPBEAR_VERSION); } +void parse_recv_window(const char* recv_window_arg) { + int ret; + unsigned int rw; + ret = m_str_to_uint(recv_window_arg, &rw); + if (ret == DROPBEAR_FAILURE || rw == 0 || rw > MAX_RECV_WINDOW) { + if (rw > MAX_RECV_WINDOW) { + opts.recv_window = MAX_RECV_WINDOW; + } + dropbear_log(LOG_WARNING, "Bad recv window '%s', using %d", + recv_window_arg, opts.recv_window); + } else { + opts.recv_window = rw; + } + +} + diff -r 870f6e386a0b -r 94dc11094e26 runopts.h --- a/runopts.h Tue Oct 12 23:31:09 2021 +0800 +++ b/runopts.h Tue Oct 12 23:32:10 2021 +0800 @@ -195,5 +195,6 @@ #endif void print_version(void); +void parse_recv_window(const char* recv_window_arg); #endif /* DROPBEAR_RUNOPTS_H_ */ diff -r 870f6e386a0b -r 94dc11094e26 svr-runopts.c --- a/svr-runopts.c Tue Oct 12 23:31:09 2021 +0800 +++ b/svr-runopts.c Tue Oct 12 23:32:10 2021 +0800 @@ -100,7 +100,7 @@ #if INETD_MODE "-i Start for inetd\n" #endif - "-W (default %d, larger may be faster, max 1MB)\n" + "-W (default %d, larger may be faster, max 10MB)\n" "-K (0 is never, default %d, in seconds)\n" "-I (0 is never, default %d, in seconds)\n" #if DROPBEAR_PLUGIN @@ -385,12 +385,9 @@ } } #endif - + if (recv_window_arg) { - opts.recv_window = atol(recv_window_arg); - if (opts.recv_window == 0 || opts.recv_window > MAX_RECV_WINDOW) { - dropbear_exit("Bad recv window '%s'", recv_window_arg); - } + parse_recv_window(recv_window_arg); } if (maxauthtries_arg) { @@ -402,7 +399,7 @@ svr_opts.maxauthtries = val; } - + if (keepalive_arg) { unsigned int val; if (m_str_to_uint(keepalive_arg, &val) == DROPBEAR_FAILURE) { diff -r 870f6e386a0b -r 94dc11094e26 sysoptions.h --- a/sysoptions.h Tue Oct 12 23:31:09 2021 +0800 +++ b/sysoptions.h Tue Oct 12 23:32:10 2021 +0800 @@ -196,7 +196,7 @@ #define RECV_WINDOWEXTEND (opts.recv_window / 3) /* We send a "window extend" every RECV_WINDOWEXTEND bytes */ -#define MAX_RECV_WINDOW (1024*1024) /* 1 MB should be enough */ +#define MAX_RECV_WINDOW (10*1024*1024) /* 10 MB should be enough */ #define MAX_CHANNELS 1000 /* simple mem restriction, includes each tcp/x11 connection, so can't be _too_ small */