Fixed Coverity warnings
CIDs: 714,781,782,825,872,917 This commit was SVN r19354.
Этот коммит содержится в:
родитель
c65e8a6882
Коммит
0f9693d8af
@ -47,7 +47,7 @@ static char* replace_vars(char *v) {
|
|||||||
while ( *end && (isalnum(*end) || *end == '_')) end++;
|
while ( *end && (isalnum(*end) || *end == '_')) end++;
|
||||||
}
|
}
|
||||||
/* determine name of variable */
|
/* determine name of variable */
|
||||||
vname = (char*)malloc(end-start);
|
vname = (char*)malloc((end-start)+1);
|
||||||
strncpy(vname, start, end-start);
|
strncpy(vname, start, end-start);
|
||||||
vname[end-start] = '\0';
|
vname[end-start] = '\0';
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ static char* replace_vars(char *v) {
|
|||||||
|
|
||||||
/* put together string with variable replaced by value */
|
/* put together string with variable replaced by value */
|
||||||
/* -- allocate enough space and copy stuff before variable part */
|
/* -- allocate enough space and copy stuff before variable part */
|
||||||
res = (char*)malloc(strlen(v)+strlen(vval));
|
res = (char*)malloc(strlen(v)+strlen(vval)+1);
|
||||||
plen = (start - v) - 1 - extra;
|
plen = (start - v) - 1 - extra;
|
||||||
if (plen) strncpy(res, v, plen);
|
if (plen) strncpy(res, v, plen);
|
||||||
res[plen] = '\0';
|
res[plen] = '\0';
|
||||||
@ -64,6 +64,8 @@ static char* replace_vars(char *v) {
|
|||||||
strcat(res, vval);
|
strcat(res, vval);
|
||||||
/* -- add stuff after variable */
|
/* -- add stuff after variable */
|
||||||
if ( *end ) strcat(res, end + extra);
|
if ( *end ) strcat(res, end + extra);
|
||||||
|
|
||||||
|
free(vname);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +74,7 @@ static int parse_bool(char *str) {
|
|||||||
static char strbuf[128];
|
static char strbuf[128];
|
||||||
char* ptr = strbuf;
|
char* ptr = strbuf;
|
||||||
|
|
||||||
strncpy(strbuf, str, 128);
|
strncpy(strbuf, str, sizeof(strbuf)-1);
|
||||||
while ( *ptr )
|
while ( *ptr )
|
||||||
{
|
{
|
||||||
*ptr = tolower(*ptr);
|
*ptr = tolower(*ptr);
|
||||||
@ -498,22 +500,25 @@ char* vt_env_metrics_spec()
|
|||||||
{
|
{
|
||||||
char msg[128];
|
char msg[128];
|
||||||
char* spec = getenv("VT_METRICS_SPEC");
|
char* spec = getenv("VT_METRICS_SPEC");
|
||||||
|
int len;
|
||||||
|
|
||||||
if ( spec != NULL ) { /* use specified file */
|
if ( spec != NULL && strlen(spec) > 0 ) { /* use specified file */
|
||||||
sprintf(msg, "VT_METRICS_SPEC=%s", spec);
|
snprintf(msg, sizeof(msg)-1, "VT_METRICS_SPEC=%s", spec);
|
||||||
} else if (access(METRICS_SPEC, R_OK) == 0) {
|
} else if (access(METRICS_SPEC, R_OK) == 0) {
|
||||||
/* use file in current directory */
|
/* use file in current directory */
|
||||||
spec = (char*)calloc(strlen(METRICS_SPEC)+3, 1);
|
len = strlen(METRICS_SPEC)+3;
|
||||||
sprintf(spec, "./%s", METRICS_SPEC);
|
spec = (char*)calloc(len, sizeof(char));
|
||||||
sprintf(msg, "[CURDIR] VT_METRICS_SPEC=%s", spec);
|
snprintf(spec, len-1, "./%s", METRICS_SPEC);
|
||||||
|
snprintf(msg, sizeof(msg)-1, "[CURDIR] VT_METRICS_SPEC=%s", spec);
|
||||||
} else {
|
} else {
|
||||||
#ifdef DATADIR
|
#ifdef DATADIR
|
||||||
/* default to installation file */
|
/* default to installation file */
|
||||||
spec = (char*)calloc(strlen(DATADIR)+strlen(METRICS_SPEC)+2, 1);
|
len = strlen(DATADIR)+strlen(METRICS_SPEC)+2;
|
||||||
sprintf(spec, "%s/%s", DATADIR, METRICS_SPEC);
|
spec = (char*)calloc(len, sizeof(char));
|
||||||
sprintf(msg, "[DATADIR] VT_METRICS_SPEC=%s", spec);
|
snprintf(spec, len-1, "%s/%s", DATADIR, METRICS_SPEC);
|
||||||
|
snprintf(msg, sizeof(msg)-1, "[DATADIR] VT_METRICS_SPEC=%s", spec);
|
||||||
#else
|
#else
|
||||||
sprintf(msg, "VT_METRICS_SPEC not set");
|
snprintf(msg, sizeof(msg)-1, "VT_METRICS_SPEC not set");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
vt_cntl_msg(msg);
|
vt_cntl_msg(msg);
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user