From 8dfad9fa2cc5f9ae464a6df44c7ae0448cc4f3ab Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 14 May 2019 12:08:03 +1200 Subject: ldap_server: chunk the writev() calls at 25MB This should limit the amount we send to GENSEC at a time where it may help avoid large realloc or memcpy calls. Signed-off-by: Andrew Bartlett Reviewed-by: Gary Lockyer --- source4/ldap_server/ldap_server.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source4/ldap_server/ldap_server.c') diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c index 53e9af94888..4d3d8cd1188 100644 --- a/source4/ldap_server/ldap_server.c +++ b/source4/ldap_server/ldap_server.c @@ -683,9 +683,16 @@ static void ldapsrv_call_writev_start(struct ldapsrv_call *call) for (reply = call->replies; reply != NULL; reply = reply->next) { + + /* Cap output at 25MB per writev() */ + if (length > length + reply->blob.length + || length + reply->blob.length > LDAP_SERVER_MAX_CHUNK_SIZE) { + break; + } + /* * Overflow is harmless here, just used below to - * decide if to read or write + * decide if to read or write, but checkd above anyway */ length += reply->blob.length; -- cgit v1.2.1