From cd99d6c1dd45379e69b25cc167c0456df32cc19b Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 16 Feb 2015 09:11:55 +0200 Subject: [PATCH] Fixes to Coverity defects 87073, 87388. --- server/core/service.c | 30 +++++++++++++++++++++++++++--- server/modules/filter/fwfilter.c | 2 +- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/server/core/service.c b/server/core/service.c index 95f9ac771..167f8a4e7 100644 --- a/server/core/service.c +++ b/server/core/service.c @@ -221,7 +221,7 @@ GWPROTOCOL *funcs; { /* Try loading authentication data from file cache */ - char *ptr, path[4096]; + char *ptr, path[4097]; strcpy(path, "/usr/local/skysql/MaxScale"); if ((ptr = getenv("MAXSCALE_HOME")) != NULL) { @@ -251,6 +251,7 @@ GWPROTOCOL *funcs; { /* Save authentication data to file cache */ char *ptr, path[4096]; + int mkdir_rval = 0; strcpy(path, "/usr/local/skysql/MaxScale"); if ((ptr = getenv("MAXSCALE_HOME")) != NULL) { @@ -259,10 +260,33 @@ GWPROTOCOL *funcs; strncat(path, "/", 4096); strncat(path, service->name, 4096); if (access(path, R_OK) == -1) - mkdir(path, 0777); + { + mkdir_rval = mkdir(path, 0777); + } + + if(mkdir_rval) + { + skygw_log_write(LOGFILE_ERROR,"Error : Failed to create directory '%s': [%d] %s", + path, + errno, + strerror(errno)); + mkdir_rval = 0; + } + strncat(path, "/.cache", 4096); if (access(path, R_OK) == -1) - mkdir(path, 0777); + { + mkdir_rval = mkdir(path, 0777); + } + + if(mkdir_rval) + { + skygw_log_write(LOGFILE_ERROR,"Error : Failed to create directory '%s': [%d] %s", + path, + errno, + strerror(errno)); + mkdir_rval = 0; + } strncat(path, "/dbusers", 4096); dbusers_save(service->users, path); } diff --git a/server/modules/filter/fwfilter.c b/server/modules/filter/fwfilter.c index 595be17ea..7766521cf 100644 --- a/server/modules/filter/fwfilter.c +++ b/server/modules/filter/fwfilter.c @@ -637,7 +637,7 @@ void link_rules(char* rule, FW_INSTANCE* instance) /**Apply rules to users*/ - bool match_any; + bool match_any = true; char *tok, *ruleptr, *userptr, *modeptr; char *saveptr = NULL; RULELIST* rulelist = NULL;