From patchwork Thu Sep 29 10:33:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Ensure an error is reported to user if 9pfs mount tag is too long From: "Daniel P. Berrange" X-Patchwork-Id: 116931 Message-Id: <1317292424-12239-1-git-send-email-berrange@redhat.com> To: qemu-devel@nongnu.org Cc: Harsh Bora , "Aneesh Kumar K. V" Date: Thu, 29 Sep 2011 11:33:44 +0100 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);