Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8346218

Browse files
committed
Restrict file mode creation mask during tmpfile().
Per Coverity. Back-patch to 9.0 (all supported versions).Michael Paquier, reviewed (in earlier versions) by Heikki Linnakangas.
1 parentba51774 commit8346218

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎src/bin/pg_dump/pg_backup_tar.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,18 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
379379
}
380380
else
381381
{
382+
intold_umask;
383+
382384
tm=pg_malloc0(sizeof(TAR_MEMBER));
383385

386+
/*
387+
* POSIX does not require, but permits, tmpfile() to restrict file
388+
* permissions. Given an OS crash after we write data, the filesystem
389+
* might retain the data but forget tmpfile()'s unlink(). If so, the
390+
* file mode protects confidentiality of the data written.
391+
*/
392+
old_umask=umask(S_IRWXG |S_IRWXO);
393+
384394
#ifndefWIN32
385395
tm->tmpFH=tmpfile();
386396
#else
@@ -415,6 +425,8 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
415425
if (tm->tmpFH==NULL)
416426
exit_horribly(modulename,"could not generate temporary file name: %s\n",strerror(errno));
417427

428+
umask(old_umask);
429+
418430
#ifdefHAVE_LIBZ
419431

420432
if (AH->compression!=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp