debuggers.hg
changeset 22881:4fea7664a6fb
libxl: correct error path in libxl_userdata_retrieve
Firstly, if libxl_read_file_contents fails, it doesn't really leave
*data and *datalen_r undefined - it leaves them unchanged. Tighten up
the spec for the benefit of libxl_userdata_retrieve.
Secondly, libxl_userdata_retrieve ignored errors, assuming they were
all ENOENT. Instead it should fail on unexpected errors.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Jim Fehlig <jfehlig@novell.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Firstly, if libxl_read_file_contents fails, it doesn't really leave
*data and *datalen_r undefined - it leaves them unchanged. Tighten up
the spec for the benefit of libxl_userdata_retrieve.
Secondly, libxl_userdata_retrieve ignored errors, assuming they were
all ENOENT. Instead it should fail on unexpected errors.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Jim Fehlig <jfehlig@novell.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author | Ian Jackson <ian.jackson@eu.citrix.com> |
---|---|
date | Fri Jan 28 16:43:53 2011 +0000 (2011-01-28) |
parents | 722f7b7678dc |
children | 2831c5c08df9 |
files | tools/libxl/libxl_dom.c tools/libxl/libxl_utils.h |
line diff
1.1 --- a/tools/libxl/libxl_dom.c Fri Jan 28 11:08:49 2011 +0000 1.2 +++ b/tools/libxl/libxl_dom.c Fri Jan 28 16:43:53 2011 +0000 1.3 @@ -671,7 +671,10 @@ int libxl_userdata_retrieve(libxl_ctx *c 1.4 } 1.5 1.6 e = libxl_read_file_contents(ctx, filename, data_r ? &data : 0, &datalen); 1.7 - 1.8 + if (e && errno != ENOENT) { 1.9 + rc = ERROR_FAIL; 1.10 + goto out; 1.11 + } 1.12 if (!e && !datalen) { 1.13 LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "userdata file %s is empty", filename); 1.14 if (data_r) assert(!*data_r);
2.1 --- a/tools/libxl/libxl_utils.h Fri Jan 28 11:08:49 2011 +0000 2.2 +++ b/tools/libxl/libxl_utils.h Fri Jan 28 16:43:53 2011 +0000 2.3 @@ -36,7 +36,7 @@ int libxl_read_file_contents(libxl_ctx * 2.4 /* Reads the contents of the plain file filename into a mallocd 2.5 * buffer. Returns 0 or errno. Any errors other than ENOENT are logged. 2.6 * If the file is empty, *data_r and *datalen_r are set to 0. 2.7 - * On error, *data_r and *datalen_r are undefined. 2.8 + * On error, *data_r and *datalen_r are unchanged. 2.9 * data_r and/or datalen_r may be 0. 2.10 */ 2.11