summaryrefslogtreecommitdiff
path: root/storage/perfschema/pfs_global.h
diff options
context:
space:
mode:
authorMarc Alff <marc.alff@oracle.com>2010-11-11 12:34:46 +0100
committerMarc Alff <marc.alff@oracle.com>2010-11-11 12:34:46 +0100
commit6272025ad408a81f31d3adbb28c8a12bd00d2890 (patch)
tree369f52d581151ab49de086a255474fbf12b209c0 /storage/perfschema/pfs_global.h
parent2ac02cf36d7db97d4c789e19b73c461bf8591ee9 (diff)
downloadmariadb-git-6272025ad408a81f31d3adbb28c8a12bd00d2890.tar.gz
Bug#58003 Segfault on CHECKSUM TABLE performance_schema.EVENTS_WAITS_HISTORY_LONG EXTENDED
This fix is a follow up on the fix for similar issue 56761. When sanitizing data read from the events_waits_history_long table, the code needs also to sanitize the schema_name / object_name / file_name pointers, because such pointers could also hold invalid values. Checking the string length alone was required but not sufficient. This fix verifies that: - the table schema and table name used in table io events - the file name used in file io events are valid pointers before dereferencing these pointers.
Diffstat (limited to 'storage/perfschema/pfs_global.h')
-rw-r--r--storage/perfschema/pfs_global.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/storage/perfschema/pfs_global.h b/storage/perfschema/pfs_global.h
index 6050612e24c..c0c0490a380 100644
--- a/storage/perfschema/pfs_global.h
+++ b/storage/perfschema/pfs_global.h
@@ -79,5 +79,21 @@ inline uint randomized_index(const void *ptr, uint max_size)
void pfs_print_error(const char *format, ...);
+/**
+ Given an array defined as T ARRAY[MAX],
+ check that an UNSAFE pointer actually points to an element
+ within the array.
+*/
+#define SANITIZE_ARRAY_BODY(T, ARRAY, MAX, UNSAFE) \
+ intptr offset; \
+ if ((&ARRAY[0] <= UNSAFE) && \
+ (UNSAFE < &ARRAY[MAX])) \
+ { \
+ offset= ((intptr) UNSAFE - (intptr) ARRAY) % sizeof(T); \
+ if (offset == 0) \
+ return UNSAFE; \
+ } \
+ return NULL
+
#endif