在 2025-12-20 00:24, Pali Rohár 写道:
Use of tempnam() + CreateFileA(CREATE_ALWAYS) can fail because filename
could be created by other process between those two calls.

So replace the tempnam() + CreateFileA(CREATE_ALWAYS) by just one mkstemp()
call which is generating temporary file name and also creating it.
---
  mingw-w64-crt/testcases/t_fseeko64.c | 14 +++++++++-----
  1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/mingw-w64-crt/testcases/t_fseeko64.c 
b/mingw-w64-crt/testcases/t_fseeko64.c
index c55e8293b643..58d3d1c892bf 100644
--- a/mingw-w64-crt/testcases/t_fseeko64.c
+++ b/mingw-w64-crt/testcases/t_fseeko64.c
@@ -1,16 +1,18 @@
  #define _FILE_OFFSET_BITS 64
  #include <stdio.h>
  #include <stdlib.h>
+#include <io.h>
  #include <string.h>
  #include <windows.h>
static const char *writebuf = "TESTVECTORSTRING";
-static char szPath[MAX_PATH];
+#define TMPTMPL "mingw-w64-fseeko64-XXXXXX"
+static char szPath[MAX_PATH + sizeof(TMPTMPL)];

I am not too satisfied with this construction, but it's only a test program, so maybe it's fine. I have pushed this one to master now.


--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

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

Reply via email to