Received: from [140.186.70.92] (port=40243 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7fUd-00029X-L4 for qemu-devel@nongnu.org; Wed, 06 Apr 2011 23:02:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q7fUb-0008Bm-Lv for qemu-devel@nongnu.org; Wed, 06 Apr 2011 23:02:47 -0400 Received: from ozlabs.org ([203.10.76.45]:54722) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q7fUb-0008BB-3e for qemu-devel@nongnu.org; Wed, 06 Apr 2011 23:02:45 -0400 From: David Gibson Date: Thu, 7 Apr 2011 13:02:03 +1000 Message-Id: <1302145325-4634-4-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1302145325-4634-1-git-send-email-david@gibson.dropbear.id.au> References: <1302145325-4634-1-git-send-email-david@gibson.dropbear.id.au> Subject: [Qemu-devel] [PATCH 3/5] virtio-9p: fixed LE-to-host conversion bug when QEMU is called from guest List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aik@ozlabs.ru From: Alexey Kardashevskiy The 9p code already contains an attempt at the necessary endian conversions, but it's broken. The code which does conversion from host to guest does it correctly and this code was copied to the function which does guest to host conversion. However the copied code hasn't been correctly updated, so it first endian converts some garbage on the stack and then overwrites it with a field from incoming packet without conversion. The patch fixes the mistakes. Signed-off-by: Alexey Kardashevskiy Signed-off-by: David Gibson --- hw/virtio-9p.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index 7c59988..7e29535 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -696,25 +696,22 @@ static size_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...) case 'w': { uint16_t val, *valp; valp = va_arg(ap, uint16_t *); - val = le16_to_cpupu(valp); offset += pdu_unpack(&val, pdu, offset, sizeof(val)); - *valp = val; + *valp = le16_to_cpu(val); break; } case 'd': { uint32_t val, *valp; valp = va_arg(ap, uint32_t *); - val = le32_to_cpupu(valp); offset += pdu_unpack(&val, pdu, offset, sizeof(val)); - *valp = val; + *valp = le32_to_cpu(val); break; } case 'q': { uint64_t val, *valp; valp = va_arg(ap, uint64_t *); - val = le64_to_cpup(valp); offset += pdu_unpack(&val, pdu, offset, sizeof(val)); - *valp = val; + *valp = le64_to_cpu(val); break; } case 'v': { -- 1.7.1