summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-03-11 21:45:39 +0200
committerunknown <monty@mashka.mysql.fi>2003-03-11 21:45:39 +0200
commit6361cd89fce087510a8addd4ce0523771526d2c8 (patch)
treed17bc1d0b5fdc6a665d6c6e6eb79be134b419f2d /myisam
parentf26a8b6fb8b87c1ca28db36d5252ad7bf8b0f3d7 (diff)
parentd69a5630ff30564d497bf1dc48e5f50b7d226cfc (diff)
downloadmariadb-git-6361cd89fce087510a8addd4ce0523771526d2c8.tar.gz
merge with 3.23 to get:
- Better detection of crashed .MYI file - Ignore writeable config files mysql-test/mysql-test-run.sh: Auto merged mysys/default.c: Auto merged myisam/mi_open.c: merge with 3.23 sql/mysqld.cc: merge with 3.23
Diffstat (limited to 'myisam')
-rw-r--r--myisam/mi_open.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index 077d8c7da3a..60049325c5c 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -35,6 +35,14 @@ static void setup_key_functions(MI_KEYDEF *keyinfo);
pos+=size;}
+#define disk_pos_assert(pos, end_pos) \
+if (pos > end_pos) \
+{ \
+ my_errno=HA_ERR_CRASHED; \
+ goto err; \
+}
+
+
/******************************************************************************
** Return the shared struct if the table is already open.
** In MySQL the server will handle version issues.
@@ -70,7 +78,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
key_parts,unique_key_parts,tmp_length,uniques;
char name_buff[FN_REFLEN], org_name [FN_REFLEN], index_name[FN_REFLEN],
data_name[FN_REFLEN];
- char *disk_cache,*disk_pos;
+ char *disk_cache, *disk_pos, *end_pos;
MI_INFO info,*m_info,*old_info;
MYISAM_SHARE share_buff,*share;
ulong rec_per_key_part[MI_MAX_POSSIBLE_KEY*MI_MAX_KEY_SEG];
@@ -138,11 +146,12 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
info_length=mi_uint2korr(share->state.header.header_length);
base_pos=mi_uint2korr(share->state.header.base_pos);
- if (!(disk_cache=(char*) my_alloca(info_length)))
+ if (!(disk_cache=(char*) my_alloca(info_length+128)))
{
my_errno=ENOMEM;
goto err;
}
+ end_pos=disk_cache+info_length;
errpos=2;
VOID(my_seek(kfile,0L,MY_SEEK_SET,MYF(0)));
@@ -288,6 +297,8 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
for (i=0 ; i < keys ; i++)
{
disk_pos=mi_keydef_read(disk_pos, &share->keyinfo[i]);
+ disk_pos_assert(disk_pos + share->keyinfo[i].keysegs * MI_KEYSEG_SIZE,
+ end_pos);
set_if_smaller(share->blocksize,share->keyinfo[i].block_length);
share->keyinfo[i].seg=pos;
for (j=0 ; j < share->keyinfo[i].keysegs; j++,pos++)
@@ -319,6 +330,8 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
for (i=0 ; i < uniques ; i++)
{
disk_pos=mi_uniquedef_read(disk_pos, &share->uniqueinfo[i]);
+ disk_pos_assert(disk_pos + share->uniqueinfo[i].keysegs *
+ MI_KEYSEG_SIZE, end_pos);
share->uniqueinfo[i].seg=pos;
for (j=0 ; j < share->uniqueinfo[i].keysegs; j++,pos++)
{
@@ -344,6 +357,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
for (i=0 ; i < keys ; i++)
setup_key_functions(share->keyinfo+i);
+ disk_pos_assert(disk_pos + share->base.fields *MI_COLUMNDEF_SIZE, end_pos);
for (i=j=offset=0 ; i < share->base.fields ; i++)
{
disk_pos=mi_recinfo_read(disk_pos,&share->rec[i]);