Fixes to Coverity defects.

This commit is contained in:
Markus Makela
2015-08-26 09:35:10 +03:00
parent b3be72022c
commit 3e863863dd
3 changed files with 9 additions and 9 deletions

View File

@ -109,7 +109,7 @@ EXTERNCMD* externcmd_allocate(char* argstr)
if(access(cmd->parameters[0],X_OK) != 0) if(access(cmd->parameters[0],X_OK) != 0)
{ {
skygw_log_write(LE, skygw_log_write(LE,
"Error: Cannot execute file: %s", "Error: Cannot execute file '%s'. Missing execution permissions.",
cmd->parameters[0]); cmd->parameters[0]);
externcmd_free(cmd); externcmd_free(cmd);
return NULL; return NULL;

View File

@ -242,11 +242,11 @@ GWPROTOCOL *funcs;
{ {
/* Try loading authentication data from file cache */ /* Try loading authentication data from file cache */
char *ptr, path[4097]; char *ptr, path[PATH_MAX+1];
strcpy(path, get_cachedir()); strncpy(path, get_cachedir(),sizeof(path)-1);
strncat(path, "/", 4096); strncat(path, "/", sizeof(path)-1);
strncat(path, service->name, 4096); strncat(path, service->name, sizeof(path)-1);
strncat(path, "/.cache/dbusers", 4096); strncat(path, "/.cache/dbusers", sizeof(path)-1);
loaded = dbusers_load(service->users, path); loaded = dbusers_load(service->users, path);
if (loaded != -1) if (loaded != -1)
{ {

View File

@ -239,7 +239,7 @@ void mon_append_node_names(MONITOR_SERVERS* start,char* str, int len)
} }
first = false; first = false;
sprintf(arr,"%s:%d",ptr->server->name,ptr->server->port); sprintf(arr,"%s:%d",ptr->server->name,ptr->server->port);
strcat(str,arr); strncat(str,arr,len);
ptr = ptr->next; ptr = ptr->next;
slen = strlen(str); slen = strlen(str);
} }
@ -306,10 +306,10 @@ void monitor_launch_script(MONITOR* mon,MONITOR_SERVERS* ptr, char* script)
ptr->server->name, ptr->server->name,
ptr->server->port); ptr->server->port);
mon_append_node_names(mon->databases,argstr,PATH_MAX + MON_ARG_MAX + 1); mon_append_node_names(mon->databases,argstr,PATH_MAX + MON_ARG_MAX);
if((cmd = externcmd_allocate(argstr)) == NULL) if((cmd = externcmd_allocate(argstr)) == NULL)
{ {
skygw_log_write(LE,"Failed to execute script: %s",script); skygw_log_write(LE,"Failed to initialize script: %s",script);
return; return;
} }