diff options
author | unknown <monty@mysql.com> | 2004-05-15 09:08:03 +0300 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-05-15 09:08:03 +0300 |
commit | bba41a1cdd6617aa586886a29c02c874122f77df (patch) | |
tree | c06f8d43d8562af60ba084e2156426de344720cc /sql | |
parent | b2d2dd5ca1c035a827f2d7793334acf5f8066b78 (diff) | |
download | mariadb-git-bba41a1cdd6617aa586886a29c02c874122f77df.tar.gz |
Extra safety fixes (probably not needed, but can't hurt)
sql/ha_innodb.cc:
simple optimization
sql/sql_show.cc:
Simple optimization
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_innodb.cc | 9 | ||||
-rw-r--r-- | sql/sql_parse.cc | 3 | ||||
-rw-r--r-- | sql/sql_show.cc | 3 |
3 files changed, 6 insertions, 9 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 4835f794a1d..4a50e2d8ccf 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -395,12 +395,9 @@ innobase_mysql_print_thd( but better be safe */ } - for (i = 0; i < len && s[i]; i++); - - memcpy(buf, s, i); /* Use memcpy to reduce the timeframe - for a race, compared to fwrite() */ - buf[300] = '\0'; /* not needed, just extra safety */ - + /* Use strmake to reduce the timeframe + for a race, compared to fwrite() */ + i= (uint) (strmake(buf, s, len) - buf); putc('\n', f); fwrite(buf, 1, i, f); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 77032bef698..7e68db0dcd2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1067,6 +1067,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, packet_length--; } /* We must allocate some extra memory for query cache */ + thd->query_length= 0; // Extra safety: Avoid races if (!(thd->query= (char*) thd->memdup_w_gap((gptr) (packet), packet_length, thd->db_length+2+ @@ -2982,8 +2983,8 @@ void mysql_parse(THD *thd, char *inBuf, uint length) { DBUG_ENTER("mysql_parse"); - mysql_init_query(thd); thd->query_length = length; + mysql_init_query(thd); if (query_cache_send_result_to_client(thd, inBuf, length) <= 0) { LEX *lex=lex_start(thd, (uchar*) inBuf, length); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 7f52e52c849..a4ef735c715 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1147,8 +1147,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) races with query_length */ uint length= min(max_query_length, tmp->query_length); - thd_info->query=(char*) thd->memdup(tmp->query,length+1); - thd_info->query[length]=0; + thd_info->query=(char*) thd->strmake(tmp->query,length); } thread_infos.append(thd_info); } |