-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix #77552: Uninitialized buffer in stat functions #3784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Some wacky CI test results. Travis passes/Appveyor times out? on the first commit, then Travis fails/Appveyor passes on the second commit (which makes an inconsequential change to a Windows only test). |
|
Thanks @nikic |
|
Actually, we're hitting this: php-src/Zend/zend_virtual_cwd.c Lines 327 to 331 in b51be55
It might be worthwhile to actually implement support for IO_REPARSE_TAG_MOUNT_POINTs, and also to add an else clause which sets buf->st_mode (or to initialize it immediately before the if statement).
|
|
@cmb69 I didn't fix it there because the stat function calls come from main\streams\streams.c to either However, I can zero initialize Regarding support for
I'm sure @weltling will have some ideas. My intention here was to supply a quick fix so that the data is consistent, but I will do anything I can to help. |
|
Since it's a fix targeting 7.2, it seems to fine merge (probably should be 7.2 only). The handling of Thanks. |
|
Thanks @weltling But why "probably should be 7.2 only"? The buffer is uninitialized in 7.3 as well. |
|
@johnstevenson in 7.3+, any stat call should be running through the ioutil implementation. You mention it in the description actually. If it's not the case, probaly need to check as something should have been missed. Though it might bring regressions, in that case your patch should be ok for 7.3, too. Thanks. |
|
@weltling From what I can see the ioutil implementation ( |
|
@johnstevenson ah, indeed. Then 7.2 and 7.3 are good to go, and empty merge upwards :) The missing implementation is a separate thing anyway. Thansk. |
|
Merged as fe4d724 into 7.2+. I've merged this as-is up to master, as zeroing the struct seems like a good defensive practice independently of the specific issue encountered here. |
An uninitialized
php_stream_statbufin php_stat (ext\standard\filestat.c) can cause randomst_modevalues when callinglstaton an NTFS junction.The
php_sys_stat_exfunction (zend\zend_virtual_cwd.c) sets the st_mode for everything except a junction, so the uninitialized value is returned.I have initialized the buffer in
_php_stream_stat_path, since this function is called in several places.Note that this anomaly has been "fixed" on master (e42e8b1) in that @weltling 's code in win32\ioutil.c initializes the individual stat members.