From 1418c6ce8559ea125c525c2663105fa5ff14905e Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 17 May 2016 17:42:11 +0200 Subject: [PATCH] utils: use O_PATH when opening /dev Use the O_PATH and O_DIRECTORY flags when opening the "/dev" path for the subsequent openat() call to ensure that it is indeed a directory. Signed-off-by: Jo-Philipp Wich --- utils/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/utils.c b/utils/utils.c index ebf5447..e2e3396 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -165,7 +165,7 @@ int patch_fd(const char *device, int fd, int flags) device = "/dev/null"; if (*device != '/') { - dfd = open("/dev", O_RDONLY); + dfd = open("/dev", O_PATH|O_DIRECTORY); if (dfd < 0) return -1; -- 2.30.2