On Sun, 5 Oct 2025, Pali Rohár wrote:
Free space check code in mingw-w64 ftruncate64 function is broken.
For example when the volume is not found, it calls GetDiskFreeSpaceExW()
with NULL first argument which always fails. This code seems to be
unreliable and probably is wrong as the POSIX ftruncate function can
create a file with holes which means that reported file size can be larger
then the underlying disk size. So disable free space check and let followup
WinAPI calls to fail if there are size restriction issues.
---
mingw-w64-crt/stdio/mingw_ftruncate64.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mingw-w64-crt/stdio/mingw_ftruncate64.c
b/mingw-w64-crt/stdio/mingw_ftruncate64.c
index 57a6b8476261..c8892f2afb9b 100644
--- a/mingw-w64-crt/stdio/mingw_ftruncate64.c
+++ b/mingw-w64-crt/stdio/mingw_ftruncate64.c
@@ -12,6 +12,7 @@
#include <windows.h>
#include <psapi.h>
+#if 0
/* Mutually exclusive methods
We check disk space as truncating more than the allowed space results
in file getting mysteriously deleted
@@ -238,6 +239,7 @@ checkfreespace (const HANDLE f, const ULONGLONG
requiredspace)
} /* We have enough space to truncate/expand */
return 0;
}
+#endif
This sounds reasonable, but if we're disabling it, we can just outright
remove the code as well. If we need it back, we can dig it up from git.
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public