From c93b4d30a3a7144db800b8d471518ac9867b071c Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 12 Sep 2014 10:41:22 +1000 Subject: [PATCH] SICS-777 Allow the log directory to be set by SICS_INIT_LOGPATH environement variable --- servlog.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/servlog.c b/servlog.c index 72cf3825..da51c839 100644 --- a/servlog.c +++ b/servlog.c @@ -270,8 +270,8 @@ static FILE *fLogFile = NULL; static int iFile = 0; static int iLineCount = 0; static int iLogUsable = 1; -static char filnam[512]; -static char prevfilnam[512]; +static char filnam[1024]; +static char prevfilnam[1024]; /*---------------------------------------------------------------------------*/ int OpenVerifyLogFile() @@ -280,17 +280,21 @@ int OpenVerifyLogFile() char *pChar = NULL; char fPath[1024]; -/* snprintf(fPath, 1023, "%s/", getenv("SICS_INIT_LOGPATH")); */ - snprintf(fPath, 1023, "%s/", "../log"); + pChar = getenv("SICS_INIT_LOGPATH"); + if (!pChar) { + snprintf(fPath, sizeof(fPath) - 1, "%s/", "../log"); + } else { + snprintf(fPath, sizeof(fPath) - 1, "%s/", pChar); + } pChar = IFindOption(pSICSOptions, "LogFileBaseName"); if (!pChar) { /* Try to write to file "server" in */ strcpy(pFile, "server"); } else { - strlcpy(pFile, pChar, 255); + strlcpy(pFile, pChar, sizeof(pFile) - 1); } - snprintf(filnam, 511, "%s%s_%19.19s.%02d.log", fPath, pFile, timestamp(NULL, '-'), iFile); + snprintf(filnam, sizeof(filnam) - 1, "%s%s_%19.19s.%02d.log", fPath, pFile, timestamp(NULL, '-'), iFile); iFile++; if (iFile >= MAXFILES) { iFile = 0;