提交 e9979ca6 编写于 作者: R Richard Henderson

crypto: Use O_CLOEXEC in qcrypto_random_init

Avoids leaking the /dev/urandom fd into any child processes.
Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
Signed-off-by: NRichard Henderson <richard.henderson@linaro.org>
上级 25fb26e4
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册