Skip to content

Commit 27d3806

Browse files
src/vipw.c: create_backup_file(): Use mask for mode_t
This is consistent with fmkstemp_set_perms() in lib/commonio.c. This avoids accidentally granting dangerous permissions. Closes: <#1500> Reported-by: Alejandro Colomar <alx@kernel.org> Suggested-by: Tobias Stoeckmann <tobias@stoeckmann.org> Signed-off-by: Alejandro Colomar <alx@kernel.org>
1 parent b37bbc3 commit 27d3806

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/vipw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static int create_backup_file (FILE * fp, char *backup, struct stat *sb)
130130
ub.modtime = sb->st_mtime;
131131
if ( (utime (backup, &ub) != 0)
132132
|| (fchown(fileno(bkfp), sb->st_uid, sb->st_gid) != 0)
133-
|| (fchmod(fileno(bkfp), sb->st_mode) != 0)) {
133+
|| (fchmod(fileno(bkfp), sb->st_mode & 0664) != 0)) {
134134
fclose(bkfp);
135135
unlink (backup);
136136
return -1;

0 commit comments

Comments
 (0)