]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Fix binary patching of sysconfdir for Linux prebuilt binary
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 28 Sep 2024 19:16:05 +0000 (21:16 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 17 Oct 2024 19:56:57 +0000 (21:56 +0200)
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.

src/ccache/config.cpp

index 9e38994c3d3d898b1271fef0c38a43052744a4e8..193b85a524406b7baf539f9dc63349027a5389ce 100644 (file)
 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;