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@amazon.com>
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
lu_status->kernel_size = size;
lu_status->kernel_off = 0;
+ errno = 0;
return NULL;
}
memcpy(lu_status->kernel + lu_status->kernel_off, data, size);
lu_status->kernel_off += size;
+ errno = 0;
return NULL;
}
if (!lu_status->filename)
return "Allocation failure.";
+ errno = 0;
return NULL;
}
if (!ret)
return errno;
} else {
- errno = 0;
ret = lu_arch(ctx, conn, vec, num);
- if (errno)
+ if (!ret && errno)
return errno;
}