• unknown's avatar
    Bug#31850 Test crashes in "embedded" server · cba71f3e
    unknown authored
    The mysql_change_user command fails to properly update the database pointer
    when no database is selected, leading to "use after free" errors. The same
    happens on the user privilege pointer in the thread security context.
    
    The solution is to properly reset and update the database name. Also update
    the user_priv pointer so that it doesn't point to freed memory.
    
    
    sql/sql_connect.cc:
      After a successful call to check_user() without specifying a new
      database name, the previous database thd->db) is freed but the
      pointer is not updated to NULL.
    sql/sql_parse.cc:
      Update the security_ctx->priv_user pointer as it is a alias for
      the user security_ctx->user pointer. Also remove unneeded cast,
      the x_free macro casts the argument.
    cba71f3e
sql_parse.cc 215 KB