Fixes to Coverity defects 87073, 87388.

This commit is contained in:
Markus Makela
2015-02-16 09:11:55 +02:00
parent 37360eb02e
commit cd99d6c1dd
2 changed files with 28 additions and 4 deletions

View File

@ -221,7 +221,7 @@ GWPROTOCOL *funcs;
{ {
/* Try loading authentication data from file cache */ /* Try loading authentication data from file cache */
char *ptr, path[4096]; char *ptr, path[4097];
strcpy(path, "/usr/local/skysql/MaxScale"); strcpy(path, "/usr/local/skysql/MaxScale");
if ((ptr = getenv("MAXSCALE_HOME")) != NULL) if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
{ {
@ -251,6 +251,7 @@ GWPROTOCOL *funcs;
{ {
/* Save authentication data to file cache */ /* Save authentication data to file cache */
char *ptr, path[4096]; char *ptr, path[4096];
int mkdir_rval = 0;
strcpy(path, "/usr/local/skysql/MaxScale"); strcpy(path, "/usr/local/skysql/MaxScale");
if ((ptr = getenv("MAXSCALE_HOME")) != NULL) if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
{ {
@ -259,10 +260,33 @@ GWPROTOCOL *funcs;
strncat(path, "/", 4096); strncat(path, "/", 4096);
strncat(path, service->name, 4096); strncat(path, service->name, 4096);
if (access(path, R_OK) == -1) 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); strncat(path, "/.cache", 4096);
if (access(path, R_OK) == -1) 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); strncat(path, "/dbusers", 4096);
dbusers_save(service->users, path); dbusers_save(service->users, path);
} }

View File

@ -637,7 +637,7 @@ void link_rules(char* rule, FW_INSTANCE* instance)
/**Apply rules to users*/ /**Apply rules to users*/
bool match_any; bool match_any = true;
char *tok, *ruleptr, *userptr, *modeptr; char *tok, *ruleptr, *userptr, *modeptr;
char *saveptr = NULL; char *saveptr = NULL;
RULELIST* rulelist = NULL; RULELIST* rulelist = NULL;