summaryrefslogtreecommitdiff
path: root/libdiskfs
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-10-03 15:19:08 +0200
committerJustus Winter <justus@gnupg.org>2016-10-03 18:29:38 +0200
commit63cfc3cdfd817d8f794c83bc39f86ab8b910fe71 (patch)
tree58b84825702ae8841280c443a8b57abee0578fc2 /libdiskfs
parent930b12e29819ffb1d4b38365315919fbe004cf3b (diff)
libdiskfs: Fix short-circuiting translators.
* libdiskfs/file-set-trans.c (diskfs_S_file_set_translator): When setting a short-circuited translator, clear the translator record first. Improve error handling. This notably fixes a crash in ext2fs when setting a symlink on a node with an existing translator record.
Diffstat (limited to 'libdiskfs')
-rw-r--r--libdiskfs/file-set-trans.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libdiskfs/file-set-trans.c b/libdiskfs/file-set-trans.c
index 6e1a61d2..3238037a 100644
--- a/libdiskfs/file-set-trans.c
+++ b/libdiskfs/file-set-trans.c
@@ -168,7 +168,20 @@ diskfs_S_file_set_translator (struct protid *cred,
np->dn_stat.st_rdev = makedev (major, minor);
}
- diskfs_truncate (np, 0);
+ err = diskfs_truncate (np, 0);
+ if (err)
+ {
+ pthread_mutex_unlock (&np->lock);
+ return err;
+ }
+
+ err = diskfs_set_translator (np, NULL, 0, cred);
+ if (err)
+ {
+ pthread_mutex_unlock (&np->lock);
+ return err;
+ }
+
if (newmode == S_IFLNK)
{
char *arg = passive + strlen (passive) + 1;