From f66d30ffc2f6bb4f8b260a8731d0fef914062bd3 Mon Sep 17 00:00:00 2001 From: djm Date: Wed, 11 Jan 2023 05:39:38 +0000 Subject: [PATCH] clamp the minimum buffer lengths and number of inflight requests too --- usr.bin/ssh/sftp-client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usr.bin/ssh/sftp-client.c b/usr.bin/ssh/sftp-client.c index 1fc267f8a23..6d8123d69a9 100644 --- a/usr.bin/ssh/sftp-client.c +++ b/usr.bin/ssh/sftp-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-client.c,v 1.167 2023/01/11 05:36:50 djm Exp $ */ +/* $OpenBSD: sftp-client.c,v 1.168 2023/01/11 05:39:38 djm Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -550,6 +550,8 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests, SFTP_MAX_MSG_LENGTH - 1024); ret->upload_buflen = MINIMUM(limits.write_length, SFTP_MAX_MSG_LENGTH - 1024); + ret->download_buflen = MAXIMUM(ret->download_buflen, 64); + ret->upload_buflen = MAXIMUM(ret->upload_buflen, 64); debug3("server upload/download buffer sizes " "%llu / %llu; using %u / %u", (unsigned long long)limits.write_length, @@ -561,6 +563,8 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests, if (num_requests == 0 && limits.open_handles) { ret->num_requests = MINIMUM(DEFAULT_NUM_REQUESTS, limits.open_handles); + if (ret->num_requests == 0) + ret->num_requests = 1; debug3("server handle limit %llu; using %u", (unsigned long long)limits.open_handles, ret->num_requests); -- 2.20.1