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

Commit7496aba

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 parente32c5f1 commit7496aba

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
@@ -380,8 +380,18 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
380380
}
381381
else
382382
{
383+
intold_umask;
384+
383385
tm=pg_malloc0(sizeof(TAR_MEMBER));
384386

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

429+
umask(old_umask);
430+
419431
#ifdefHAVE_LIBZ
420432

421433
if (AH->compression!=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp