From 9da034e1d453ea9136d13a4036862317ec2526c1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Dec 2013 13:53:45 +0100 Subject: [PATCH] s3:smbd: take less than SMB_BUFFER_SIZE_MIN ('500') as header overhead in ipc.c We're now sure that sconn->smb1.sessions.max_send is >= SMB_BUFFER_SIZE_MIN. in order to garantee some progress we need to make sure our assumed header overhead is less than SMB_BUFFER_SIZE_MIN. Assuming 372 bytes for the SMBtrans headers should still be more than enough. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10422 Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison (cherry picked from commit 2ec49cf57c88735be962b0681b487df5efe7ed6b) --- source3/smbd/ipc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index 91d5047c4c6..dbb259cedc2 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -109,12 +109,14 @@ void send_trans_reply(connection_struct *conn, int lparam = rparam ? rparam_len : 0; struct smbd_server_connection *sconn = req->sconn; int max_send = sconn->smb1.sessions.max_send; + /* HACK: make sure we send at least 128 byte in one go */ + int hdr_overhead = SMB_BUFFER_SIZE_MIN - 128; if (buffer_too_large) DEBUG(5,("send_trans_reply: buffer %d too large\n", ldata )); - this_lparam = MIN(lparam,max_send - 500); /* hack */ - this_ldata = MIN(ldata,max_send - (500+this_lparam)); + this_lparam = MIN(lparam,max_send - hdr_overhead); + this_ldata = MIN(ldata,max_send - (hdr_overhead+this_lparam)); align = ((this_lparam)%4); @@ -163,9 +165,9 @@ void send_trans_reply(connection_struct *conn, while (tot_data_sent < ldata || tot_param_sent < lparam) { this_lparam = MIN(lparam-tot_param_sent, - max_send - 500); /* hack */ + max_send - hdr_overhead); this_ldata = MIN(ldata -tot_data_sent, - max_send - (500+this_lparam)); + max_send - (hdr_overhead+this_lparam)); if(this_lparam < 0) this_lparam = 0; -- 2.11.4.GIT