summaryrefslogtreecommitdiff
path: root/libdiskfs
diff options
context:
space:
mode:
authorJeff Bailey <jbailey@gnu.org>2003-07-28 22:37:24 +0000
committerJeff Bailey <jbailey@gnu.org>2003-07-28 22:37:24 +0000
commit23667bac3f98eb3085ca8239b7abc1bc3f9c5b44 (patch)
treea4d0a7a15ffef417636a42a90441d7f3b3ed18d7 /libdiskfs
parent211ee30f24c0abf5fcd5df17451b738e32c2c2c5 (diff)
2003-06-11 Ognyan Kulev <ogi@fmi.uni-sofia.bg>
* dir-renamed.c (diskfs_rename_dir): Check permissions to remove FROMNAME before any modification could take place. Check result of removing the from node.
Diffstat (limited to 'libdiskfs')
-rw-r--r--libdiskfs/ChangeLog6
-rw-r--r--libdiskfs/dir-renamed.c18
2 files changed, 19 insertions, 5 deletions
diff --git a/libdiskfs/ChangeLog b/libdiskfs/ChangeLog
index 27879c7c..170134b3 100644
--- a/libdiskfs/ChangeLog
+++ b/libdiskfs/ChangeLog
@@ -1,3 +1,9 @@
+2003-06-11 Ognyan Kulev <ogi@fmi.uni-sofia.bg>
+
+ * dir-renamed.c (diskfs_rename_dir): Check permissions to remove
+ FROMNAME before any modification could take place. Check result
+ of removing the from node.
+
2002-06-26 Marcus Brinkmann <marcus@gnu.org>
* Makefile (DIST_FILES): Variable removed.
diff --git a/libdiskfs/dir-renamed.c b/libdiskfs/dir-renamed.c
index c67cc072..ce8f4153 100644
--- a/libdiskfs/dir-renamed.c
+++ b/libdiskfs/dir-renamed.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1994,95,96,97,98,99,2001 Free Software Foundation, Inc.
+ Copyright (C) 1994,95,96,97,98,99,2001,2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -106,8 +106,15 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname,
return 0;
}
- /* Now we can safely lock fnp */
- mutex_lock (&fnp->lock);
+ /* Check permissions to remove FROMNAME and lock FNP. */
+ tmpds = alloca (diskfs_dirstat_size);
+ err = diskfs_lookup (fdp, fromname, REMOVE, &tmpnp, tmpds, fromcred);
+ assert (!tmpnp || tmpnp == fnp);
+ if (tmpnp)
+ diskfs_nrele (tmpnp);
+ diskfs_drop_dirstat (fdp, tmpds);
+ if (err)
+ goto out;
if (tnp)
{
@@ -199,8 +206,9 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname,
ds = buf;
mutex_unlock (&fnp->lock);
err = diskfs_lookup (fdp, fromname, REMOVE, &tmpnp, ds, fromcred);
- assert (tmpnp == fnp);
- diskfs_nrele (tmpnp);
+ assert (!tmpnp || tmpnp == fnp);
+ if (tmpnp)
+ diskfs_nrele (tmpnp);
if (err)
goto out;