summaryrefslogtreecommitdiff
path: root/libdiskfs
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2009-10-12 01:32:44 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2009-10-12 01:32:44 +0200
commit00a8e7813decb4339ef45a34cecdc09c4be3dd70 (patch)
tree8284e70b90700ae0fb9f0d0fecd78a968c320f8d /libdiskfs
parent4d2e9c98b5b886d80fb7396aef89ca50b0d5fcfe (diff)
Make rename("something", "something/.") not hang
* libdiskfs/dir-rename.c: Include <string.h> (diskfs_S_dir_rename): If source or destination ends with "." or "..", return EINVAL as required by POSIX.
Diffstat (limited to 'libdiskfs')
-rw-r--r--libdiskfs/dir-rename.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libdiskfs/dir-rename.c b/libdiskfs/dir-rename.c
index 747c6666..867e395d 100644
--- a/libdiskfs/dir-rename.c
+++ b/libdiskfs/dir-rename.c
@@ -19,6 +19,7 @@
#include "priv.h"
#include "fs_S.h"
+#include <string.h>
/* To avoid races in checkpath, and to prevent a directory from being
simultaneously renamed by two processes, we serialize all renames of
@@ -44,6 +45,10 @@ diskfs_S_dir_rename (struct protid *fromcred,
if (! tocred)
return EXDEV;
+ if (!strcmp (fromname, ".") || !strcmp (fromname, "..")
+ || !strcmp (toname, ".") || !strcmp (toname, ".."))
+ return EINVAL;
+
if (tocred->po->shadow_root != fromcred->po->shadow_root)
/* Same translator, but in different shadow trees. */
return EXDEV;