All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxc: check for null size file mapping
@ 2018-02-12 12:09 Paul Semel
  2018-02-12 12:35 ` Wei Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Semel @ 2018-02-12 12:09 UTC (permalink / raw)
  To: xen-devel; +Cc: Paul Semel, wei.liu2, ian.jackson

Changed the error message when trying to map a null size file.
When doing `xl create` command, we get an Invalid Kernel error
when the file size is greater than zero. For zero length files, we are
falling in the mmap error, and we get an `Invalid parameter` error,
which is not explicit. With this change, we get a `zero length file`
error.

Signed-off-by: Paul Semel <semelpaul@gmail.com>
---
 tools/libxc/xc_dom_core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
index 96e71dd2d9..9bd04cb2d5 100644
--- a/tools/libxc/xc_dom_core.c
+++ b/tools/libxc/xc_dom_core.c
@@ -225,6 +225,12 @@ void *xc_dom_malloc_filemap(struct xc_dom_image *dom,
                      "tried to map file which is too large");
         goto err;
     }
+    else if ( !*size )
+    {
+        xc_dom_panic(dom->xch, XC_INTERNAL_ERROR,
+                     "'%s': zero length file", filename);
+        goto err;
+    }
 
     block = malloc(sizeof(*block));
     if ( block == NULL ) {
-- 
2.16.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH] libxc: check for null size file mapping
  2018-02-12 12:09 [PATCH] libxc: check for null size file mapping Paul Semel
@ 2018-02-12 12:35 ` Wei Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Wei Liu @ 2018-02-12 12:35 UTC (permalink / raw)
  To: Paul Semel; +Cc: xen-devel, ian.jackson, wei.liu2

On Mon, Feb 12, 2018 at 01:09:15PM +0100, Paul Semel wrote:
> Changed the error message when trying to map a null size file.
> When doing `xl create` command, we get an Invalid Kernel error
> when the file size is greater than zero. For zero length files, we are
> falling in the mmap error, and we get an `Invalid parameter` error,
> which is not explicit. With this change, we get a `zero length file`
> error.
> 
> Signed-off-by: Paul Semel <semelpaul@gmail.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

This can in fact be done right after lseek, but I don't think it is
important enough to ask you to rewrite your patch. :-)

> ---
>  tools/libxc/xc_dom_core.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
> index 96e71dd2d9..9bd04cb2d5 100644
> --- a/tools/libxc/xc_dom_core.c
> +++ b/tools/libxc/xc_dom_core.c
> @@ -225,6 +225,12 @@ void *xc_dom_malloc_filemap(struct xc_dom_image *dom,
>                       "tried to map file which is too large");
>          goto err;
>      }
> +    else if ( !*size )
> +    {
> +        xc_dom_panic(dom->xch, XC_INTERNAL_ERROR,
> +                     "'%s': zero length file", filename);
> +        goto err;
> +    }
>  
>      block = malloc(sizeof(*block));
>      if ( block == NULL ) {
> -- 
> 2.16.1
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2018-02-12 12:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-12 12:09 [PATCH] libxc: check for null size file mapping Paul Semel
2018-02-12 12:35 ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.