From 605848787b105148b68bc05617fae77ced44a602 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 8 May 2021 03:28:05 +0200 Subject: Utilities: Specify mode argument when creating files with dd When using open() with the O_CREAT flag we must specify the mode argument. Otherwise we'll incorrectly set the new file's mode to whatever is left on the stack: courage:~ $ dd if=/dev/zero of=test count=1 1+0 blocks in 1+0 blocks out 512 bytes copied. courage:~ $ ls -l test --w-r-x--- 1 anon users 512 2021-05-08 01:29:52 test courage:~ $ This also specifies the mode argument when opening files for reading. This however is harmless because in those cases the argument is ignored. fixes #6923 --- Userland/Utilities/dd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Userland/Utilities/dd.cpp') diff --git a/Userland/Utilities/dd.cpp b/Userland/Utilities/dd.cpp index 3eb58b486e..18b1736cd7 100644 --- a/Userland/Utilities/dd.cpp +++ b/Userland/Utilities/dd.cpp @@ -58,7 +58,7 @@ static int handle_io_file_arguments(int& fd, int flags, const char* argument) return -1; } - fd = open(value.characters(), flags); + fd = open(value.characters(), flags, 0666); if (fd == -1) { fprintf(stderr, "Unable to open: %s\n", value.characters()); return -1; -- cgit v1.2.3