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>
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;
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;
if (ret == 0 && S_ISREG(st.st_mode)) {
tmp = malloc(strlen(filename) + 8);
if (tmp) {
+ mode_t save_umask = umask(022);
sprintf(tmp, "%s-XXXXXX", filename);
fd = mkstemp(tmp);
+ umask(save_umask);
if (fd >= 0) {
file = fdopen(fd, "w");
opened = tmp;
errcode_t retval;
char *fn, uuid[40];
ext2_ino_t num_inodes;
+ mode_t save_umask;
int fd;
retval = alloc_icount(fs, flags, &icount);
uuid_unparse(fs->super->s_uuid, uuid);
sprintf(fn, "%s/%s-icount-XXXXXX", tdb_dir, uuid);
icount->tdb_fn = fn;
+ save_umask = umask(077);
fd = mkstemp(fn);
if (fd < 0) {
retval = errno;
goto errout;
}
+ umask(save_umask);
/*
* This is an overestimate of the size that we will need; the
* ideal value is the number of used inodes with a count