From patchwork Thu Sep 29 10:33:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 116931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E15851007D5 for ; Thu, 29 Sep 2011 20:34:19 +1000 (EST) Received: from localhost ([::1]:58235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9DwQ-0000cs-V9 for incoming@patchwork.ozlabs.org; Thu, 29 Sep 2011 06:34:10 -0400 Received: from eggs.gnu.org ([140.186.70.92]:52991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9DwK-0000cn-Vl for qemu-devel@nongnu.org; Thu, 29 Sep 2011 06:34:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9DwJ-0002ji-Lp for qemu-devel@nongnu.org; Thu, 29 Sep 2011 06:34:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52740) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9DwJ-0002iw-B4 for qemu-devel@nongnu.org; Thu, 29 Sep 2011 06:34:03 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8TAY0KA031008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 29 Sep 2011 06:34:00 -0400 Received: from t500wlan.home.berrange.com.com (vpn1-7-70.ams2.redhat.com [10.36.7.70]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p8TAXwss024921; Thu, 29 Sep 2011 06:33:59 -0400 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Thu, 29 Sep 2011 11:33:44 +0100 Message-Id: <1317292424-12239-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: Harsh Bora , "Aneesh Kumar K. V" Subject: [Qemu-devel] [PATCH] Ensure an error is reported to user if 9pfs mount tag is too long X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Daniel P. Berrange" If the 9pfs mount tag is longer than MAX_TAG_LEN bytes, rather than silently truncating the tag which will likely break the guest OS, report an immediate error and exit QEMU * hw/9pfs/virtio-9p-device.c: Report error & exit if mount tag is too long Signed-off-by: Daniel P. Berrange --- hw/9pfs/virtio-9p-device.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 97f2da5..8ca38d3 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -117,7 +117,9 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf) s->ctx.fs_root = g_strdup(fse->path); len = strlen(conf->tag); if (len > MAX_TAG_LEN) { - len = MAX_TAG_LEN; + fprintf(stderr, "mount tag '%s' (%d bytes) is longer than maximum (%d bytes)", + conf->tag, len, MAX_TAG_LEN); + exit(1); } /* s->tag is non-NULL terminated string */ s->tag = g_malloc(len);