summaryrefslogtreecommitdiff
path: root/ext2fs
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2016-11-20 16:19:38 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-11-20 16:19:38 +0100
commit484a67719146e819ddad64fbda23b4b23afa3095 (patch)
tree13e1c455452b9f1e32a133f500d7254b67d122c8 /ext2fs
parent385d9bf1b81bc35f06cdf49f57bf65545339cbbb (diff)
ext2fs: Fix crash on ENOSPC while extending a directory
* ext2fs/dir.c (diskfs_direnter_hard): Call hurd_safe_memset on directory extension before using it, to actually reserve room.
Diffstat (limited to 'ext2fs')
-rw-r--r--ext2fs/dir.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext2fs/dir.c b/ext2fs/dir.c
index bc375c34..1097db82 100644
--- a/ext2fs/dir.c
+++ b/ext2fs/dir.c
@@ -26,6 +26,8 @@
#include <dirent.h>
#include <stddef.h>
+#include <hurd/sigpreempt.h>
+
/* This isn't quite right because a file system block may straddle several
device blocks, and so a write failure between writing two device blocks
may scramble things up a bit. But the linux doesn't do this. We could
@@ -620,6 +622,12 @@ diskfs_direnter_hard (struct node *dp, const char *name, struct node *np,
}
new = (struct ext2_dir_entry_2 *) (ds->mapbuf + oldsize);
+ err = hurd_safe_memset (new, 0, DIRBLKSIZ);
+ if (err)
+ {
+ munmap ((caddr_t) ds->mapbuf, ds->mapextent);
+ return err;
+ }
dp->dn_stat.st_size = oldsize + DIRBLKSIZ;
dp->dn_set_ctime = 1;