summaryrefslogtreecommitdiff
path: root/storage/myisam/rt_split.c
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@sun.com>2010-03-25 15:18:14 +0400
committerSergey Vojtovich <svoj@sun.com>2010-03-25 15:18:14 +0400
commit85094f3cc1df379b253433b300073527dedaff9f (patch)
tree688e8b1b9cd13bddb199ed755c41bfb95e3a2b8c /storage/myisam/rt_split.c
parent0ed46845479e5d1f995ee6c16cdad7dd4cb43317 (diff)
downloadmariadb-git-85094f3cc1df379b253433b300073527dedaff9f.tar.gz
BUG#47598 - MyISAM may write uninitialized data to disk
When MyISAM writes newly created index page it may be initialized partially. In other words some bytes of sensible data and uninitialized tail of the page may go into index file. Under certain rare circumstances these hunks of memory may contain data that would be otherwise inaccessible to user, like passwords or data from other tables. Fixed by initializing memory for temporary MyISAM key buffer to '\0'. No test case for this fix as it is heavily covered by existing tests. storage/myisam/mi_open.c: When creating new MI_INFO object, initialize MI_INFO::buff. This is done to ensure that we never write uninitialized memory hunks to index file. storage/myisam/mi_page.c: No need to silence memory error detector anymore, page buffer is always initialized. storage/myisam/mi_write.c: Fixed invalid memory read of 2 bytes. new_right_length is length of data on a page, including first 2 bytes that store this length itself. pos + k_length is pure data excluding these 2 bytes containing length. storage/myisam/rt_index.c: To avoid uninitialized data write, create new page on info->buff, instead of locally allocated buffer. Note: second key block on info->buff is used here, because first block is used by called functions. storage/myisam/rt_split.c: To avoid uninitialized data write, create new page on info->buff, instead of locally allocated buffer.
Diffstat (limited to 'storage/myisam/rt_split.c')
-rw-r--r--storage/myisam/rt_split.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/storage/myisam/rt_split.c b/storage/myisam/rt_split.c
index ef988dbd048..88cf643faf9 100644
--- a/storage/myisam/rt_split.c
+++ b/storage/myisam/rt_split.c
@@ -258,7 +258,7 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key,
double *old_coord;
int n_dim;
uchar *source_cur, *cur1, *cur2;
- uchar *new_page;
+ uchar *new_page= info->buff;
int err_code= 0;
uint nod_flag= mi_test_if_nod(page);
uint full_length= key_length + (nod_flag ? nod_flag :
@@ -304,12 +304,7 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key,
goto split_err;
}
- if (!(new_page = (uchar*)my_alloca((uint)keyinfo->block_length)))
- {
- err_code= -1;
- goto split_err;
- }
-
+ info->buff_used= 1;
stop = task + (max_keys + 1);
cur1 = rt_PAGE_FIRST_KEY(page, nod_flag);
cur2 = rt_PAGE_FIRST_KEY(new_page, nod_flag);
@@ -345,8 +340,6 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key,
DFLT_INIT_HITS, new_page);
DBUG_PRINT("rtree", ("split new block: %lu", (ulong) *new_page_offs));
- my_afree((uchar*)new_page);
-
split_err:
my_afree((uchar*) coord_buf);
DBUG_RETURN(err_code);