diff options
author | Tony Cook <tony@develop-help.com> | 2019-11-04 09:52:22 +1100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2019-11-07 09:19:47 +1100 |
commit | 7c3f362035dec9b7eaec388b1f7f1619c1bd96a3 (patch) | |
tree | 2dd4eb914cbbd5f6b26fc0e7b0722038263bcdb0 /lib/File | |
parent | cc8ba724ccabff255f384ab68d6f6806ac2eae7c (diff) | |
download | perl-7c3f362035dec9b7eaec388b1f7f1619c1bd96a3.tar.gz |
prevent a race between name-based stat and an open modifying atime
Most linux systems rarely update atime, so it's very unlikely
for this issue to trigger there, but on a system with classic atime
behaviour this was a race between open modifying atime and time()
ticking over.
gh #17234
Diffstat (limited to 'lib/File')
-rw-r--r-- | lib/File/stat.t | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/File/stat.t b/lib/File/stat.t index c403fc4498..fc9bb12cef 100644 --- a/lib/File/stat.t +++ b/lib/File/stat.t @@ -133,6 +133,9 @@ SKIP: { test_X_ops($^X, "for $^X", qr/A/); } +# open early so atime is consistent with the name based call +local *STAT; +my $canopen = open(STAT, '<', $file); my $stat = File::stat::stat($file); isa_ok($stat, 'File::stat', 'should build a stat object'); @@ -143,8 +146,7 @@ for (split //, "tTB") { } SKIP: { - local *STAT; - skip("Could not open file: $!", 2) unless open(STAT, '<', $file); + skip("Could not open file: $!", 2) unless $canopen; isa_ok(File::stat::stat('STAT'), 'File::stat', '... should be able to find filehandle'); |