From b088f85d42a05a6c0c8418c02a67b48864ba95a3 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 May 2017 12:23:42 +0100 Subject: [PATCH] rpc: Double buffer size instead of quadrupling buffer size. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When increasing the buffer size up to VIR_NET_MESSAGE_MAX, we currently quadruple it each time. This unfortunately means that we cannot allow certain buffer sizes -- for example the current VIR_NET_MESSAGE_MAX == 33554432 can never be "hit" since ‘newlen’ jumps from 16MB to 64MB. Instead of quadrupling, double it each time. Thanks: Daniel Berrange. Signed-off-by: Richard W.M. Jones --- src/rpc/virnetmessage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c index c3a2e595c1..5908b074a8 100644 --- a/src/rpc/virnetmessage.c +++ b/src/rpc/virnetmessage.c @@ -358,7 +358,8 @@ int virNetMessageEncodePayload(virNetMessagePtr msg, /* Try to encode the payload. If the buffer is too small increase it. */ while (!(*filter)(&xdr, data, 0)) { - unsigned int newlen = (msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX) * 4; + unsigned int newlen = msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX; + newlen *= 2; if (newlen > VIR_NET_MESSAGE_MAX) { virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message payload")); -- GitLab