Commit c38125c5 authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi

Cleaned up disk_pos_assert() to be more general.

parent a7710a4c
......@@ -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.
......@@ -270,28 +278,19 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
share->state.header.max_block_size));
strmov(share->filename,name_buff);
#define disk_pos_assert do \
{ \
if (disk_pos > end_pos) \
{ \
my_errno=HA_ERR_CRASHED; \
goto err; \
} \
} while(0)
share->blocksize=min(IO_SIZE,myisam_block_size);
{
MI_KEYSEG *pos=share->keyparts;
for (i=0 ; i < keys ; i++)
{
disk_pos=mi_keydef_read(disk_pos, &share->keyinfo[i]);
disk_pos_assert;
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++)
{
disk_pos=mi_keyseg_read(disk_pos, pos);
disk_pos_assert;
if (pos->type == HA_KEYTYPE_TEXT || pos->type == HA_KEYTYPE_VARTEXT)
{
if (!pos->language)
......@@ -318,12 +317,12 @@ 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_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++)
{
disk_pos=mi_keyseg_read(disk_pos, pos);
disk_pos_assert;
if (pos->type == HA_KEYTYPE_TEXT || pos->type == HA_KEYTYPE_VARTEXT)
{
if (!pos->language)
......@@ -345,10 +344,10 @@ 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]);
disk_pos_assert;
share->rec[i].pack_type=0;
share->rec[i].huff_tree=0;
share->rec[i].offset=offset;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment