From ac7ea79c330d9684e39cb41ef528a1c44eb13616 Mon Sep 17 00:00:00 2001 From: gcontini <1121667+gcontini@users.noreply.github.com> Date: 周六, 30 11月 2019 16:20:10 +0800 Subject: [PATCH] update install targets --- src/library/base/logger.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/library/base/logger.c b/src/library/base/logger.c index 4ee8354..a6dc5f3 100644 --- a/src/library/base/logger.c +++ b/src/library/base/logger.c @@ -4,8 +4,9 @@ #include <string.h> #include <stdarg.h> #include <time.h> -#include <unistd.h> + #ifdef __unix__ +#include <unistd.h> #define MAX_PATH 255 #else #include <windows.h> @@ -29,18 +30,18 @@ if (folder == 0) { folder = "/tmp"; } - strcpy(logpath, folder); - strcat(logpath, "/open-license.log"); + strncpy(logpath, folder, MAX_PATH); + strncat(logpath, "/open-license.log", MAX_PATH - strlen(logpath)); #else - int plen=GetTempPath(MAX_PATH,logpath); + const int plen = GetTempPath(MAX_PATH, logpath); if(plen == 0) { fprintf(stderr, "Error getting temporary directory path"); } - strcat(logpath,"open-license.log"); + strncat(logpath, "open-license.log", MAX_PATH - strlen(logpath)); #endif } -void _log(char* format, ...) { +void _log(const char* format, ...) { char logpath[MAX_PATH]; va_list args; char * buffer; -- Gitblit v1.9.1