MariaDB server is a community developed fork of MySQL server. Started by core members of the original MySQL team, MariaDB actively works with outside developers to deliver the most featureful, stable, and sanely licensed open SQL server in the industry.
Find a file
Chaithra Gopalareddy 4bd94e7d1c Bug #16119355: PREPARED STATEMENT: READ OF FREED MEMORY WITH
STRING CONVERSION FUNCTIONS
            
Problem:
While executing the prepared statement, user variable is
set to memory which would be freed at the end of
execution.
If the statement is executed again, valgrind throws
error when accessing this pointer.
                  
Analysis:
                
1. First time when Item_func_set_user_var::check is called,
   memory is allocated for "value" to store the result.
   (In the call to copy_if_not_alloced).
2. While sending the result, Item_func_set_user_var::check
   is called again. But, this time, its called with
   "use_result_field" set to true. 
   As a result, we call result_field->val_str(&value).
3. Here memory allocated for "value" gets freed. And "value"
   gets set to "result_field", with "str_length" being that of
   result_field's.
4. In the call to JOIN::cleanup, result_field's memory gets
   freed as this is allocated in a chunk as part of the
   temporary table which is needed to execute the query.
5. Next time, when execute of the same statement is called,
   "value" will be set to memory which is already freed.
   Valgrind error occurs as "str_length" is positive 
   (set at Step 3)
                  
Note that user variables list is stored as part of the Lex object
in set_var_list. Hence the persistance across executions.
            
Solution:
Patch for Bug#11764371 fixed in mysql-5.6+ fixes this problem 
as well.So backporting the same.
            
In the solution for Bug#11764371, we create another object of 
user_var and repoint it to temp_table's field. As a result while 
deleting the alloced buffer in Step 3, since the cloned object 
does not own the buffer, deletion will not happen.
So at step 5 when we execute the statement second time, the 
original object will be used and since deletion did not happen 
valgrind will not complain about dangling pointer.


sql/item_func.h:
  Add constructors.
sql/sql_select.cc:
  Change user variable assignment functions to read from fields after
  tables have been unlocked.
2013-05-23 15:00:31 +05:30
.bzr-mysql merge 2010-12-17 14:44:35 +02:00
BitKeeper Merge trift2.:/MySQL/M51/mysql-5.1 2008-01-28 15:16:40 +01:00
BUILD Correcting the permissions of executable files. 2013-03-20 17:49:30 +01:00
client Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
cmd-line-utils Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
config/ac-macros Bug#62856 Check for "stack overrun" doesn't work with gcc-4.6, server crashes 2013-03-26 08:22:45 +01:00
dbug Correcting the permissions of executable files. 2013-03-20 17:49:30 +01:00
Docs Bug 16633169 - MYSQL.INFO CONTAINS OUTDATED INFORMATION. 2013-04-16 12:12:18 +02:00
extra Bug#16807394: PREVENT NEW ERROR MESSAGES FROM BEING ADDED TO 5.5 2013-05-16 08:09:48 +02:00
include Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
libmysql Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
libmysql_r Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
libmysqld Correcting the permissions of executable files. 2013-03-20 17:49:30 +01:00
man Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mysql-test Bug #16813007 - MTR IS NOT TAKING MYSQLTEST CLIENT USING THE ENV VARIABLE MYSQL_TEST 2013-05-16 14:32:09 +05:30
mysys Bug#14324766:PARTIALLY WRITTEN INSERT STATEMENT IN BINLOG 2013-03-28 14:14:39 +05:30
netware Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
plugin Updated/added copyright headers. 2013-02-25 15:26:00 +01:00
regex Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
scripts Bug#12671635 HELP-TABLEFORMAT DOESN'T MATCH HELP-FILES 2013-03-21 23:36:02 +05:30
server-tools Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
sql Bug #16119355: PREPARED STATEMENT: READ OF FREED MEMORY WITH 2013-05-23 15:00:31 +05:30
sql-bench Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
sql-common Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
storage Bug #16806366 BOGUS CALL TO LOCK_REC_RESTORE_FROM_PAGE_INFIMUM IN 2013-05-16 14:05:05 +05:30
strings Bug#11766191:INVALID MEMORY READ IN DO_DIV_MOD WITH DOUBLY ASSIGNED VARIABLES 2013-05-22 14:36:43 +05:30
support-files Bug 16633169 - MYSQL.INFO CONTAINS OUTDATED INFORMATION. 2013-04-16 12:12:18 +02:00
tests Correcting the permissions of executable files. 2013-03-20 17:49:30 +01:00
unittest Bug#11766191:INVALID MEMORY READ IN DO_DIV_MOD WITH DOUBLY ASSIGNED VARIABLES 2013-05-22 14:36:43 +05:30
vio Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
win Correcting the permissions of executable files. 2013-03-20 17:49:30 +01:00
zlib Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
.bzrignore merge 2011-04-20 18:00:50 +02:00
.cvsignore
CMakeLists.txt Updated/added copyright headers. 2013-02-25 15:26:00 +01:00
configure.in Bug#11766191:INVALID MEMORY READ IN DO_DIV_MOD WITH DOUBLY ASSIGNED VARIABLES 2013-05-22 14:36:43 +05:30
COPYING Use a new version of "COPYING", the GPL text. 2010-03-04 14:26:27 +01:00
INSTALL-SOURCE Bug 16633169 - MYSQL.INFO CONTAINS OUTDATED INFORMATION. 2013-04-16 12:12:18 +02:00
INSTALL-WIN-SOURCE Bug 16633169 - MYSQL.INFO CONTAINS OUTDATED INFORMATION. 2013-04-16 12:12:18 +02:00
Makefile.am Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
README Bug 16401147 - CRLF INSTEAD OF LF IN README 2013-03-19 05:19:31 +01:00

MySQL Server 5.1

This is a release of MySQL, a dual-license SQL database server.
For the avoidance of doubt, this particular copy of the software 
is released under the version 2 of the GNU General Public License. 
MySQL is brought to you by Oracle.

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

License information can be found in the COPYING file.

MySQL FOSS License Exception
We want free and open source software applications under certain
licenses to be able to use specified GPL-licensed MySQL client
libraries despite the fact that not all such FOSS licenses are
compatible with version 2 of the GNU General Public License.  
Therefore there are special exceptions to the terms and conditions 
of the GPLv2 as applied to these client libraries, which are 
identified and described in more detail in the FOSS License 
Exception at 
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.

This distribution may include materials developed by third
parties. For license and attribution notices for these
materials, please refer to the documentation that accompanies
this distribution (see the "Licenses for Third-Party Components"
appendix) or view the online documentation at 
<http://dev.mysql.com/doc/>.

GPLv2 Disclaimer
For the avoidance of doubt, except that if any license choice
other than GPL or LGPL is available it will apply instead, 
Oracle elects to use only the General Public License version 2 
(GPLv2) at this time for any software where a choice of GPL 
license versions is made available with the language indicating 
that GPLv2 or any later version may be used, or where a choice 
of which version of the GPL is applied is otherwise unspecified.

For further information about MySQL or additional documentation, 
see:
- The latest information about MySQL: http://www.mysql.com
- The current MySQL documentation: http://dev.mysql.com/doc

Some Reference Manual sections of special interest:
- If you are migrating from an older version of MySQL, please 
  read the "Upgrading from..." section.
- To see what MySQL can do, take a look at the features section.
- For installation instructions, see the Installing and Upgrading
  chapter.
- For the new features/bugfix history, see the MySQL Change History 
  appendix.

You can browse the MySQL Reference Manual online or download it 
in any of several formats at the URL given earlier in this file.
Source distributions include a local copy of the manual in the
Docs directory.