[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sal/android

Jan Holesovsky (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 19 23:01:11 UTC 2019


 sal/android/libreofficekit-jni.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

New commits:
commit 8756beb31ce7cf5c2e54963c6c29594c47de26b9
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Jun 19 20:29:02 2019 +0200
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed Jun 19 22:20:25 2019 +0200

    android: Fix type of a C string to be const char[].
    
    With the wrong type, we were measusing 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 at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/sal/android/libreofficekit-jni.c b/sal/android/libreofficekit-jni.c
index 0f66fdc44fe0..1307ab6a5fbb 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) {


More information about the Libreoffice-commits mailing list