From: Joel Rosdahl Date: Sat, 28 Sep 2024 19:16:05 +0000 (+0200) Subject: fix: Fix binary patching of sysconfdir for Linux prebuilt binary X-Git-Tag: v4.11~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e24e82fb73174dbca45cbf5b53d266d156114845;p=thirdparty%2Fccache.git fix: Fix binary patching of sysconfdir for Linux prebuilt binary After fs::path-ification it no longer works to binary patch sysconfdir at install time since the compiler apparently makes a note of the actual length of SYSCONFDIR in const char k_sysconfdir[4096 + 1] = SYSCONFDIR; and uses the length in the fs::path sysconfdir(k_sysconfdir); call. When patching the SYSCONFDIR string the length of the original string is used so that only the first strlen(SYSCONFDIR) part of the new sysconfdir will be used. Fix this by adding a pointer indirection which makes binary patching work again. --- diff --git a/src/ccache/config.cpp b/src/ccache/config.cpp index 9e38994c..193b85a5 100644 --- a/src/ccache/config.cpp +++ b/src/ccache/config.cpp @@ -59,8 +59,11 @@ DLLIMPORT extern char** environ; #endif -// Make room for binary patching at install time. -const char k_sysconfdir[4096 + 1] = SYSCONFDIR; +// Make room for binary patching at install time. The extra pointer to a buffer +// is needed to prevent the compiler from assuming too much about the string, +// such as its actual length. +const char k_sysconfdir_array[4096 + 1] = SYSCONFDIR; +const char* k_sysconfdir = k_sysconfdir_array; namespace fs = util::filesystem;