libxc: don't ignore fd read failures when restoring a domain
authorMatthew Daley <mattjd@gmail.com>
Wed, 30 Oct 2013 07:51:40 +0000 (20:51 +1300)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 31 Oct 2013 21:23:46 +0000 (21:23 +0000)
Coverity-ID: 1055042
Coverity-ID: 1055043
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxc/xc_domain_restore.c

index ecaf25deb4b475478a1d58873f1f0d0cc728da1c..80769a7f3bf2b867c88a50a0e3e7721635837d14 100644 (file)
@@ -327,7 +327,11 @@ static xen_pfn_t *load_p2m_frame_list(
             else if ( !strncmp(chunk_sig, "xcnt", 4) )
             {
                 *vcpuextstate = 1;
-                RDEXACT(io_fd, vcpuextstate_size, sizeof(*vcpuextstate_size));
+                if ( RDEXACT(io_fd, vcpuextstate_size, sizeof(*vcpuextstate_size)) )
+                {
+                    PERROR("read extended vcpu state size failed");
+                    return NULL;
+                }
                 tot_bytes -= chunk_bytes;
                 chunk_bytes = 0;
             }
@@ -928,14 +932,22 @@ static int pagebuf_get_one(xc_interface *xch, struct restore_ctx *ctx,
 
     case XC_SAVE_ID_TOOLSTACK:
         {
-            RDEXACT(fd, &buf->tdata.len, sizeof(buf->tdata.len));
+            if ( RDEXACT(fd, &buf->tdata.len, sizeof(buf->tdata.len)) )
+            {
+                PERROR("error read toolstack id size");
+                return -1;
+            }
             buf->tdata.data = (uint8_t*) realloc(buf->tdata.data, buf->tdata.len);
             if ( buf->tdata.data == NULL )
             {
                 PERROR("error memory allocation");
                 return -1;
             }
-            RDEXACT(fd, buf->tdata.data, buf->tdata.len);
+            if ( RDEXACT(fd, buf->tdata.data, buf->tdata.len) )
+            {
+                PERROR("error read toolstack id");
+                return -1;
+            }
             return pagebuf_get_one(xch, ctx, buf, fd, dom);
         }