Received: from eggs.gnu.org ([2001:4830:134:3::10]:49640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSkxf-0006W9-F0 for qemu-devel@nongnu.org; Sun, 06 Oct 2013 05:49:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VSkxa-0006QC-FR for qemu-devel@nongnu.org; Sun, 06 Oct 2013 05:49:15 -0400 From: Michael Tokarev Date: Sun, 6 Oct 2013 13:32:55 +0400 Message-Id: <1381051979-25742-11-git-send-email-mjt@msgid.tls.msk.ru> In-Reply-To: <1381051979-25742-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1381051979-25742-1-git-send-email-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 10/14] qemu-char: Fix potential out of bounds access to local arrays List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: aliguori@us.ibm.com Cc: qemu-trivial@nongnu.org, Stefan Weil , Michael Tokarev , qemu-devel@nongnu.org, qemu-stable From: Stefan Weil Latest gcc-4.8 supports a new option -fsanitize=3Daddress which activates an AddressSanitizer. This AddressSanitizer stops the QEMU system emulatio= n very early because two character arrays of size 8 are potentially written with 9 bytes. Commit 6ea314d91439741e95772dfbab98b4135e04bebb added the code. There is no obvious reason why width or height could need 8 characters, so reduce it to 7 characters which together with the terminating '\0' fit into the arrays. Cc: qemu-stable Signed-off-by: Stefan Weil Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Michael Tokarev --- qemu-char.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index f7f5464..6d393e6 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2989,11 +2989,11 @@ QemuOpts *qemu_chr_parse_compat(const char *label= , const char *filename) if (strstart(filename, "vc", &p)) { qemu_opt_set(opts, "backend", "vc"); if (*p =3D=3D ':') { - if (sscanf(p+1, "%8[0-9]x%8[0-9]", width, height) =3D=3D 2) = { + if (sscanf(p+1, "%7[0-9]x%7[0-9]", width, height) =3D=3D 2) = { /* pixels */ qemu_opt_set(opts, "width", width); qemu_opt_set(opts, "height", height); - } else if (sscanf(p+1, "%8[0-9]Cx%8[0-9]C", width, height) =3D= =3D 2) { + } else if (sscanf(p+1, "%7[0-9]Cx%7[0-9]C", width, height) =3D= =3D 2) { /* chars */ qemu_opt_set(opts, "cols", width); qemu_opt_set(opts, "rows", height); --=20 1.7.10.4