[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 06/29] libxc: don't read uninitialized size value in xc_read_image



This error case can only be triggered by gzread returning 0 (and having
not read anything), so move it there.

Coverity-ID: 1056076
Signed-off-by: Matthew Daley <mattjd@xxxxxxxxx>
---
 tools/libxc/xg_private.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/libxc/xg_private.c b/tools/libxc/xg_private.c
index 8fa068e..a914068 100644
--- a/tools/libxc/xg_private.c
+++ b/tools/libxc/xg_private.c
@@ -71,6 +71,12 @@ char *xc_read_image(xc_interface *xch,
             image = NULL;
             goto out;
         case 0: /* EOF */
+            if ( *size == 0 )
+            {
+                PERROR("Could not read kernel image");
+                free(image);
+                image = NULL;
+            }
             goto out;
         default:
             *size += bytes;
@@ -80,13 +86,7 @@ char *xc_read_image(xc_interface *xch,
 #undef CHUNK
 
  out:
-    if ( *size == 0 )
-    {
-        PERROR("Could not read kernel image");
-        free(image);
-        image = NULL;
-    }
-    else if ( image )
+    if ( image )
     {
         /* Shrink allocation to fit image. */
         tmp = realloc(image, *size);
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.