From 025ddfea288890236d4da04b46b3fff926707de3 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Apr 2004 16:51:34 +0300 Subject: InnoDB cleanup: fixing buffer overflows and quoting of quotes innobase/dict/dict0crea.c: Remove unneeded prototypes for static functions Remove unused parameters from some functions Replace some assertions with compile-time checks dict_create_add_foreigns_to_dictionary(): allocate space dynamically for the SQL, and quote quotes innobase/dict/dict0dict.c: Remove unnecessary prototypes for static functions dict_tables_have_same_db(): Remove length limitation dict_remove_db_name(): Use strchr() dict_get_db_name_len(): Use strchr() Replace mem_heap_alloc()+strlen()+memcpy() with mem_heap_strdup() Remove unnecessary strlen() calls Allocate space dynamically for generated strings dict_scan_id(): allow quotes within quoted strings innobase/dict/dict0load.c: Remove unnecessary strlen() calls Replace mem_heap_alloc()+strlen()+memcpy() with mem_heap_strdup() innobase/dict/dict0mem.c: Replace mem_heap_alloc()+strlen()+memcpy() with mem_heap_strdup() innobase/eval/eval0eval.c: Make TO_CHAR() work with any machine word width innobase/fil/fil0fil.c: Replace mem_alloc()+strlen()+strcpy() with mem_strdup() innobase/ibuf/ibuf0ibuf.c: Make some global variables static Add #ifdef UNIV_IBUF_DEBUG around debug statements innobase/include/data0data.h: Add #ifdef UNIV_DEBUG around dtuple_validate() innobase/include/data0data.ic: Replace = with == in ut_ad(tuple->magic_n == DATA_TUPLE_MAGIC_N) innobase/include/dict0dict.h: Add const qualifiers innobase/include/lock0lock.h: Add UL suffixes to unsigned long masks innobase/include/log0log.h: Remove unused parameter "type" of log_group_write_buf() innobase/include/mem0mem.h: Add mem_strdup(), mem_strdupl(), mem_strdupq(), mem_heap_strdup(), and mem_heap_strdupl() innobase/include/mem0mem.ic: Add mem_strdup(), mem_strdupl(), mem_strdupq(), mem_heap_strdup(), and mem_heap_strdupl() innobase/include/row0uins.h: Remove unused parameter "thr" of row_undo_ins() innobase/include/row0undo.h: Remvoe unused parameter "thr" of row_undo_search_clust_to_pcur() innobase/include/ut0byte.h: Add const qualifier to ut_cpy_in_lower_case() Remove parameter "len" of ut_cmp_in_lower_case() innobase/include/ut0mem.h: Add ut_strlenq(), ut_strcpyq() and ut_memcpyq() innobase/include/ut0mem.ic: Add ut_strlenq() innobase/include/ut0ut.h: Declare ut_sprintf() as a printf-style function innobase/lock/lock0lock.c: lock_clust_rec_modify_check_and_lock(): Remove unused variable "trx" innobase/log/log0log.c: Remove unused parameters innobase/log/log0recv.c: Remove parameter "type" from log_group_write_buf() innobase/mem/mem0mem.c: Simplify the initialization of block->init_block innobase/mtr/mtr0log.c: Add a debug assertion to mlog_parse_initial_log_record() innobase/page/page0cur.c: Add debug assertion to page_cur_insert_rec_write_log() Remove hard-coded buffer size in page_cur_parse_insert_rec() innobase/page/page0page.c: Remove unneeded variable rec innobase/pars/pars0opt.c: Correct a potential buffer overflow innobase/pars/pars0pars.c: Replace mem_heap_alloc()+strlen()+memcpy() with mem_heap_strdup() innobase/row/row0ins.c: Replace parameter "thr" with "trx" in row_ins_foreign_report_add_err() Remove unnecessary strlen() call Use strchr() innobase/row/row0mysql.c: Add row_mysql_is_recovered_tmp_table() Add row_mysql_is_system_table() Compare reserved table names with exact match Use strstr() and strchr() and mem_strdupl() Compute space needed for generated SQL, and allocate it dynamically innobase/row/row0purge.c: Remove unused parameters "thr" innobase/row/row0row.c: Simplify row_get_clust_rec() innobase/row/row0uins.c: Remove unused parameters "thr" innobase/row/row0umod.c: Remove unused variable "index" row_undo_mod_del_unmark_sec_and_undo_update(): Remove parameter "node" and variable "rec" Remove unused parameters "thr" innobase/row/row0undo.c: Remove unused parameters "thr" innobase/srv/srv0srv.c: Replace UT_NOT_USED() with __attribute__((unused)) innobase/srv/srv0start.c: Remove unnecessary strlen() calls Remove unused parameter "create_new_db" of open_or_create_log_file() innobase/trx/trx0roll.c: Replace mem_alloc()+strlen()+memcpy() with mem_strdup() innobase/trx/trx0sys.c: Remove unnecessary strlen() call innobase/ut/ut0byte.c: Add const qualifier to ut_cpy_in_lower_case() Remove parameter "len" of ut_cmp_in_lower_case() innobase/ut/ut0mem.c: Add ut_strlenq() and ut_memcpyq() sql/ha_innodb.cc: Remove parameter "len" of ut_cmp_in_lower_case() --- innobase/row/row0umod.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'innobase/row/row0umod.c') diff --git a/innobase/row/row0umod.c b/innobase/row/row0umod.c index 34c3aaf9142..5dde60029f0 100644 --- a/innobase/row/row0umod.c +++ b/innobase/row/row0umod.c @@ -95,14 +95,11 @@ row_undo_mod_clust_low( ulint mode) /* in: BTR_MODIFY_LEAF or BTR_MODIFY_TREE */ { big_rec_t* dummy_big_rec; - dict_index_t* index; btr_pcur_t* pcur; btr_cur_t* btr_cur; ulint err; ibool success; - index = dict_table_get_first_index(node->table); - pcur = &(node->pcur); btr_cur = btr_pcur_get_btr_cur(pcur); @@ -317,13 +314,6 @@ row_undo_mod_del_mark_or_remove_sec_low( if (!found) { /* Not found */ - /* FIXME: remove printfs in the final version */ - - /* printf( - "--UNDO MOD: Record not found from page %lu index %s\n", - buf_frame_get_page_no(btr_cur_get_rec(btr_cur)), - index->name); */ - btr_pcur_close(&pcur); mtr_commit(&mtr); @@ -421,7 +411,6 @@ row_undo_mod_del_unmark_sec_and_undo_update( DB_OUT_OF_FILE_SPACE */ ulint mode, /* in: search mode: BTR_MODIFY_LEAF or BTR_MODIFY_TREE */ - undo_node_t* node, /* in: row undo node */ que_thr_t* thr, /* in: query thread */ dict_index_t* index, /* in: index */ dtuple_t* entry) /* in: index entry */ @@ -430,15 +419,12 @@ row_undo_mod_del_unmark_sec_and_undo_update( btr_pcur_t pcur; btr_cur_t* btr_cur; upd_t* update; - rec_t* rec; ulint err = DB_SUCCESS; ibool found; big_rec_t* dummy_big_rec; mtr_t mtr; char err_buf[1000]; - UT_NOT_USED(node); - log_free_check(); mtr_start(&mtr); @@ -463,15 +449,13 @@ row_undo_mod_del_unmark_sec_and_undo_update( } else { btr_cur = btr_pcur_get_btr_cur(&pcur); - rec = btr_cur_get_rec(btr_cur); - err = btr_cur_del_mark_set_sec_rec(BTR_NO_LOCKING_FLAG, btr_cur, FALSE, thr, &mtr); ut_a(err == DB_SUCCESS); heap = mem_heap_create(100); update = row_upd_build_sec_rec_difference_binary(index, entry, - rec, heap); + btr_cur_get_rec(btr_cur), heap); if (upd_get_n_fields(update) == 0) { /* Do nothing */ @@ -566,11 +550,11 @@ row_undo_mod_del_mark_sec( err = row_undo_mod_del_unmark_sec_and_undo_update( BTR_MODIFY_LEAF, - node, thr, index, entry); + thr, index, entry); if (err == DB_FAIL) { err = row_undo_mod_del_unmark_sec_and_undo_update( BTR_MODIFY_TREE, - node, thr, index, entry); + thr, index, entry); } if (err != DB_SUCCESS) { @@ -649,12 +633,12 @@ row_undo_mod_upd_exist_sec( node->update, NULL); err = row_undo_mod_del_unmark_sec_and_undo_update( BTR_MODIFY_LEAF, - node, thr, index, entry); + thr, index, entry); if (err == DB_FAIL) { err = row_undo_mod_del_unmark_sec_and_undo_update( BTR_MODIFY_TREE, - node, thr, index, entry); + thr, index, entry); } if (err != DB_SUCCESS) { @@ -745,7 +729,7 @@ row_undo_mod( if (node->table == NULL) { found = FALSE; } else { - found = row_undo_search_clust_to_pcur(node, thr); + found = row_undo_search_clust_to_pcur(node); } if (!found) { -- cgit v1.2.1 From 80fe399fee3a7752aecdfc888edfcf56a2be7b0a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Apr 2004 16:14:43 +0300 Subject: InnoDB: send diagnostic output to stderr or files instead of stdout or fixed-size memory buffers innobase/btr/btr0btr.c: Output to stderr; quote table and index names innobase/btr/btr0cur.c: Output to stderr; quote table and index names innobase/btr/btr0sea.c: Output to stderr innobase/buf/buf0buf.c: Output to stderr; quote table and index names innobase/buf/buf0flu.c: Output to stderr innobase/buf/buf0lru.c: Output to stderr innobase/buf/buf0rea.c: Output to stderr innobase/data/data0data.c: Remove dtuple_validate() unless #ifdef UNIV_DEBUG Remove unnecessary sprintf() calls Output to stderr innobase/data/data0type.c: Output to stderr innobase/dict/dict0boot.c: Remove dummy call to printf() innobase/dict/dict0crea.c: Output diagnostic information to stream, not to memory innobase/dict/dict0dict.c: Output diagnostics to a file, not to a memory buffer innobase/dict/dict0load.c: Output to stderr; quote table and index names innobase/eval/eval0eval.c: Output to stderr innobase/fil/fil0fil.c: Output to stderr innobase/fsp/fsp0fsp.c: Output to stderr Avoid sprintf() innobase/fut/fut0lst.c: Output to stderr innobase/ha/ha0ha.c: Output to stream, not to memory buffer innobase/ibuf/ibuf0ibuf.c: Output to stderr Avoid sprintf() innobase/include/buf0buf.h: Output to stream, not to memory buffer innobase/include/buf0buf.ic: Use %p for displaying pointers innobase/include/data0data.h: Remove dtuple_sprintf() innobase/include/dict0dict.h: Output to stream, not to memory buffer innobase/include/ha0ha.h: Output to stream, not to memory buffer innobase/include/ibuf0ibuf.h: Output to stream, not to memory buffer innobase/include/lock0lock.h: Output to stream, not to memory buffer innobase/include/log0log.h: Output to stream, not to memory buffer innobase/include/mtr0log.ic: Output to stderr Display pointers with %p innobase/include/os0file.h: Output to stream, not to memory buffer innobase/include/rem0rec.h: Remove rec_sprintf() innobase/include/rem0rec.ic: Output to stderr innobase/include/row0sel.ic: Output to stderr innobase/include/row0upd.ic: Quote table and index names innobase/include/srv0srv.h: Remove srv_sprintf_innodb_monitor() innobase/include/sync0arr.h: Output to stream, not to memory buffer innobase/include/sync0sync.h: Output to stream, not to memory buffer innobase/include/trx0sys.h: Output to stderr innobase/include/trx0trx.h: Output to stream, not to memory buffer innobase/include/ut0ut.h: Remove ut_sprintf_buf() Add ut_print_name(), ut_print_namel() and ut_copy_file() innobase/lock/lock0lock.c: Output to stream, not to memory buffer innobase/log/log0log.c: Output to stderr innobase/log/log0recv.c: Output to stderr innobase/mem/mem0dbg.c: Output to stderr innobase/mtr/mtr0log.c: Display pointers with %p innobase/mtr/mtr0mtr.c: Output to stderr innobase/os/os0file.c: Output to stream, not to memory buffer innobase/os/os0proc.c: Output to stderr innobase/os/os0thread.c: Output to stderr innobase/page/page0cur.c: Output to stderr innobase/page/page0page.c: Avoid sprintf() Output to stderr instead of stdout innobase/pars/pars0opt.c: Output to stderr instead of stdout innobase/rem/rem0rec.c: Remove rec_sprintf() Output to stderr instead of stdout innobase/row/row0ins.c: Output diagnostics to stream instead of memory buffer innobase/row/row0mysql.c: Output to stderr instead of stdout Quote table and index names innobase/row/row0purge.c: Output to stderr instead of stdout innobase/row/row0row.c: Quote table and index names innobase/row/row0sel.c: Output to stderr instead of stdout Quote table and index names innobase/row/row0umod.c: Avoid sprintf() Quote table and index names innobase/row/row0undo.c: Output to stderr instead of stdout innobase/row/row0upd.c: Avoid sprintf() innobase/srv/srv0srv.c: Output to stderr instead of stdout innobase/srv/srv0start.c: Handle srv_monitor_file Make some global variables static innobase/sync/sync0arr.c: Output to stderr instead of stdout Output to stream instead of memory buffer innobase/sync/sync0rw.c: Output to stderr instead of stdout innobase/sync/sync0sync.c: Output to stderr instead of stdout Output to stream instead of memory buffer innobase/trx/trx0purge.c: Output to stderr instead of stdout innobase/trx/trx0rec.c: Quote index and table names Avoid sprintf() innobase/trx/trx0roll.c: Quote identifier names Output to stderr instead of stdout innobase/trx/trx0sys.c: Output to stderr instead of stdout innobase/trx/trx0trx.c: Output to stream instead of memory buffer innobase/trx/trx0undo.c: Output to stderr instead of stdout innobase/ut/ut0ut.c: Declare mysql_get_identifier_quote_char() Remove ut_sprintf_buf() Add ut_print_name() and ut_print_namel() Add ut_copy_file() sql/ha_innodb.cc: innobase_mysql_print_thd(): output to stream, not to memory buffer Add mysql_get_identifier_quote_char() Remove unused function innobase_print_error() Display pointers with %p Buffer InnoDB output via files, not via statically allocated memory --- innobase/row/row0umod.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'innobase/row/row0umod.c') diff --git a/innobase/row/row0umod.c b/innobase/row/row0umod.c index 5dde60029f0..5975bb164b9 100644 --- a/innobase/row/row0umod.c +++ b/innobase/row/row0umod.c @@ -417,13 +417,11 @@ row_undo_mod_del_unmark_sec_and_undo_update( { mem_heap_t* heap; btr_pcur_t pcur; - btr_cur_t* btr_cur; upd_t* update; ulint err = DB_SUCCESS; ibool found; big_rec_t* dummy_big_rec; mtr_t mtr; - char err_buf[1000]; log_free_check(); mtr_start(&mtr); @@ -431,23 +429,22 @@ row_undo_mod_del_unmark_sec_and_undo_update( found = row_search_index_entry(index, entry, mode, &pcur, &mtr); if (!found) { - fprintf(stderr, - "InnoDB: error in sec index entry del undo in\n" - "InnoDB: index %s table %s\n", index->name, - index->table->name); - dtuple_sprintf(err_buf, 900, entry); - fprintf(stderr, "InnoDB: tuple %s\n", err_buf); - - rec_sprintf(err_buf, 900, btr_pcur_get_rec(&pcur)); - fprintf(stderr, "InnoDB: record %s\n", err_buf); - - trx_print(err_buf, thr_get_trx(thr)); - fprintf(stderr, - "%s\nInnoDB: Make a detailed bug report and send it\n", - err_buf); - fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n"); + fputs("InnoDB: error in sec index entry del undo in\n" + "InnoDB: ", stderr); + dict_index_name_print(stderr, index); + fputs("\n" + "InnoDB: tuple ", stderr); + dtuple_print(stderr, entry); + fputs("\n" + "InnoDB: record ", stderr); + rec_print(stderr, btr_pcur_get_rec(&pcur)); + putc('\n', stderr); + trx_print(stderr, thr_get_trx(thr)); + fputs("\n" + "InnoDB: Make a detailed bug report and send it\n" + "InnoDB: to mysql@lists.mysql.com\n", stderr); } else { - btr_cur = btr_pcur_get_btr_cur(&pcur); + btr_cur_t* btr_cur = btr_pcur_get_btr_cur(&pcur); err = btr_cur_del_mark_set_sec_rec(BTR_NO_LOCKING_FLAG, btr_cur, FALSE, thr, &mtr); -- cgit v1.2.1