diff options
author | vhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com> | 2006-01-24 13:14:42 +0000 |
---|---|---|
committer | vhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com> | 2006-01-24 13:14:42 +0000 |
commit | 9ebf278d68a912b6cd6eed3c215c4e1e19ac295c (patch) | |
tree | 7b4686949e0d268c796fb08d01e52a98c8172406 /tools/xenstore/xenstored_domain.c | |
parent | 4f139e3d93e5ab05efb7c4e4341866367791eb33 (diff) | |
download | xen-9ebf278d68a912b6cd6eed3c215c4e1e19ac295c.tar.gz xen-9ebf278d68a912b6cd6eed3c215c4e1e19ac295c.tar.bz2 xen-9ebf278d68a912b6cd6eed3c215c4e1e19ac295c.zip |
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@xensource.com>
Diffstat (limited to 'tools/xenstore/xenstored_domain.c')
-rw-r--r-- | tools/xenstore/xenstored_domain.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c index 353ef9b7ac..cf862e4b8b 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -468,28 +468,38 @@ static int dom0_init(void) 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; } |