[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), `<string.h>` 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.
This commit is contained in:
Jonathan Hui
2026-10-26 22:16:27 +01:00
committed by GitHub
parent 099a7e133e
commit fdb6f96072
+8 -1
View File
@@ -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