projects
/
systemd
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7d82cd4
)
basic: fix touch() creating files with 07777 mode
author
Mantas Mikulėnas
<grawity@gmail.com>
Fri, 29 Jan 2016 21:36:08 +0000
(23:36 +0200)
committer
Mantas Mikulėnas
<grawity@gmail.com>
Fri, 29 Jan 2016 21:41:09 +0000
(23:41 +0200)
mode_t is unsigned, so MODE_INVALID < 0 can never be true.
This fixes a possible DoS where any user could fill /run by writing to
a world-writable /run/systemd/show-status.
src/basic/fs-util.c
patch
|
blob
|
history
diff --git
a/src/basic/fs-util.c
b/src/basic/fs-util.c
index d31bd6e273fe8d881e2d1627ffebd2764db6bec1..61b651b573afb3f2d7f9e74830063728577e71de 100644
(file)
--- a/
src/basic/fs-util.c
+++ b/
src/basic/fs-util.c
@@
-341,7
+341,8
@@
int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi
if (parents)
mkdir_parents(path, 0755);
- fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, mode > 0 ? mode : 0644);
+ fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY,
+ (mode == 0 || mode == MODE_INVALID) ? 0644 : mode);
if (fd < 0)
return -errno;