Bug #44834 | strxnmov is expected to behave as you'd expect | ||
---|---|---|---|
Submitted: | 12 May 2009 21:20 | Modified: | 3 Aug 2009 23:45 |
Reporter: | Daniel Fischer | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Charsets | Severity: | S1 (Critical) |
Version: | any | OS: | Any |
Assigned to: | Sergei Glukhov | CPU Architecture: | Any |
[12 May 2009 21:20]
Daniel Fischer
[13 May 2009 0:05]
Davi Arnaut
In a nutshell: there will be a one byte overflow if the real size of the buffer is passed to strxnmov and this size is exceed by the length of the strings being concatenated. Suggested fix: === modified file 'strings/strxnmov.c' --- strings/strxnmov.c 2007-05-10 09:59:39 +0000 +++ strings/strxnmov.c 2009-05-13 00:05:05 +0000 @@ -42,7 +42,7 @@ char *strxnmov(char *dst, size_t len, const char *src, ...) { va_list pvar; - char *end_of_dst=dst+len; + char *end_of_dst=dst+len-1; va_start(pvar,src); while (src != NullS)
[13 May 2009 5:48]
Daniel Fischer
Davi, it's not as easy, because in many places the code relies on strxnmov acting the way it does and just changing it without changing other parts of the server will lead to behavioural differences as limits are reduced by one.
[15 Jun 2009 13:51]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/76282 2936 Sergey Glukhov 2009-06-15 Bug#44834 strxnmov is expected to behave as you'd expect The problem: described in the bug report. The fix: --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ client/mysql.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/ha_ndbcluster.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/ha_ndbcluster_binlog.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/handler.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/mysqld.cc removed unnecessary line @ sql/parse_file.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_acl.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_base.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_db.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_delete.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_partition.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_rename.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_show.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_table.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_view.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function
[17 Jun 2009 12:41]
Georgi Kodinov
I see few more instances of where we should change the code : sql/ha_ndbcluster.cc char* ha_ndbcluster::get_tablespace_name() 9502 strxnmov(name, name_len, ts.getName(), NullS); sql/log.cc bool LOGGER::slow_log_print() 945 char user_host_buff[MAX_USER_HOST_SIZE]; 969 /* fill in user_host value: the format is "%s[%s] @ %s [%s]" */ 970 user_host_len= (strxnmov(user_host_buff, MAX_USER_HOST_SIZE, 971 sctx->priv_user ? sctx->priv_user : "", "[", 972 sctx->user ? sctx->user : "", "] @ ", 973 sctx->host ? sctx->host : "", " [", 974 sctx->ip ? sctx->ip : "", "]", NullS) - 975 user_host_buff); bool LOGGER::general_log_write() 1011 char user_host_buff[MAX_USER_HOST_SIZE]; 1028 user_host_len= strxnmov(user_host_buff, MAX_USER_HOST_SIZE, 1029 sctx->priv_user ? sctx->priv_user : "", "[", 1030 sctx->user ? sctx->user : "", "] @ ", 1031 sctx->host ? sctx->host : "", " [", 1032 sctx->ip ? sctx->ip : "", "]", NullS)
[19 Jun 2009 8:33]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/76641 2936 Sergey Glukhov 2009-06-19 Bug#44834 strxnmov is expected to behave as you'd expect The problem: described in the bug report. The fix: --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used @ client/mysql.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/ha_ndbcluster.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/ha_ndbcluster_binlog.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/handler.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/log.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/mysqld.cc removed unnecessary line @ sql/parse_file.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_acl.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_base.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_db.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_delete.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_partition.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_rename.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_show.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_table.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_view.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function
[19 Jun 2009 9:27]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/76648 2961 Sergey Glukhov 2009-06-19 Bug#44834 strxnmov is expected to behave as you'd expect The problem: described in the bug report. The fix: --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used @ client/mysql.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/ha_ndbcluster.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/ha_ndbcluster_binlog.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/handler.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/log.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/mysqld.cc removed unnecessary line @ sql/parse_file.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_acl.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_base.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_db.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_delete.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_partition.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_rename.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_show.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_table.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function @ sql/sql_view.cc --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used as argument for strxnmov function
[8 Jul 2009 13:30]
Bugs System
Pushed into 5.1.37 (revid:joro@sun.com-20090708131116-kyz8iotbum8w9yic) (version source revid:sergey.glukhov@sun.com-20090619082443-1u6dm75s5gciyjso) (merge vers: 5.1.36) (pib:11)
[9 Jul 2009 7:36]
Bugs System
Pushed into 5.1.37 (revid:joro@sun.com-20090708131116-kyz8iotbum8w9yic) (version source revid:sergey.glukhov@sun.com-20090619082443-1u6dm75s5gciyjso) (merge vers: 5.1.36) (pib:11)
[10 Jul 2009 11:20]
Bugs System
Pushed into 5.4.4-alpha (revid:anozdrin@bk-internal.mysql.com-20090710111017-bnh2cau84ug1hvei) (version source revid:sergey.glukhov@sun.com-20090619092844-7xf8myliowe8i9iv) (merge vers: 5.4.4-alpha) (pib:11)
[3 Aug 2009 23:45]
Paul DuBois
Noted in 5.1.37, 5.4.4 changelogs. The strxnmov() library function could write a null byte after the end of the destination buffer.
[12 Aug 2009 21:48]
Paul DuBois
Noted in 5.4.2 changelog because next 5.4 version will be 5.4.2 and not 5.4.4.
[14 Aug 2009 22:46]
Paul DuBois
Ignore previous comment about 5.4.2.
[26 Aug 2009 13:45]
Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 2009 13:46]
Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers: 5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 2009 13:48]
Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers: 5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 2009 16:32]
Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[7 Oct 2009 1:25]
Paul DuBois
The 5.4 fix has been pushed into 5.4.2.