]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests/server: drop unsafe `open()` override in signal handler (Windows)
authorViktor Szakats <commit@vsz.me>
Mon, 29 Sep 2025 20:48:55 +0000 (22:48 +0200)
committerViktor Szakats <commit@vsz.me>
Mon, 29 Sep 2025 23:10:35 +0000 (01:10 +0200)
Turns out the signal handler on Windows still wasn't signal safe after
the previous round of fix. There is an `open()` call made from there,
and `open` happens to be unconditionally overridden via `curl_setup.h`
on Windows, to its local implementation (`curlx_win32_open()`), which
does memory allocations and potentially other things that are not signal
safe.

This is a temporary fix, till avoiding the override of system symbols
`open` and `stat` on Windows.

FTR this did not fix the CI 2304 errors, diskspace fail or job hangs due
to 0xC0000142 fork failure (it's rare all three occurs in the same run):
https://github.com/curl/curl/actions/runs/18110523584?pr=18774

Ref: #18634
Follow-up e95f509c66abdd88ae02e3243cdc217f19c4a330 #16852
Closes #18774

tests/server/util.c

index 052effa8958343dd2f859d79e8cfd07cc4622b70..41f42ca42e09dbc10755fd5a35133349024e9d5a 100644 (file)
@@ -373,12 +373,12 @@ static void exit_signal_handler(int signum)
     (void)!write(STDERR_FILENO, msg, sizeof(msg) - 1);
   }
   else {
+    int fd;
 #ifdef _WIN32
-#define OPENMODE S_IREAD | S_IWRITE
+    fd = _open(serverlogfile, O_WRONLY|O_CREAT|O_APPEND, S_IREAD | S_IWRITE);
 #else
-#define OPENMODE S_IRUSR | S_IWUSR
+    fd = open(serverlogfile, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR | S_IWUSR);
 #endif
-    int fd = open(serverlogfile, O_WRONLY|O_CREAT|O_APPEND, OPENMODE);
     if(fd != -1) {
       static const char msg[] = "exit_signal_handler: called\n";
       (void)!write(fd, msg, sizeof(msg) - 1);