From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBRzR-0003Mr-Ry for qemu-devel@nongnu.org; Tue, 22 Dec 2015 13:48:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aBRzN-00048I-IZ for qemu-devel@nongnu.org; Tue, 22 Dec 2015 13:48:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBRzN-00048E-Ch for qemu-devel@nongnu.org; Tue, 22 Dec 2015 13:48:49 -0500 Date: Tue, 22 Dec 2015 13:48:45 -0500 From: Luiz Capitulino Message-ID: <20151222134845.60deb22f@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] hmp: avoid redundant null termination of buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: P J P Cc: Markus Armbruster , qemu-devel@nongnu.org, Ling Liu On Thu, 17 Dec 2015 18:10:59 +0530 (IST) P J P wrote: > Hello, > > An OOB write issue was reported by Mr Ling Liu, CC'd here. It occurs while > processing the 'sendkey' command, if the command argument was longer than > the 'keyname_buf[16]' buffer. Markus, are you planning a pull request soon? Reviewed-by: Luiz Capitulino > > === > From b0363f4c0e91671064dd7ffece8a6923c8dcaf20 Mon Sep 17 00:00:00 2001 > From: Prasad J Pandit > Date: Thu, 17 Dec 2015 17:47:15 +0530 > Subject: [PATCH] hmp: avoid redundant null termination of buffer > > When processing 'sendkey' command, hmp_sendkey routine null > terminates the 'keyname_buf' array. This results in an OOB write > issue, if 'keyname_len' was to fall outside of 'keyname_buf' array. > Removed the redundant null termination, as pstrcpy routine already > null terminates the target buffer. > > Reported-by: Ling Liu > Signed-off-by: Prasad J Pandit > --- > hmp.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/hmp.c b/hmp.c > index 2140605..e530c9c 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -1746,9 +1746,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) > /* Be compatible with old interface, convert user inputted "<" */ > if (!strncmp(keyname_buf, "<", 1) && keyname_len == 1) { > pstrcpy(keyname_buf, sizeof(keyname_buf), "less"); > - keyname_len = 4; > } > - keyname_buf[keyname_len] = 0; > > keylist = g_malloc0(sizeof(*keylist)); > keylist->value = g_malloc0(sizeof(*keylist->value));