Patchwork virtio-9p: Check the return value of llistxattr.

login
register
mail settings
Submitter Kusanagi Kouichi
Date Oct. 30, 2010, 2:52 a.m.
Message ID <20101030025240.0676A6FC03B@msa105.auone-net.jp>
Download mbox | patch
Permalink /patch/69644/
State New
Headers show

Comments

Kusanagi Kouichi - Oct. 30, 2010, 2:52 a.m.
If llistxattr returned 0, qemu aborts.

Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
---
 hw/virtio-9p-xattr.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
jvrao - Oct. 30, 2010, 9:29 p.m.
On 10/29/2010 7:52 PM, Kusanagi Kouichi wrote:
> If llistxattr returned 0, qemu aborts.
> 
> Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>

Acked-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>

> ---
>  hw/virtio-9p-xattr.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/virtio-9p-xattr.c b/hw/virtio-9p-xattr.c
> index 175f372..1aab081 100644
> --- a/hw/virtio-9p-xattr.c
> +++ b/hw/virtio-9p-xattr.c
> @@ -73,6 +73,9 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path,
> 
>      /* Get the actual len */
>      xattr_len = llistxattr(rpath(ctx, path), value, 0);
> +    if (xattr_len <= 0) {
> +        return xattr_len;
> +    }
> 
>      /* Now fetch the xattr and find the actual size */
>      orig_value = qemu_malloc(xattr_len);

Patch

diff --git a/hw/virtio-9p-xattr.c b/hw/virtio-9p-xattr.c
index 175f372..1aab081 100644
--- a/hw/virtio-9p-xattr.c
+++ b/hw/virtio-9p-xattr.c
@@ -73,6 +73,9 @@  ssize_t v9fs_list_xattr(FsContext *ctx, const char *path,
 
     /* Get the actual len */
     xattr_len = llistxattr(rpath(ctx, path), value, 0);
+    if (xattr_len <= 0) {
+        return xattr_len;
+    }
 
     /* Now fetch the xattr and find the actual size */
     orig_value = qemu_malloc(xattr_len);