depot/third_party/nixpkgs/pkgs/tools/backup/store-backup/CVE-2020-7040.patch
Default email c7cb07f092 Project import generated by Copybara.
GitOrigin-RevId: 1536926ef5621b09bba54035ae2bb6d806d72ac8
2024-02-29 21:09:43 +01:00

23 lines
708 B
Diff

Index: storeBackup/lib/fileDir.pl
===================================================================
--- storeBackup.orig/lib/fileDir.pl
+++ storeBackup/lib/fileDir.pl
@@ -21,7 +21,7 @@
use Digest::MD5 qw(md5_hex);
-use Fcntl qw(O_RDWR O_CREAT);
+use Fcntl qw(O_RDWR O_CREAT O_WRONLY O_EXCL);
use Fcntl ':mode';
use POSIX;
use Cwd 'abs_path';
@@ -482,7 +482,7 @@ sub checkLockFile
'-str' => ["creating lock file <$lockFile>"]);
&::checkDelSymLink($lockFile, $prLog, 0x01);
- open(FILE, '>', $lockFile) or
+ sysopen(FILE, $lockFile, O_WRONLY | O_CREAT | O_EXCL) or
$prLog->print('-kind' => 'E',
'-str' => ["cannot create lock file <$lockFile>"],
'-exit' => 1);