6.0.0-beta1
11/9/25

[#8669] ssh2 VFS module stat() cache needs to be flushed in read() before checking file size
Summary ssh2 VFS module stat() cache needs to be flushed in read() before checking file size
Queue Horde Base
Queue Version 3.3.5
Type Bug
State Resolved
Priority 1. Low
Owners chuck (at) horde (dot) org
Requester lstewart (at) room52 (dot) net
Created 10/29/2009 (5855 days ago)
Due
Updated 11/01/2009 (5852 days ago)
Assigned
Resolved 11/01/2009 (5852 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch Yes

History
11/01/2009 02:29:47 AM Chuck Hagenbuch Comment #4
Assigned to Chuck Hagenbuch
State ⇒ Resolved
Reply to this comment
Committed - nice catch!
11/01/2009 02:28:54 AM CVS Commit Comment #3 Reply to this comment
Changes have been made in CVS for this ticket:

Clear the stat cache before reading the filesize of a temp file that 
may already
be cached.
Bug: 8669
Submitted by: lstewart (at) room52 (dot) net
http://cvs.horde.org/diff.php/framework/VFS/lib/VFS/ssh2.php?rt=horde&r1=1.15&r2=1.16&ty=u
10/29/2009 06:20:07 PM lstewart (at) room52 (dot) net Comment #2
New Attachment: horde_sshfilesizefix.diff Download
Reply to this comment
Seems my patch didn't make it.
10/29/2009 06:12:15 PM lstewart (at) room52 (dot) net Comment #1
Priority ⇒ 1. Low
Patch ⇒ Yes
Milestone ⇒
Queue ⇒ Horde Base
Summary ⇒ ssh2 VFS module stat() cache needs to be flushed in read() before checking file size
Type ⇒ Bug
State ⇒ Unconfirmed
Reply to this comment
The remote file is able to be successfully retrieved by the ssh2 VFS 
module and stored in a local temp file. However, the  "$size = 
filesize($file);" line in the read() function returns the size of the 
local temp file as 0 which in turn results in no file content being 
returned.



This is caused by calling certain other PHP function(s) (which rely on 
the underlying OS stat() function) on the temp file prior to it 
actually being populated with remote content. The details of the first 
stat() on the temp file are cached in the PHP stat cache, so even 
though the temp file subsequently gets populated with content, the 
cache returns data for the temp file which is stale.



On a more general note, this type of bug seems like it may be relevant 
to any filesystem-based VFS modules, so it may be wise to audit the 
use of the functions listed here in the "Affected functions" list:

http://us2.php.net/manual/en/function.clearstatcache.php

and check if calls to clearstatcache() are required in other places 
within Horde as well.

Saved Queries