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.
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;