From fdb6f960723ec6dd2b46feafc6642dad606fe286 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Mon, 26 Oct 2026 22:16:27 +0100 Subject: [PATCH] [script] fix socat 1.7.4.4 build with C23 / glibc 2.43 (#13796) In `socat-1.7.4.4/filan.c`, `printtime()` declares `const char *s`, assigns `asctime(localtime(&time))` (which returns `char *`), and strips the trailing newline in place via `*strchr(s, '\n') = '\0'`. With glibc 2.43 and `-D_GNU_SOURCE` (as on Ubuntu 26.04 with GCC 15.2), `` enables ISO C23 qualifier-preserving `_Generic` macros so `strchr(const char *, int)` returns `const char *`, causing `make` in `script/install_socat` to fail with `error: assignment of read-only location` (even if `-std=gnu17` is passed). This commit patches `printtime()` in `filan.c` after archive extraction to declare `char *s;` (matching `asctime()`'s `char *` return type without altering `const char *s;` in `getfiletypestring()` above it), using a POSIX `sed` + `mv` sequence compatible with both Linux and macOS. --- script/install_socat | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/script/install_socat b/script/install_socat index 923240200..e0d932670 100644 --- a/script/install_socat +++ b/script/install_socat @@ -75,4 +75,11 @@ cd "$TEMP_PATH" "$SOCAT_URL" verify_sha256 "$SOCAT_TAR" tar -xjf "$SOCAT_TAR" -cd "$SOCAT" && ./configure "$INSTALL_PREFIX" && make && sudo make install +cd "$SOCAT" +# Fix C23 / glibc 2.43 build failure where const-preserving strchr() rejects +# mutating asctime()'s char * return value through a const char * variable. +sed '/^static int printtime(/,/^}/s/const char \*s;/char *s;/' filan.c >filan.c.tmp +mv filan.c.tmp filan.c +./configure "$INSTALL_PREFIX" +make +sudo make install