Fix GH-8048: disk_*_space wrong for some filesystems on macOS

A macOS bug in libc statvfs(3) call truncates 64 bit elements (e.g.
f_blocks) to 32 bits.  Thus, we force macOS to use statfs.

Closes GH-8056.
This commit is contained in:
risner 2022-02-07 12:22:50 -05:00 committed by Christoph M. Becker
parent e6cf583160
commit 57ef16bb5d
No known key found for this signature in database
GPG key ID: D66C9593118BCCB6
2 changed files with 12 additions and 0 deletions

2
NEWS
View file

@ -2,6 +2,8 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2022, PHP 8.0.18
- Standard:
. Fixed bug GH-8048 (Force macOS to use statfs). (risner)
17 Mar 2022, PHP 8.0.17

View file

@ -42,6 +42,16 @@
# include <os2.h>
#endif
#if defined(__APPLE__)
/*
Apple statvfs has an interger overflow in libc copying to statvfs.
cvt_statfs_to_statvfs(struct statfs *from, struct statvfs *to) {
to->f_blocks = (fsblkcnt_t)from->f_blocks;
*/
# undef HAVE_SYS_STATVFS_H
# undef HAVE_STATVFS
#endif
#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
# include <sys/statvfs.h>
#elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)