Merge branch 'develop' into MAX-324
Conflicts: server/include/modutil.h
This commit is contained in:
@ -71,7 +71,7 @@ static void blr_log_header(logfile_id_t file, char *msg, uint8_t *ptr);
|
||||
int
|
||||
blr_file_init(ROUTER_INSTANCE *router)
|
||||
{
|
||||
char *ptr, path[1024], filename[1050];
|
||||
char *ptr, path[1025], filename[1051];
|
||||
int file_found, n = 1;
|
||||
int root_len, i;
|
||||
DIR *dirp;
|
||||
@ -80,12 +80,12 @@ struct dirent *dp;
|
||||
if (router->binlogdir == NULL)
|
||||
{
|
||||
strcpy(path, "/usr/local/skysql/MaxScale");
|
||||
if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
|
||||
if ((ptr = getenv("MAXSCALE_HOME")) != NULL && strnlen(ptr,1025) < 1025)
|
||||
{
|
||||
strcpy(path, ptr);
|
||||
strncpy(path, ptr,PATH_MAX);
|
||||
}
|
||||
strcat(path, "/");
|
||||
strcat(path, router->service->name);
|
||||
strncat(path, "/",1024);
|
||||
strncat(path, router->service->name,1024);
|
||||
|
||||
if (access(path, R_OK) == -1)
|
||||
mkdir(path, 0777);
|
||||
@ -196,7 +196,7 @@ unsigned char magic[] = BINLOG_MAGIC;
|
||||
fsync(fd);
|
||||
close(router->binlog_fd);
|
||||
spinlock_acquire(&router->binlog_lock);
|
||||
strcpy(router->binlog_name, file);
|
||||
strncpy(router->binlog_name, file,BINLOG_FNAMELEN);
|
||||
router->binlog_position = 4; /* Initial position after the magic number */
|
||||
spinlock_release(&router->binlog_lock);
|
||||
router->binlog_fd = fd;
|
||||
@ -230,7 +230,7 @@ int fd;
|
||||
fsync(fd);
|
||||
close(router->binlog_fd);
|
||||
spinlock_acquire(&router->binlog_lock);
|
||||
strcpy(router->binlog_name, file);
|
||||
strncpy(router->binlog_name, file,BINLOG_FNAMELEN);
|
||||
router->binlog_position = lseek(fd, 0L, SEEK_END);
|
||||
spinlock_release(&router->binlog_lock);
|
||||
router->binlog_fd = fd;
|
||||
@ -290,7 +290,7 @@ blr_file_flush(ROUTER_INSTANCE *router)
|
||||
BLFILE *
|
||||
blr_open_binlog(ROUTER_INSTANCE *router, char *binlog)
|
||||
{
|
||||
char path[1024];
|
||||
char path[1025];
|
||||
BLFILE *file;
|
||||
|
||||
spinlock_acquire(&router->fileslock);
|
||||
@ -310,14 +310,14 @@ BLFILE *file;
|
||||
spinlock_release(&router->fileslock);
|
||||
return NULL;
|
||||
}
|
||||
strcpy(file->binlogname, binlog);
|
||||
strncpy(file->binlogname, binlog,BINLOG_FNAMELEN+1);
|
||||
file->refcnt = 1;
|
||||
file->cache = 0;
|
||||
spinlock_init(&file->lock);
|
||||
|
||||
strcpy(path, router->binlogdir);
|
||||
strcat(path, "/");
|
||||
strcat(path, binlog);
|
||||
strncpy(path, router->binlogdir,1024);
|
||||
strncat(path, "/",1024);
|
||||
strncat(path, binlog,1024);
|
||||
|
||||
if ((file->fd = open(path, O_RDONLY, 0666)) == -1)
|
||||
{
|
||||
@ -630,7 +630,7 @@ struct stat statb;
|
||||
void
|
||||
blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf)
|
||||
{
|
||||
char path[4096], *ptr;
|
||||
char path[4097], *ptr;
|
||||
int fd;
|
||||
|
||||
strcpy(path, "/usr/local/skysql/MaxScale");
|
||||
|
@ -1228,8 +1228,8 @@ MYSQL_session *auth_info;
|
||||
|
||||
if ((auth_info = calloc(1, sizeof(MYSQL_session))) == NULL)
|
||||
return NULL;
|
||||
strcpy(auth_info->user, username);
|
||||
strcpy(auth_info->db, database);
|
||||
strncpy(auth_info->user, username,MYSQL_USER_MAXLEN+1);
|
||||
strncpy(auth_info->db, database,MYSQL_DATABASE_MAXLEN+1);
|
||||
gw_sha1_str((const uint8_t *)password, strlen(password), auth_info->client_sha1);
|
||||
|
||||
return auth_info;
|
||||
|
@ -385,7 +385,9 @@ char *sql;
|
||||
if (modutil_MySQL_Query(queue, &sql, &len, &residual))
|
||||
{
|
||||
sql = strndup(sql, len);
|
||||
return maxinfo_execute_query(instance, session, sql);
|
||||
int rc = maxinfo_execute_query(instance, session, sql);
|
||||
free(sql);
|
||||
return rc;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -85,6 +85,7 @@ int len;
|
||||
return;
|
||||
sprintf(msg, "%s in query '%s'", desc, sql);
|
||||
maxinfo_send_error(dcb, 1149, msg);
|
||||
free(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,7 +113,7 @@ int len;
|
||||
data[4] = 0xff; // Error indicator
|
||||
data[5] = errcode & 0xff; // Error Code
|
||||
data[6] = (errcode >> 8) & 0xff; // Error Code
|
||||
strncpy((char *)&data[7], "#42000", 6);
|
||||
strncpy((char *)&data[13], msg, strlen(msg)); // Error Message
|
||||
memcpy(&data[7], "#42000", 6);
|
||||
memcpy(&data[13], msg, strlen(msg)); // Error Message
|
||||
dcb->func.write(dcb, pkt);
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ exec_select(DCB *dcb, MAXINFO_TREE *tree)
|
||||
static int
|
||||
maxinfo_pattern_match(char *pattern, char *str)
|
||||
{
|
||||
int anchor, len, trailing;
|
||||
int anchor = 0, len, trailing;
|
||||
char *fixed;
|
||||
extern char *strcasestr();
|
||||
|
||||
|
@ -100,6 +100,7 @@ MAXINFO_TREE *col, *table;
|
||||
}
|
||||
}
|
||||
// Malformed show
|
||||
free(text);
|
||||
free_tree(tree);
|
||||
*parse_error = PARSE_MALFORMED_SHOW;
|
||||
return NULL;
|
||||
@ -136,31 +137,35 @@ parse_column_list(char **ptr)
|
||||
int token, lookahead;
|
||||
char *text, *text2;
|
||||
MAXINFO_TREE *tree = NULL;
|
||||
|
||||
MAXINFO_TREE * rval = NULL;
|
||||
*ptr = fetch_token(*ptr, &token, &text);
|
||||
*ptr = fetch_token(*ptr, &lookahead, &text2);
|
||||
switch (token)
|
||||
{
|
||||
case LT_STRING:
|
||||
free(text2);
|
||||
switch (lookahead)
|
||||
{
|
||||
case LT_COMMA:
|
||||
return make_tree_node(MAXOP_COLUMNS, text, NULL,
|
||||
rval = make_tree_node(MAXOP_COLUMNS, text, NULL,
|
||||
parse_column_list(ptr));
|
||||
case LT_FROM:
|
||||
return make_tree_node(MAXOP_COLUMNS, text, NULL,
|
||||
rval = make_tree_node(MAXOP_COLUMNS, text, NULL,
|
||||
NULL);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case LT_STAR:
|
||||
free(text);
|
||||
free(text2);
|
||||
if (lookahead != LT_FROM)
|
||||
return make_tree_node(MAXOP_ALL_COLUMNS, NULL, NULL,
|
||||
rval = make_tree_node(MAXOP_ALL_COLUMNS, NULL, NULL,
|
||||
NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
free(text);
|
||||
free(text2);
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
||||
@ -180,6 +185,7 @@ MAXINFO_TREE *tree = NULL;
|
||||
*ptr = fetch_token(*ptr, &token, &text);
|
||||
if (token == LT_STRING)
|
||||
return make_tree_node(MAXOP_TABLE, text, NULL, NULL);
|
||||
free(text);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ char* get_lenenc_str(void* data, int* len)
|
||||
* Parses a response set to a SHOW DATABASES query and inserts them into the
|
||||
* router client session's database hashtable. The name of the database is used
|
||||
* as the key and the unique name of the server is the value. The function
|
||||
* currently supports only result sets that span a single GWBUF.
|
||||
* currently supports only result sets that span a single SQL packet.
|
||||
* @param rses Router client session
|
||||
* @param target Target server where the database is
|
||||
* @param buf GWBUF containing the result set
|
||||
@ -315,9 +315,9 @@ bool parse_showdb_response(ROUTER_CLIENT_SES* rses, char* target, GWBUF* buf)
|
||||
{
|
||||
bool rval = false;
|
||||
unsigned char* ptr;
|
||||
|
||||
int more = 0;
|
||||
if(PTR_IS_RESULTSET(((unsigned char*)buf->start)) &&
|
||||
modutil_count_signal_packets(buf,0,0) == 2)
|
||||
modutil_count_signal_packets(buf,0,0,&more) == 2)
|
||||
{
|
||||
ptr = (unsigned char*)buf->start;
|
||||
|
||||
|
@ -334,9 +334,10 @@ parse_mapping_response(ROUTER_CLIENT_SES* rses, char* target, GWBUF* buf)
|
||||
{
|
||||
bool rval = false;
|
||||
unsigned char* ptr;
|
||||
int more = 0;
|
||||
|
||||
if(PTR_IS_RESULTSET(((unsigned char*)buf->start)) &&
|
||||
modutil_count_signal_packets(buf,0,0) == 2)
|
||||
modutil_count_signal_packets(buf,0,0,&more) == 2)
|
||||
{
|
||||
ptr = (char*)buf->start;
|
||||
|
||||
@ -2988,4 +2989,4 @@ reply_error:
|
||||
}
|
||||
retblock:
|
||||
return succp;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user