diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-05-08 03:28:05 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-08 09:56:00 +0200 |
commit | 605848787b105148b68bc05617fae77ced44a602 (patch) | |
tree | e1be2ef358ba825c1f5238f1289b75ae71eb654e /Userland/Utilities/dd.cpp | |
parent | eed6ce8b8b124de2b838ee327cfea87b5dd3b005 (diff) | |
download | serenity-605848787b105148b68bc05617fae77ced44a602.zip |
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
Diffstat (limited to 'Userland/Utilities/dd.cpp')
-rw-r--r-- | Userland/Utilities/dd.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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; |