WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] add some checking of opening and read in dom0_init and r

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] add some checking of opening and read in dom0_init and return -1 if error.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 24 Jan 2006 15:22:10 +0000
Delivery-date: Tue, 24 Jan 2006 15:31:49 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User vhanquez@xxxxxxxxxxxxxxxxxxxxxxx
# Node ID c0a8a0b64f65a38385028be277b9b2bbfcef65fc
# Parent  068857a7133dbd8688502e71d45e83b13c0b8c8c
add some checking of opening and read in dom0_init and return -1 if error.
instead of crashing, it now prints a more meaningful error message.

Signed-off-by: Vincent Hanquez <vincent@xxxxxxxxxxxxx>

diff -r 068857a7133d -r c0a8a0b64f65 tools/xenstore/xenstored_domain.c
--- a/tools/xenstore/xenstored_domain.c Tue Jan 24 12:06:48 2006
+++ b/tools/xenstore/xenstored_domain.c Tue Jan 24 13:14:42 2006
@@ -468,28 +468,38 @@
         struct domain *dom0; 
         
         fd = open(XENSTORED_PROC_MFN, O_RDONLY); 
+       if (fd == -1)
+               return -1;
         
         rc = read(fd, str, sizeof(str)); 
+       if (rc == -1)
+               goto outfd;
         str[rc] = '\0'; 
         mfn = strtoul(str, NULL, 0); 
         
         close(fd); 
         
         fd = open(XENSTORED_PROC_PORT, O_RDONLY); 
+       if (fd == -1)
+               return -1;
         
         rc = read(fd, str, sizeof(str)); 
+       if (rc == -1)
+               goto outfd;
         str[rc] = '\0'; 
         port = strtoul(str, NULL, 0); 
         
         close(fd); 
         
-        
         dom0 = new_domain(NULL, 0, mfn, port); 
         talloc_steal(dom0->conn, dom0); 
 
         evtchn_notify(dom0->port); 
 
         return 0; 
+outfd:
+       close(fd);
+       return -1;
 }
 
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] add some checking of opening and read in dom0_init and return -1 if error., Xen patchbot -unstable <=