mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
crypto: Use O_CLOEXEC in qcrypto_random_init
Avoids leaking the /dev/urandom fd into any child processes. Reviewed-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
@@ -42,9 +42,9 @@ int qcrypto_random_init(Error **errp)
|
||||
#else
|
||||
/* TBD perhaps also add support for BSD getentropy / Linux
|
||||
* getrandom syscalls directly */
|
||||
fd = open("/dev/urandom", O_RDONLY);
|
||||
fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
|
||||
if (fd == -1 && errno == ENOENT) {
|
||||
fd = open("/dev/random", O_RDONLY);
|
||||
fd = open("/dev/random", O_RDONLY | O_CLOEXEC);
|
||||
}
|
||||
|
||||
if (fd < 0) {
|
||||
|
||||
Reference in New Issue
Block a user