From 484a67719146e819ddad64fbda23b4b23afa3095 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 20 Nov 2016 16:19:38 +0100 Subject: 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. --- ext2fs/dir.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ext2fs') 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 #include +#include + /* 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; -- cgit v1.2.3