qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Ensure an error is reported to user if 9pfs mount tag is too long
@ 2011-09-29 10:33 Daniel P. Berrange
  2011-09-29 15:02 ` Aneesh Kumar K.V
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel P. Berrange @ 2011-09-29 10:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: Harsh Bora, Aneesh Kumar K. V

From: "Daniel P. Berrange" <berrange@redhat.com>

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 <berrange@redhat.com>
---
 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);
-- 
1.7.6.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] Ensure an error is reported to user if 9pfs mount tag is too long
  2011-09-29 10:33 [Qemu-devel] [PATCH] Ensure an error is reported to user if 9pfs mount tag is too long Daniel P. Berrange
@ 2011-09-29 15:02 ` Aneesh Kumar K.V
  0 siblings, 0 replies; 2+ messages in thread
From: Aneesh Kumar K.V @ 2011-09-29 15:02 UTC (permalink / raw)
  To: Daniel P. Berrange, qemu-devel; +Cc: Harsh Bora

On Thu, 29 Sep 2011 11:33:44 +0100, "Daniel P. Berrange" <berrange@redhat.com> wrote:
> From: "Daniel P. Berrange" <berrange@redhat.com>
> 
> 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 <berrange@redhat.com>

Applied to the VirtFS (git://repo.or.cz/qemu/v9fs.git). I have to apply
by hand, because it didn't apply cleanly. I also fixed checkpatch.pl errors.

> ---
>  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);
> -- 
> 1.7.6.2
> 
> 

-aneesh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-29 15:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-29 10:33 [Qemu-devel] [PATCH] Ensure an error is reported to user if 9pfs mount tag is too long Daniel P. Berrange
2011-09-29 15:02 ` Aneesh Kumar K.V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).