Fixes to Coverity defects.
This commit is contained in:
@ -2138,7 +2138,7 @@ config_get_release_string(char* release)
|
|||||||
*end = 0;
|
*end = 0;
|
||||||
|
|
||||||
to = strcpy(distribution, "lsb: ");
|
to = strcpy(distribution, "lsb: ");
|
||||||
memmove(to, found, end - found + 1);
|
memmove(to, found, end - found + 1 < INT_MAX ? end - found + 1 : INT_MAX);
|
||||||
|
|
||||||
strncpy(release, to, _RELEASE_STR_LENGTH);
|
strncpy(release, to, _RELEASE_STR_LENGTH);
|
||||||
|
|
||||||
@ -2175,7 +2175,7 @@ config_get_release_string(char* release)
|
|||||||
+5 and -8 below cut the file name part out of the
|
+5 and -8 below cut the file name part out of the
|
||||||
full pathname that corresponds to the mask as above.
|
full pathname that corresponds to the mask as above.
|
||||||
*/
|
*/
|
||||||
new_to = strcpy(distribution, found.gl_pathv[0] + 5);
|
new_to = strncpy(distribution, found.gl_pathv[0] + 5,_RELEASE_STR_LENGTH - 1);
|
||||||
new_to += 8;
|
new_to += 8;
|
||||||
*new_to++ = ':';
|
*new_to++ = ':';
|
||||||
*new_to++ = ' ';
|
*new_to++ = ' ';
|
||||||
|
@ -798,7 +798,7 @@ getUsers(SERVICE *service, USERS *users)
|
|||||||
if (db_grants) {
|
if (db_grants) {
|
||||||
/* we have dbgrants, store them */
|
/* we have dbgrants, store them */
|
||||||
if(row[5]){
|
if(row[5]){
|
||||||
strcpy(dbnm,row[5]);
|
strncpy(dbnm,row[5],MYSQL_DATABASE_MAXLEN);
|
||||||
if(service->strip_db_esc) {
|
if(service->strip_db_esc) {
|
||||||
strip_escape_chars(dbnm);
|
strip_escape_chars(dbnm);
|
||||||
}
|
}
|
||||||
|
@ -690,6 +690,8 @@ module_create_feedback_report(GWBUF **buffer, MODULES *modules, FEEDBACK_CONF *c
|
|||||||
time_t now;
|
time_t now;
|
||||||
struct tm *now_tm;
|
struct tm *now_tm;
|
||||||
int report_max_bytes=0;
|
int report_max_bytes=0;
|
||||||
|
if(buffer == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
|
|
||||||
@ -838,13 +840,13 @@ do_http_post(GWBUF *buffer, void *cfg) {
|
|||||||
/* Check for errors */
|
/* Check for errors */
|
||||||
if(res != CURLE_OK) {
|
if(res != CURLE_OK) {
|
||||||
ret_code = 2;
|
ret_code = 2;
|
||||||
|
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Error: do_http_post(), curl call for [%s] failed due: %s, %s",
|
"Error: do_http_post(), curl call for [%s] failed due: %s, %s",
|
||||||
feedback_config->feedback_url,
|
feedback_config->feedback_url,
|
||||||
curl_easy_strerror(res),
|
curl_easy_strerror(res),
|
||||||
error_message)));
|
error_message)));
|
||||||
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
|
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
|
||||||
}
|
}
|
||||||
@ -855,6 +857,7 @@ do_http_post(GWBUF *buffer, void *cfg) {
|
|||||||
ret_code = 0;
|
ret_code = 0;
|
||||||
} else {
|
} else {
|
||||||
ret_code = 3;
|
ret_code = 3;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
@ -862,18 +865,21 @@ do_http_post(GWBUF *buffer, void *cfg) {
|
|||||||
"Error: do_http_post(), Bad HTTP Code from remote server: %lu",
|
"Error: do_http_post(), Bad HTTP Code from remote server: %lu",
|
||||||
http_code)));
|
http_code)));
|
||||||
ret_code = 4;
|
ret_code = 4;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Error: do_http_post(), curl object not initialized")));
|
"Error: do_http_post(), curl object not initialized")));
|
||||||
ret_code = 1;
|
ret_code = 1;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGIF(LT, (skygw_log_write_flush(
|
LOGIF(LT, (skygw_log_write_flush(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_TRACE,
|
||||||
"do_http_post() ret_code [%d], HTTP code [%d]",
|
"do_http_post() ret_code [%d], HTTP code [%d]",
|
||||||
ret_code, http_code)));
|
ret_code, http_code)));
|
||||||
|
cleanup:
|
||||||
|
|
||||||
if (chunk.data)
|
if (chunk.data)
|
||||||
free(chunk.data);
|
free(chunk.data);
|
||||||
|
@ -126,7 +126,7 @@ MAXINFO_TREE *col, *table;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a column list, may be a * or a valid list of string name
|
* Parse a column list, may be a * or a valid list of string name
|
||||||
* seperated by a comma
|
* separated by a comma
|
||||||
*
|
*
|
||||||
* @param sql Pointer to pointer to column list updated to point to the table name
|
* @param sql Pointer to pointer to column list updated to point to the table name
|
||||||
* @return A tree of column names
|
* @return A tree of column names
|
||||||
@ -148,9 +148,11 @@ MAXINFO_TREE * rval = NULL;
|
|||||||
case LT_COMMA:
|
case LT_COMMA:
|
||||||
rval = make_tree_node(MAXOP_COLUMNS, text, NULL,
|
rval = make_tree_node(MAXOP_COLUMNS, text, NULL,
|
||||||
parse_column_list(ptr));
|
parse_column_list(ptr));
|
||||||
|
break;
|
||||||
case LT_FROM:
|
case LT_FROM:
|
||||||
rval = make_tree_node(MAXOP_COLUMNS, text, NULL,
|
rval = make_tree_node(MAXOP_COLUMNS, text, NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1632,7 +1632,7 @@ gen_show_dbs_response(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client)
|
|||||||
rval = gwbuf_append(rval, last_packet);
|
rval = gwbuf_append(rval, last_packet);
|
||||||
|
|
||||||
rval = gwbuf_make_contiguous(rval);
|
rval = gwbuf_make_contiguous(rval);
|
||||||
|
hashtable_iterator_free(iter);
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2224,18 +2224,19 @@ static void clientReply (
|
|||||||
goto lock_failed;
|
goto lock_failed;
|
||||||
}
|
}
|
||||||
bref = get_bref_from_dcb(router_cli_ses, backend_dcb);
|
bref = get_bref_from_dcb(router_cli_ses, backend_dcb);
|
||||||
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Received reply from %s for session %p",
|
|
||||||
bref->bref_backend->backend_server->unique_name,
|
|
||||||
router_cli_ses->rses_client_dcb->session);
|
|
||||||
#if !defined(FOR_BUG548_FIX_ONLY)
|
|
||||||
/** This makes the issue becoming visible in poll.c */
|
|
||||||
if (bref == NULL)
|
if (bref == NULL)
|
||||||
{
|
{
|
||||||
/** Unlock router session */
|
/** Unlock router session */
|
||||||
rses_end_locked_router_action(router_cli_ses);
|
rses_end_locked_router_action(router_cli_ses);
|
||||||
goto lock_failed;
|
goto lock_failed;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Received reply from %s for session %p",
|
||||||
|
bref->bref_backend->backend_server->unique_name,
|
||||||
|
router_cli_ses->rses_client_dcb->session);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(router_cli_ses->init & INIT_MAPPING)
|
if(router_cli_ses->init & INIT_MAPPING)
|
||||||
{
|
{
|
||||||
@ -3905,7 +3906,7 @@ static bool handle_error_new_connection(
|
|||||||
|
|
||||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: Re-mapping databases");
|
skygw_log_write(LOGFILE_TRACE,"schemarouter: Re-mapping databases");
|
||||||
gen_databaselist(rses->router,rses);
|
gen_databaselist(rses->router,rses);
|
||||||
|
hashtable_iterator_free(iter);
|
||||||
return_succp:
|
return_succp:
|
||||||
return succp;
|
return succp;
|
||||||
}
|
}
|
||||||
|
@ -274,6 +274,7 @@ char* get_lenenc_str(void* data, int* len)
|
|||||||
|
|
||||||
if(data == NULL || len == NULL)
|
if(data == NULL || len == NULL)
|
||||||
{
|
{
|
||||||
|
if(len)
|
||||||
*len = -1;
|
*len = -1;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1099,7 +1100,8 @@ return_rses:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
errorblock:
|
errorblock:
|
||||||
if(client_rses->subservice)
|
|
||||||
|
if(client_rses && client_rses->subservice)
|
||||||
{
|
{
|
||||||
for(j = 0; j < i; j++)
|
for(j = 0; j < i; j++)
|
||||||
{
|
{
|
||||||
@ -1661,14 +1663,7 @@ routeQuery(ROUTER* instance,
|
|||||||
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/** Something else went wrong, terminate connection */
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
goto retblock;
|
goto retblock;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2794,6 +2789,9 @@ get_shard_subsvc(SUBSERVICE** subsvc,ROUTER_CLIENT_SES* session,char* target)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if(subsvc == NULL || session == NULL || target == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
for(i = 0;i<session->n_subservice;i++)
|
for(i = 0;i<session->n_subservice;i++)
|
||||||
{
|
{
|
||||||
if(strcmp(session->subservice[i]->service->name,target) == 0)
|
if(strcmp(session->subservice[i]->service->name,target) == 0)
|
||||||
@ -2859,7 +2857,7 @@ router_handle_state_switch(
|
|||||||
CHK_DCB(dcb);
|
CHK_DCB(dcb);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
#if 0
|
||||||
if(SERVER_IS_RUNNING(srv) && SERVER_IS_IN_CLUSTER(srv))
|
if(SERVER_IS_RUNNING(srv) && SERVER_IS_IN_CLUSTER(srv))
|
||||||
{
|
{
|
||||||
goto return_rc;
|
goto return_rc;
|
||||||
@ -2882,6 +2880,7 @@ router_handle_state_switch(
|
|||||||
|
|
||||||
return_rc:
|
return_rc:
|
||||||
return rc;
|
return rc;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +78,7 @@ int main(int argc, char** argv)
|
|||||||
goto report;
|
goto report;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(query,"STOP SLAVE",databases[i]);
|
sprintf(query,"STOP SLAVE");
|
||||||
if(mysql_real_query(server,query,strlen(query)))
|
if(mysql_real_query(server,query,strlen(query)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to stop slave in %d: %s.\n",
|
fprintf(stderr, "Failed to stop slave in %d: %s.\n",
|
||||||
|
Reference in New Issue
Block a user