summaryrefslogtreecommitdiff
path: root/sql/sql_priv.h
diff options
context:
space:
mode:
authorNuno Carvalho <nuno.carvalho@oracle.com>2012-10-12 08:36:09 +0100
committerNuno Carvalho <nuno.carvalho@oracle.com>2012-10-12 08:36:09 +0100
commitfa240877436739cd88e20b9e2e753ad1c1b693d1 (patch)
tree583deb38a800d7fb1ec33c797ca6b547bb963757 /sql/sql_priv.h
parent937a9381d3329febbfb4f9e58f7d8944994d1eda (diff)
parent0cdd810bee2001ff199b7d9a5eb627b60a8d9048 (diff)
downloadmariadb-git-fa240877436739cd88e20b9e2e753ad1c1b693d1.tar.gz
BUG#14629727: USER_VAR_EVENT IS MISSING RANGE CHECKS
Merge from mysql-5.1 into mysql-5.5.
Diffstat (limited to 'sql/sql_priv.h')
-rw-r--r--sql/sql_priv.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/sql/sql_priv.h b/sql/sql_priv.h
index caf82beb982..6bc34d611bc 100644
--- a/sql/sql_priv.h
+++ b/sql/sql_priv.h
@@ -151,6 +151,50 @@
*/
#define OPTION_ALLOW_BATCH (ULL(1) << 36) // THD, intern (slave)
+/*
+ Check how many bytes are available on buffer.
+
+ @param buf_start Pointer to buffer start.
+ @param buf_current Pointer to the current position on buffer.
+ @param buf_len Buffer length.
+
+ @return Number of bytes available on event buffer.
+*/
+template <class T> T available_buffer(const char* buf_start,
+ const char* buf_current,
+ T buf_len)
+{
+ return buf_len - (buf_current - buf_start);
+}
+/* Explicit instantion to unsigned int. */
+template unsigned int available_buffer<unsigned int>(const char*,
+ const char*,
+ unsigned int);
+
+/*
+ Check if jump value is within buffer limits.
+
+ @param jump Number of positions we want to advance.
+ @param buf_start Pointer to buffer start
+ @param buf_current Pointer to the current position on buffer.
+ @param buf_len Buffer length.
+
+ @return True If jump value is within buffer limits.
+ False Otherwise.
+*/
+template <class T> bool valid_buffer_range(T jump,
+ const char* buf_start,
+ const char* buf_current,
+ T buf_len)
+{
+ return (jump <= available_buffer(buf_start, buf_current, buf_len));
+}
+/* Explicit instantion to unsigned int. */
+template bool valid_buffer_range<unsigned int>(unsigned int,
+ const char*,
+ const char*,
+ unsigned int);
+
/* The rest of the file is included in the server only */
#ifndef MYSQL_CLIENT