diff mbox

[LEDE-DEV,2/2] utils: use O_PATH when opening /dev

Message ID 789771690482fcd43a5369d1115f236b6b1c97f2.1463499516.git.jo@mein.io
State Accepted
Headers show

Commit Message

Jo-Philipp Wich May 17, 2016, 3:42 p.m. UTC
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 <jo@mein.io>
---
 utils/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

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;