summaryrefslogtreecommitdiff
path: root/e2fsck/dirinfo.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2014-01-09 15:18:44 -0500
committerTheodore Ts'o <tytso@mit.edu>2014-01-09 15:18:44 -0500
commit253a96500a8fbe7266fe2daa066768cbaa1d3137 (patch)
tree38354c754556e6e924d2147b8bd4fd6791b5932c /e2fsck/dirinfo.c
parente114288010d01e3957bd5c1c3667d9cb7b73bba8 (diff)
downloade2fsprogs-253a96500a8fbe7266fe2daa066768cbaa1d3137.tar.gz
Save and restore umask around calls to mkstemp()
The races would be hard to exploit, but let's close them off. Addresses-Coverity-Id: #709504 Addresses-Coverity-Id: #709505 Addresses-Coverity-Id: #709506 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'e2fsck/dirinfo.c')
-rw-r--r--e2fsck/dirinfo.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/e2fsck/dirinfo.c b/e2fsck/dirinfo.c
index dc08f90a..dbaf4712 100644
--- a/e2fsck/dirinfo.c
+++ b/e2fsck/dirinfo.c
@@ -42,6 +42,7 @@ static void setup_tdb(e2fsck_t ctx, ext2_ino_t num_dirs)
struct dir_info_db *db = ctx->dir_info;
unsigned int threshold;
errcode_t retval;
+ mode_t save_umask;
char *tdb_dir, uuid[40];
int fd, enable;
@@ -62,7 +63,9 @@ static void setup_tdb(e2fsck_t ctx, ext2_ino_t num_dirs)
uuid_unparse(ctx->fs->super->s_uuid, uuid);
sprintf(db->tdb_fn, "%s/%s-dirinfo-XXXXXX", tdb_dir, uuid);
+ save_umask = umask(077);
fd = mkstemp(db->tdb_fn);
+ umask(save_umask);
if (fd < 0) {
db->tdb = NULL;
return;