Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IPnkN-0003jk-KX for qemu-devel@nongnu.org; Mon, 27 Aug 2007 19:11:51 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IPnkI-0003ZW-Tq for qemu-devel@nongnu.org; Mon, 27 Aug 2007 19:11:50 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IPnkI-0003Z6-E7 for qemu-devel@nongnu.org; Mon, 27 Aug 2007 19:11:46 -0400 Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IPnkI-0004QT-31 for qemu-devel@nongnu.org; Mon, 27 Aug 2007 19:11:46 -0400 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1IPnic-0000yK-Tr for qemu-devel@nongnu.org; Tue, 28 Aug 2007 01:10:03 +0200 Received: from 140.239.185.98 ([140.239.185.98]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 28 Aug 2007 01:10:02 +0200 Received: from m.bevand by 140.239.185.98 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 28 Aug 2007 01:10:02 +0200 From: Marc Bevand Date: Mon, 27 Aug 2007 23:00:57 +0000 (UTC) Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: news Subject: [Qemu-devel] [PATCH] Fix infinite loop caused by mishandling of type-6 VNC client messages Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi, I have been using QEMU's VNC support quite extensively since 0.8.1 came out, and every once in a while QEMU froze on me while interacting with a guest OS through a VNC client. I recently spent some time tracking down this bug in QEMU 0.9.0 and I found and fixed it in vnc.c (see patch below). In protocol_client_msg(), type-6 messages ("client cut text") are not handled properly. From time to time my VNC client (xvncviewer version 3.3.7-8ubuntu2_amd64.deb, from Ubuntu 6.06.1) appears to send type-6 messages with an empty text string: 06 message-type xx xx xx padding 00 00 00 00 length - (empty text string) This causes protocol_client_msg() to enter this if-condition: if (len == 8) return 8 + read_u32(data, 4); Which returns 8 (8 + 0), meaning that 8 more bytes are expected (it doesn't realize that the lenght field is 0.) This causes QEMU to enter an infinite loop: protocol_client_msg keeps getting called again and again, making the guest OS appear frozen. The bug seems to stil exist in CVS HEAD, I made a patch against qemu-snapshot-2007-08-27_05, please apply it. -marc --- qemu-snap-2007-08-27_05/vnc.c.orig 2007-08-24 18:39:57.000000000 -0700 +++ qemu-snap-2007-08-27_05/vnc.c 2007-08-27 15:25:57.379836750 -0700 @@ -1196,7 +1196,11 @@ return 8; if (len == 8) - return 8 + read_u32(data, 4); + { + uint32_t dlen = read_u32(data, 4); + if (dlen > 0) + return 8 + dlen; + } client_cut_text(vs, read_u32(data, 4), data + 8); break;