Skip to content

Commit

Permalink
Fix GH-8048: disk_*_space wrong for some filesystems on macOS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
risner authored and cmb69 committed Mar 4, 2022
1 parent e6cf583 commit 57ef16b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions ext/standard/filestat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 57ef16b

Please sign in to comment.