diff options
author | Richard Jones <rjones@redhat.com> | 2010-04-17 13:33:14 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2010-04-17 13:36:26 +0100 |
commit | 61ab83d19009a8006dd73ebe16d22494b78be4d1 (patch) | |
tree | ad14a0f005867ceea391da618792c59c9b395728 /daemon | |
parent | 42fc0e02b094ef3b19dae115276a0a33116af6d5 (diff) | |
download | libguestfs-61ab83d19009a8006dd73ebe16d22494b78be4d1.tar.gz libguestfs-61ab83d19009a8006dd73ebe16d22494b78be4d1.tar.xz libguestfs-61ab83d19009a8006dd73ebe16d22494b78be4d1.zip |
Improved checking, documentation of modes (RHBZ#582901, RHBZ#582929).
chmod: Disallow negative mode, document mode affected by umask.
mkdir-mode: Disallow negative mode, document that filesystems
may interpret the mode in different ways.
mknod: Disallow negative mode, document mode affected by umask.
umask: Check the range of umask mask value carefully.
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/dir.c | 5 | ||||
-rw-r--r-- | daemon/file.c | 5 | ||||
-rw-r--r-- | daemon/mknod.c | 5 | ||||
-rw-r--r-- | daemon/umask.c | 5 |
4 files changed, 20 insertions, 0 deletions
diff --git a/daemon/dir.c b/daemon/dir.c index 205139b8..3a4647cd 100644 --- a/daemon/dir.c +++ b/daemon/dir.c @@ -104,6 +104,11 @@ do_mkdir_mode (const char *path, int mode) { int r; + if (mode < 0) { + reply_with_error ("%s: mode is negative", path); + return -1; + } + CHROOT_IN; r = mkdir (path, mode); CHROOT_OUT; diff --git a/daemon/file.c b/daemon/file.c index dbdbbaae..7a0f8f92 100644 --- a/daemon/file.c +++ b/daemon/file.c @@ -198,6 +198,11 @@ do_chmod (int mode, const char *path) { int r; + if (mode < 0) { + reply_with_error ("%s: mode is negative", path); + return -1; + } + CHROOT_IN; r = chmod (path, mode); CHROOT_OUT; diff --git a/daemon/mknod.c b/daemon/mknod.c index 50865a62..2458a851 100644 --- a/daemon/mknod.c +++ b/daemon/mknod.c @@ -51,6 +51,11 @@ do_mknod (int mode, int devmajor, int devminor, const char *path) #ifdef HAVE_MKNOD int r; + if (mode < 0) { + reply_with_error ("%s: mode is negative", path); + return -1; + } + CHROOT_IN; r = mknod (path, mode, makedev (devmajor, devminor)); CHROOT_OUT; diff --git a/daemon/umask.c b/daemon/umask.c index a9ddeab0..db4a2f2f 100644 --- a/daemon/umask.c +++ b/daemon/umask.c @@ -35,6 +35,11 @@ do_umask (int mask) { int r; + if (mask < 0 || mask > 0777) { + reply_with_error ("0%o: mask negative or out of range", mask); + return -1; + } + r = umask (mask); if (r == -1) { |