Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kg58K-0003i5-QL for qemu-devel@nongnu.org; Wed, 17 Sep 2008 18:04:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kg58K-0003hY-6r for qemu-devel@nongnu.org; Wed, 17 Sep 2008 18:04:24 -0400 Received: from [199.232.76.173] (port=35140 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kg58K-0003hQ-22 for qemu-devel@nongnu.org; Wed, 17 Sep 2008 18:04:24 -0400 Received: from savannah.gnu.org ([199.232.41.3]:58435 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kg58J-0000Z9-Fb for qemu-devel@nongnu.org; Wed, 17 Sep 2008 18:04:23 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1Kg58I-0001da-Ob for qemu-devel@nongnu.org; Wed, 17 Sep 2008 22:04:22 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1Kg58I-0001dV-AA for qemu-devel@nongnu.org; Wed, 17 Sep 2008 22:04:22 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Wed, 17 Sep 2008 22:04:22 +0000 Subject: [Qemu-devel] [5242] [PATCH] usb-serial: Fix data corruption with usb serial emulation 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 Revision: 5242 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5242 Author: aurel32 Date: 2008-09-17 22:04:21 +0000 (Wed, 17 Sep 2008) Log Message: ----------- [PATCH] usb-serial: Fix data corruption with usb serial emulation * Remove the unused send_buf variable and its constant. * Fix a math error The variables recv_ptr and recv_used are not large enough to hold the constant 384, which causes data corruption when the pointer is reset with: s->recv_ptr = (s->recv_ptr + len) % RECV_BUF; Signed-off-by: Jason Wessel Acked-by: Samuel Thibault Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/hw/usb-serial.c Modified: trunk/hw/usb-serial.c =================================================================== --- trunk/hw/usb-serial.c 2008-09-17 19:05:19 UTC (rev 5241) +++ trunk/hw/usb-serial.c 2008-09-17 22:04:21 UTC (rev 5242) @@ -22,7 +22,6 @@ #endif #define RECV_BUF 384 -#define SEND_BUF 128 // Not used for now /* Commands */ #define FTDI_RESET 0 @@ -94,9 +93,8 @@ uint16_t vendorid; uint16_t productid; uint8_t recv_buf[RECV_BUF]; - uint8_t recv_ptr; - uint8_t recv_used; - uint8_t send_buf[SEND_BUF]; + uint16_t recv_ptr; + uint16_t recv_used; uint8_t event_chr; uint8_t error_chr; uint8_t event_trigger;