summaryrefslogtreecommitdiff
path: root/sql/mdl.h
diff options
context:
space:
mode:
authorDmitry Lenev <Dmitry.Lenev@oracle.com>2012-12-11 22:04:30 +0400
committerDmitry Lenev <Dmitry.Lenev@oracle.com>2012-12-11 22:04:30 +0400
commit4235e46ea2973d82994f28d47cad95a12d77685d (patch)
treea1e388eba6be5e74da9c6a45774476e52bcf879e /sql/mdl.h
parent897f497f74961e64a729b97c2d4475cebf4612b0 (diff)
parent2e10e7c38eb6ccef3319f3fc5267224c171628da (diff)
downloadmariadb-git-4235e46ea2973d82994f28d47cad95a12d77685d.tar.gz
Bug #15954872 "MAKE MDL SUBSYSTEM AND TABLE DEFINITION CACHE
ROBUST AGAINST BUGS IN CALLERS". Both MDL subsystems and Table Definition Cache code assume that callers ensure that names of objects passed to them are not longer than NAME_LEN bytes. Unfortunately due to bugs in callers this assumption might be broken in some cases. As result we get nasty bugs causing buffer overruns when we construct MDL key or TDC key from object names. This patch makes MDL and TDC code more robust against such bugs by ensuring that we always checking size of result buffer when constructing MDL and TDC keys. This doesn't free its callers from ensuring that both db and table names are shorter than NAME_LEN bytes. But at least these steps prevents buffer overruns in case of bug in caller, replacing them with less harmful behavior. This is 5.5-only version of patch. Changed code of MDL_key::mdl_key_init() to take into account size of buffer for the key. Introduced new version of create_table_def_key() helper function which constructs TDC key without risk of result buffer overrun. Places in code that construct TDC keys were changed to use this function. Also changed rm_temporary_table() and open_new_frm() functions to avoid use of "unsafe" strmov() and strxmov() functions and use safer strnxmov() instead.
Diffstat (limited to 'sql/mdl.h')
-rw-r--r--sql/mdl.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/sql/mdl.h b/sql/mdl.h
index d30d30ac2fa..3179205f999 100644
--- a/sql/mdl.h
+++ b/sql/mdl.h
@@ -241,8 +241,14 @@ public:
const char *db, const char *name)
{
m_ptr[0]= (char) mdl_namespace;
- m_db_name_length= (uint16) (strmov(m_ptr + 1, db) - m_ptr - 1);
- m_length= (uint16) (strmov(m_ptr + m_db_name_length + 2, name) - m_ptr + 1);
+ /*
+ It is responsibility of caller to ensure that db and object names
+ are not longer than NAME_LEN. Still we play safe and try to avoid
+ buffer overruns.
+ */
+ m_db_name_length= (uint16) (strmake(m_ptr + 1, db, NAME_LEN) - m_ptr - 1);
+ m_length= (uint16) (strmake(m_ptr + m_db_name_length + 2, name, NAME_LEN) -
+ m_ptr + 1);
}
void mdl_key_init(const MDL_key *rhs)
{