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

Commit24aed21

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 parenteed5bbc commit24aed21

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
@@ -375,8 +375,18 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
375375
}
376376
else
377377
{
378+
intold_umask;
379+
378380
tm=calloc(1,sizeof(TAR_MEMBER));
379381

382+
/*
383+
* POSIX does not require, but permits, tmpfile() to restrict file
384+
* permissions. Given an OS crash after we write data, the filesystem
385+
* might retain the data but forget tmpfile()'s unlink(). If so, the
386+
* file mode protects confidentiality of the data written.
387+
*/
388+
old_umask=umask(S_IRWXG |S_IRWXO);
389+
380390
#ifndefWIN32
381391
tm->tmpFH=tmpfile();
382392
#else
@@ -411,6 +421,8 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
411421
if (tm->tmpFH==NULL)
412422
die_horribly(AH,modulename,"could not generate temporary file name: %s\n",strerror(errno));
413423

424+
umask(old_umask);
425+
414426
#ifdefHAVE_LIBZ
415427

416428
if (AH->compression!=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp