servers: fix to avoid a non-signal-safe call in signal handler

`strlen()` is only guaranteed to be signal-safe since POSIX.1-2008.

Ref: https://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_03

Reported by Copilot
Bug: https://github.com/curl/curl/pull/22487#pullrequestreview-4863961494
Follow-up to e95f509c66 #16852

Closes #22491
This commit is contained in:
Viktor Szakats 2026-08-05 14:06:57 +02:00
parent 518a4dadff
commit b260e9f841
No known key found for this signature in database

View file

@ -399,8 +399,11 @@ static void exit_signal_handler(int signum)
}
else {
static const char msg[] = "exit_signal_handler: failed opening ";
const char *str;
(void)write(STDERR_FILENO, msg, CURL_CSTRLEN(msg));
(void)write(STDERR_FILENO, serverlogfile, strlen(serverlogfile));
str = serverlogfile;
while(*str)
(void)write(STDERR_FILENO, str++, 1);
(void)write(STDERR_FILENO, "\n", 1);
}
}