diff options
author | Jan Holesovsky <kendy@collabora.com> | 2019-06-19 20:29:02 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2019-10-09 10:41:10 +0200 |
commit | 46bc671e837d9d9695b2d7474c2d322c7aef3142 (patch) | |
tree | 4778d9fe1def71fe1a4f14ec1c5339b6925610a5 /sal | |
parent | 5b4b8538fdab65a2a8b9884fa031672e9ed32052 (diff) |
android: Fix type of a C string to be const char[].
With the wrong type, we were measuring the sizeof() wrongly, leading to
a hard to catch crash at start that appeared only from time to time.
Improve the concatenation too when at that.
Change-Id: I4a4ab2909124281aac99118d66c62d669294d5f7
Reviewed-on: https://gerrit.libreoffice.org/74375
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/74444
Tested-by: Jenkins
Reviewed-on: https://gerrit.libreoffice.org/80285
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/android/libreofficekit-jni.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sal/android/libreofficekit-jni.c b/sal/android/libreofficekit-jni.c index 9466d2efdb3f..9f96d30d7ae0 100644 --- a/sal/android/libreofficekit-jni.c +++ b/sal/android/libreofficekit-jni.c @@ -75,7 +75,8 @@ jboolean libreofficekit_initialize(JNIEnv* env, const char *cacheDirPath; const char *apkFilePath; - const char *fontsConf = "/etc/fonts/fonts.conf"; + size_t data_dir_len; + const char fontsConf[] = "/etc/fonts/fonts.conf"; char *fontsConfPath; setenv("OOO_DISABLE_RECOVERY", "1", 1); @@ -93,9 +94,10 @@ jboolean libreofficekit_initialize(JNIEnv* env, // TMPDIR is used by osl_getTempDirURL() setenv("TMPDIR", cache_dir, 1); - fontsConfPath = malloc(strlen(data_dir) + sizeof(fontsConf)); - strcpy(fontsConfPath, data_dir); - strcat(fontsConfPath, fontsConf); + data_dir_len = strlen(data_dir); + fontsConfPath = malloc(data_dir_len + sizeof(fontsConf)); + strncpy(fontsConfPath, data_dir, data_dir_len); + strncpy(fontsConfPath + data_dir_len, fontsConf, sizeof(fontsConf)); fd = open(fontsConfPath, O_RDONLY); if (fd != -1) { |