summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2016-10-25 22:35:35 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2016-10-25 22:35:35 +0000
commit82ab92bd66eaaf951d49082a5c142759da59b137 (patch)
tree835d710fd7bcf2bd1ff0949a23a3744c94358301 /include
parented3998ae7cc286860670bc9a285aeb99c5edcced (diff)
downloadmariadb-git-82ab92bd66eaaf951d49082a5c142759da59b137.tar.gz
MDEV-10951 Field_newdate::cmp access violation
The crash is caused by macro uint3korr() accessing memory (1 byte) past the end of allocated page. The macro is written such it reads 4 bytes instead of 3 and discards the value of the last byte. However, it is not always guaranteed that all uint3korr accesses will be valid (i.e that the caller allocates an extra byte after the value). In particular, the tree in Item_func_group_concat does not account for any extra bytes that it would need for comparison of keys in some cases (Field_newdate::cmp, Field_medium::cmp) The fix change uint3korr so it does not access extra bytes.
Diffstat (limited to 'include')
-rw-r--r--include/byte_order_generic_x86.h10
-rw-r--r--include/byte_order_generic_x86_64.h8
2 files changed, 0 insertions, 18 deletions
diff --git a/include/byte_order_generic_x86.h b/include/byte_order_generic_x86.h
index 0a71a17829b..a97dd0f43a3 100644
--- a/include/byte_order_generic_x86.h
+++ b/include/byte_order_generic_x86.h
@@ -27,19 +27,9 @@
((uint32) (uchar) (A)[0])))
#define sint4korr(A) (*((const long *) (A)))
#define uint2korr(A) (*((const uint16 *) (A)))
-
-/*
- Attention: Please, note, uint3korr reads 4 bytes (not 3)!
- It means, that you have to provide enough allocated space.
-*/
-#if defined(HAVE_valgrind) && !defined(_WIN32)
#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16))
-#else
-#define uint3korr(A) (long) (*((const unsigned int *) (A)) & 0xFFFFFF)
-#endif
-
#define uint4korr(A) (*((const uint32 *) (A)))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
diff --git a/include/byte_order_generic_x86_64.h b/include/byte_order_generic_x86_64.h
index b6b0c5d8ea5..8c7493965a9 100644
--- a/include/byte_order_generic_x86_64.h
+++ b/include/byte_order_generic_x86_64.h
@@ -27,17 +27,9 @@
((uint32) (uchar) (A)[0])))
#define sint4korr(A) (int32) (*((int32 *) (A)))
#define uint2korr(A) (uint16) (*((uint16 *) (A)))
-/*
- Attention: Please, note, uint3korr reads 4 bytes (not 3)!
- It means, that you have to provide enough allocated space.
-*/
-#if defined(HAVE_valgrind) && !defined(_WIN32)
#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16))
-#else
-#define uint3korr(A) (uint32) (*((unsigned int *) (A)) & 0xFFFFFF)
-#endif
#define uint4korr(A) (uint32) (*((uint32 *) (A)))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\