diff options
author | unknown <monty@mysql.com> | 2005-01-15 03:47:06 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2005-01-15 03:47:06 +0200 |
commit | deac81af88c0bc424126d3a9d3d4aaeca2a6770c (patch) | |
tree | c2e1f8b8bfc0be933a4b5fff758d2b2c6366f881 /mysys/mf_iocache.c | |
parent | d3ad1a919e8f770852ff661e0401be7fc043efaa (diff) | |
download | mariadb-git-deac81af88c0bc424126d3a9d3d4aaeca2a6770c.tar.gz |
Fixed possible access to unintialized memory in filesort when using many buffers
include/my_sys.h:
Added function to call if IO_CACHE is moved
mysys/mf_iocache.c:
Added function to call if IO_CACHE is moved
sql/filesort.cc:
Tell that io_cache is moved
Diffstat (limited to 'mysys/mf_iocache.c')
-rw-r--r-- | mysys/mf_iocache.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 8fb93dc4780..a7937da0cc2 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -71,9 +71,40 @@ static void my_aiowait(my_aio_result *result); #define IO_ROUND_UP(X) (((X)+IO_SIZE-1) & ~(IO_SIZE-1)) #define IO_ROUND_DN(X) ( (X) & ~(IO_SIZE-1)) + +/* + Setup internal pointers inside IO_CACHE + + SYNOPSIS + setup_io_cache() + info IO_CACHE handler + + NOTES + This is called on automaticly on init or reinit of IO_CACHE + It must be called externally if one moves or copies an IO_CACHE + object. +*/ + +void setup_io_cache(IO_CACHE* info) +{ + /* Ensure that my_b_tell() and my_b_bytes_in_cache works */ + if (info->type == WRITE_CACHE) + { + info->current_pos= &info->write_pos; + info->current_end= &info->write_end; + } + else + { + info->current_pos= &info->read_pos; + info->current_end= &info->read_end; + } +} + + static void -init_functions(IO_CACHE* info, enum cache_type type) +init_functions(IO_CACHE* info) { + enum cache_type type= info->type; switch (type) { case READ_NET: /* @@ -97,17 +128,7 @@ init_functions(IO_CACHE* info, enum cache_type type) info->write_function = _my_b_write; } - /* Ensure that my_b_tell() and my_b_bytes_in_cache works */ - if (type == WRITE_CACHE) - { - info->current_pos= &info->write_pos; - info->current_end= &info->write_end; - } - else - { - info->current_pos= &info->read_pos; - info->current_end= &info->read_end; - } + setup_io_cache(info); } /* @@ -211,7 +232,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, /* End_of_file may be changed by user later */ info->end_of_file= end_of_file; info->error=0; - init_functions(info,type); + init_functions(info); #ifdef HAVE_AIOWAIT if (use_async_io && ! my_disable_async_io) { @@ -333,7 +354,7 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, } info->type=type; info->error=0; - init_functions(info,type); + init_functions(info); #ifdef HAVE_AIOWAIT if (use_async_io && ! my_disable_async_io && |