On Mon, 20 Oct 2025, Pali Rohár wrote:

On Monday 20 October 2025 15:14:19 Martin Storsjö wrote:
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

This file already contains more disabled code. And I wanted to do simple
change to this file. You are right that it could be cleaned up; tests
can be moved into the appropriate directory, etc...

Ok, in that case we can consider removing all such disabled code in a later future step instead.

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to