From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Daley Subject: [PATCH 04/29] libxc: don't ignore fd read failures when restoring a domain Date: Wed, 30 Oct 2013 20:51:40 +1300 Message-ID: <1383119525-26033-5-git-send-email-mattjd@gmail.com> References: <1383119525-26033-1-git-send-email-mattjd@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1383119525-26033-1-git-send-email-mattjd@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Matthew Daley , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Coverity-ID: 1055042 Coverity-ID: 1055043 Signed-off-by: Matthew Daley --- tools/libxc/xc_domain_restore.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/libxc/xc_domain_restore.c b/tools/libxc/xc_domain_restore.c index ecaf25d..80769a7 100644 --- a/tools/libxc/xc_domain_restore.c +++ b/tools/libxc/xc_domain_restore.c @@ -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); } -- 1.7.10.4