summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitInit.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h
index 6190d728ecfa..4f745fc6e96c 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -164,19 +164,20 @@ static void *lok_dlopen( const char *install_path, char ** _imp_lib )
// allocate large enough buffer
partial_length = strlen(install_path);
- imp_lib = (char *) malloc(partial_length + sizeof(TARGET_LIB) + sizeof(TARGET_MERGED_LIB) + 2);
+ size_t imp_lib_size = partial_length + sizeof(TARGET_LIB) + sizeof(TARGET_MERGED_LIB) + 2;
+ imp_lib = (char *) malloc(imp_lib_size);
if (!imp_lib)
{
fprintf( stderr, "failed to open library : not enough memory\n");
return NULL;
}
- strcpy(imp_lib, install_path);
+ strncpy(imp_lib, install_path, imp_lib_size);
extendUnoPath(install_path);
imp_lib[partial_length++] = SEPARATOR;
- strcpy(imp_lib + partial_length, TARGET_LIB);
+ strncpy(imp_lib + partial_length, TARGET_LIB, imp_lib_size - partial_length);
dlhandle = lok_loadlib(imp_lib);
if (!dlhandle)
@@ -194,7 +195,7 @@ static void *lok_dlopen( const char *install_path, char ** _imp_lib )
return NULL;
}
- strcpy(imp_lib + partial_length, TARGET_MERGED_LIB);
+ strncpy(imp_lib + partial_length, TARGET_MERGED_LIB, imp_lib_size - partial_length);
dlhandle = lok_loadlib(imp_lib);
if (!dlhandle)