From: Ian Campbell Subject: Re: [PATCH v2] libxl: fix the bug which will cause heap to break down Date: Fri, 27 Jun 2014 13:01:09 +0100 Message-ID: <1403870469.25894.55.camel@kazak.uk.xensource.com> References: <1403854808-7633-1-git-send-email-liangx.z.li@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X0Uq9-0006H3-P3 for xen-devel@lists.xenproject.org; Fri, 27 Jun 2014 12:01:13 +0000 In-Reply-To: <1403854808-7633-1-git-send-email-liangx.z.li@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Liliang Cc: xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org On Fri, 2014-06-27 at 15:40 +0800, Liliang wrote: > From: Li Liang > > If the JSON message contains more bytes than QMP_RECEIVE_BUFFER_SIZE, > this bug will break down the heap, that leads to core dump. One more > byte should be allocated to contain the appended null character. > > Signed-off-by: Li Liang Does this differ from v1 in some way? I can't spot it. I'm not sure if maybe you meant to send with a different but accidentally resent v1 again, so I won't apply just yet. I take the +1 is for the NULL terminator? Also, please CC the maintainer. You can use ./scripts/get_maintainers.pl to guide you on who that is for a given patch. > --- > tools/libxl/libxl_qmp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c > index 8433e42..5cc56b1 100644 > --- a/tools/libxl/libxl_qmp.c > +++ b/tools/libxl/libxl_qmp.c > @@ -456,7 +456,7 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp) > if (incomplete) { > size_t current_pos = s - incomplete; > incomplete = libxl__realloc(gc, incomplete, > - incomplete_size + rd); > + incomplete_size + rd + 1); > strncat(incomplete + incomplete_size, qmp->buffer, rd); > s = incomplete + current_pos; > incomplete_size += rd;