[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] tools/xenstored: Don't assume errno will not be overwritten in lu_arch()
commit e066ca5acc2ee3b5db5c005e1a548b05e753e07d Author: Julien Grall <jgrall@xxxxxxxxxx> AuthorDate: Fri Jul 30 16:14:14 2021 +0100 Commit: Julien Grall <jgrall@xxxxxxxxxx> CommitDate: Fri Jul 30 16:14:39 2021 +0100 tools/xenstored: Don't assume errno will not be overwritten in lu_arch() At the moment, do_control_lu() will set errno to 0 before calling lu_arch() and then check errno. The expectation is nothing in lu_arch() will change the value unless there is an error. However, per errno(3), a function that succeeds is allowed to change errno. In fact, syslog() will overwrite errno if the logs are rotated at the time it is called. To prevent any further issue, errno is now always set before returning NULL. Additionally, errno is only checked when returning NULL so the client can see the error message if there is any. Reported-by: Michael Kurth <mku@xxxxxxxxxx> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx> Reviewed-by: Juergen Gross <jgross@xxxxxxxx> --- tools/xenstore/xenstored_control.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/xenstore/xenstored_control.c b/tools/xenstore/xenstored_control.c index 6b68b79faa..7b4300ef77 100644 --- a/tools/xenstore/xenstored_control.c +++ b/tools/xenstore/xenstored_control.c @@ -324,6 +324,7 @@ static const char *lu_binary_alloc(const void *ctx, struct connection *conn, lu_status->kernel_size = size; lu_status->kernel_off = 0; + errno = 0; return NULL; } @@ -339,6 +340,7 @@ static const char *lu_binary_save(const void *ctx, struct connection *conn, memcpy(lu_status->kernel + lu_status->kernel_off, data, size); lu_status->kernel_off += size; + errno = 0; return NULL; } @@ -413,6 +415,7 @@ static const char *lu_binary(const void *ctx, struct connection *conn, if (!lu_status->filename) return "Allocation failure."; + errno = 0; return NULL; } @@ -798,9 +801,8 @@ static int do_control_lu(void *ctx, struct connection *conn, if (!ret) return errno; } else { - errno = 0; ret = lu_arch(ctx, conn, vec, num); - if (errno) + if (!ret && errno) return errno; } -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |