1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-02 09:41:40 +03:00

Extra safety fixes (probably not needed, but can't hurt)

sql/ha_innodb.cc:
  simple optimization
sql/sql_show.cc:
  Simple optimization
This commit is contained in:
unknown
2004-05-15 09:08:03 +03:00
parent 5c7ed1462e
commit fa163d0ba5
3 changed files with 6 additions and 9 deletions

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);
}