summaryrefslogtreecommitdiff
path: root/sql/my_decimal.h
diff options
context:
space:
mode:
authorTor Didriksen <tor.didriksen@oracle.com>2011-10-14 10:44:27 +0200
committerTor Didriksen <tor.didriksen@oracle.com>2011-10-14 10:44:27 +0200
commit5dc553cd28853b6bce70644a52d835b595fde12a (patch)
tree405e896fc90733d1183cf4cb7f2fcc22e53a7307 /sql/my_decimal.h
parenta2cbf8358bf698e5577cad32d870c46f7590cd92 (diff)
parenta6145f4b62bd264ad32d2dade98eda0cc6de0dba (diff)
downloadmariadb-git-5dc553cd28853b6bce70644a52d835b595fde12a.tar.gz
merge 5.0-security => 5.1 security
Diffstat (limited to 'sql/my_decimal.h')
-rw-r--r--sql/my_decimal.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/sql/my_decimal.h b/sql/my_decimal.h
index 21f485560da..a5f2aaada09 100644
--- a/sql/my_decimal.h
+++ b/sql/my_decimal.h
@@ -93,12 +93,31 @@ inline int my_decimal_int_part(uint precision, uint decimals)
class my_decimal :public decimal_t
{
+ /*
+ Several of the routines in strings/decimal.c have had buffer
+ overrun/underrun problems. These are *not* caught by valgrind.
+ To catch them, we allocate dummy fields around the buffer,
+ and test that their values do not change.
+ */
+#if !defined(DBUG_OFF)
+ int foo1;
+#endif
+
decimal_digit_t buffer[DECIMAL_BUFF_LENGTH];
+#if !defined(DBUG_OFF)
+ int foo2;
+ static const int test_value= 123;
+#endif
+
public:
void init()
{
+#if !defined(DBUG_OFF)
+ foo1= test_value;
+ foo2= test_value;
+#endif
len= DECIMAL_BUFF_LENGTH;
buf= buffer;
}
@@ -107,6 +126,17 @@ public:
{
init();
}
+ ~my_decimal()
+ {
+ sanity_check();
+ }
+
+ void sanity_check()
+ {
+ DBUG_ASSERT(foo1 == test_value);
+ DBUG_ASSERT(foo2 == test_value);
+ }
+
void fix_buffer_pointer() { buf= buffer; }
bool sign() const { return decimal_t::sign; }