Commit fa163d0b authored by unknown's avatar unknown
Browse files

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


sql/ha_innodb.cc:
  simple optimization
sql/sql_show.cc:
  Simple optimization
parent 5c7ed146
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -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
                /* Use strmake to reduce the timeframe
                   for a race, compared to fwrite() */
		buf[300] = '\0';	/* not needed, just extra safety */

		i= (uint) (strmake(buf, s, len) - buf);
		putc('\n', f);
		fwrite(buf, 1, i, f);
	}
+2 −1
Original line number Diff line number Diff line
@@ -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);
+1 −2
Original line number Diff line number Diff line
@@ -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);
      }