diff options
author | unknown <heikki@hundin.mysql.fi> | 2002-08-11 18:49:47 +0300 |
---|---|---|
committer | unknown <heikki@hundin.mysql.fi> | 2002-08-11 18:49:47 +0300 |
commit | 12c89220373834983e236d0e49c4ab39c9ba5c9f (patch) | |
tree | d3f55dcc192a55ccc266a48e322be71aae0673af /innobase | |
parent | e6625f241009f3ae8fbdd0dd0e9332a1c85feaf5 (diff) | |
download | mariadb-git-12c89220373834983e236d0e49c4ab39c9ba5c9f.tar.gz |
ha_innobase.cc, ut0ut.c, univ.i, ut0ut.h:
Redefine sprintf as ut_sprintf inside InnoDB code; some old Unixes may have a pointer as the return type of sprintf
lock0lock.c:
Add safety against buffer overruns in latest deadlock info
srv0srv.c:
Add safety against buffer overruns in SHOW INNODB STATUS
os0thread.h, os0thread.c:
Fix a portability bug introduced in Windows when we changed os_thread_id_t to be the same as os_thread_t
innobase/os/os0thread.c:
Fix a portability bug introduced in Windows when we changed os_thread_id_t to be the same as os_thread_t
innobase/include/os0thread.h:
Fix a portability bug introduced in Windows when we changed os_thread_id_t to be the same as os_thread_t
innobase/srv/srv0srv.c:
Add safety against buffer overruns in SHOW INNODB STATUS
innobase/lock/lock0lock.c:
Add safety against buffer overruns in latest deadlock info
innobase/include/ut0ut.h:
Redefine sprintf as ut_sprintf inside InnoDB code; some old Unixes may have a pointer as the return type of sprintf
innobase/include/univ.i:
Redefine sprintf as ut_sprintf inside InnoDB code; some old Unixes may have a pointer as the return type of sprintf
innobase/ut/ut0ut.c:
Redefine sprintf as ut_sprintf inside InnoDB code; some old Unixes may have a pointer as the return type of sprintf
sql/ha_innobase.cc:
Redefine sprintf as ut_sprintf inside InnoDB code; some old Unixes may have a pointer as the return type of sprintf
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/include/os0thread.h | 4 | ||||
-rw-r--r-- | innobase/include/univ.i | 6 | ||||
-rw-r--r-- | innobase/include/ut0ut.h | 12 | ||||
-rw-r--r-- | innobase/lock/lock0lock.c | 2 | ||||
-rw-r--r-- | innobase/os/os0thread.c | 11 | ||||
-rw-r--r-- | innobase/srv/srv0srv.c | 13 | ||||
-rw-r--r-- | innobase/ut/ut0ut.c | 25 |
7 files changed, 69 insertions, 4 deletions
diff --git a/innobase/include/os0thread.h b/innobase/include/os0thread.h index 636cfd79e50..95a3a95fb74 100644 --- a/innobase/include/os0thread.h +++ b/innobase/include/os0thread.h @@ -70,7 +70,9 @@ os_thread_create( void* arg, /* in: argument to start function */ os_thread_id_t* thread_id); /* out: id of created - thread */ + thread; currently this is + identical to the handle to + the thread */ /********************************************************************* A thread calling this function ends its execution. */ diff --git a/innobase/include/univ.i b/innobase/include/univ.i index f5d083766bc..b511ec044a2 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -63,6 +63,12 @@ Microsoft Visual C++ */ #define HAVE_PWRITE #endif +/* Apparently in some old SCO Unixes the return type of sprintf is not +an integer as it should be according to the modern Posix standard. Because +of that we define sprintf inside InnoDB code as our own function ut_sprintf */ +#undef sprintf +#define sprintf ut_sprintf + #endif /* DEBUG VERSION CONTROL diff --git a/innobase/include/ut0ut.h b/innobase/include/ut0ut.h index 408788016c1..8ec23b23dcd 100644 --- a/innobase/include/ut0ut.h +++ b/innobase/include/ut0ut.h @@ -17,6 +17,18 @@ Created 1/20/1994 Heikki Tuuri typedef time_t ib_time_t; + +/************************************************************ +Uses vsprintf to emulate sprintf so that the function always returns +the printed length. Apparently in some old SCO Unixes sprintf did not +return the printed length but a pointer to the end of the printed string. */ + +ulint +ut_sprintf( +/*=======*/ + char* buf, /* in/out: buffer where to print */ + const char* format, /* in: format of prints */ + ...); /* in: arguments to be printed */ /************************************************************ Gets the high 32 bits in a ulint. That is makes a shift >> 32, but since there seem to be compiler bugs in both gcc and Visual C++, diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c index 9b3719867f0..da4092b926e 100644 --- a/innobase/lock/lock0lock.c +++ b/innobase/lock/lock0lock.c @@ -2754,6 +2754,8 @@ lock_deadlock_occurs( err_buf += sprintf(err_buf, "*** WE ROLL BACK TRANSACTION (2)\n"); + ut_a(strlen(lock_latest_err_buf) < 4100); + /* sess_raise_error_low(trx, DB_DEADLOCK, lock->type_mode, table, index, NULL, NULL, NULL); diff --git a/innobase/os/os0thread.c b/innobase/os/os0thread.c index 75f19f6d175..9eb80cdf826 100644 --- a/innobase/os/os0thread.c +++ b/innobase/os/os0thread.c @@ -96,17 +96,20 @@ os_thread_create( void* arg, /* in: argument to start function */ os_thread_id_t* thread_id) /* out: id of created - thread */ + thread; currently this is + identical to the handle to + the thread */ { #ifdef __WIN__ os_thread_t thread; + ulint win_thread_id; thread = CreateThread(NULL, /* no security attributes */ 0, /* default size stack */ (LPTHREAD_START_ROUTINE)start_f, arg, 0, /* thread runs immediately */ - thread_id); + &win_thread_id); if (srv_set_thread_priorities) { @@ -117,6 +120,8 @@ os_thread_create( ut_a(SetThreadPriority(thread, srv_query_thread_priority)); } + *thread_id = thread; + return(thread); #else int ret; @@ -134,6 +139,8 @@ os_thread_create( my_pthread_setprio(pthread, srv_query_thread_priority); } + *thread_id = pthread; + return(pthread); #endif } diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 2ce97c34e06..0472146013e 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -2222,6 +2222,7 @@ srv_sprintf_innodb_monitor( ut_sprintf_timestamp(buf); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); buf += sprintf(buf, " INNODB MONITOR OUTPUT\n" "=====================================\n"); @@ -2236,6 +2237,7 @@ srv_sprintf_innodb_monitor( sync_print(buf, buf_end); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); buf += sprintf(buf, "------------\n" "TRANSACTIONS\n" @@ -2248,15 +2250,18 @@ srv_sprintf_innodb_monitor( "--------\n"); os_aio_print(buf, buf_end); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); buf += sprintf(buf, "-------------------------------------\n" "INSERT BUFFER AND ADAPTIVE HASH INDEX\n" "-------------------------------------\n"); ibuf_print(buf, buf_end); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); ha_print_info(buf, buf_end, btr_search_sys->hash_index); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); buf += sprintf(buf, "%.2f hash searches/s, %.2f non-hash searches/s\n", @@ -2272,6 +2277,7 @@ srv_sprintf_innodb_monitor( "---\n"); log_print(buf, buf_end); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); buf += sprintf(buf, "----------------------\n" "BUFFER POOL AND MEMORY\n" @@ -2282,6 +2288,7 @@ srv_sprintf_innodb_monitor( mem_pool_get_reserved(mem_comm_pool)); buf_print_io(buf, buf_end); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); buf += sprintf(buf, "--------------\n" "ROW OPERATIONS\n" @@ -2315,6 +2322,8 @@ srv_sprintf_innodb_monitor( buf += sprintf(buf, "----------------------------\n" "END OF INNODB MONITOR OUTPUT\n" "============================\n"); + ut_a(buf < buf_end + 1900); + mutex_exit(&srv_innodb_monitor_mutex); } @@ -2372,7 +2381,9 @@ loop: buf = mem_alloc(100000); - srv_sprintf_innodb_monitor(buf, 100000); + srv_sprintf_innodb_monitor(buf, 90000); + + ut_a(strlen(buf) < 99000); printf("%s", buf); diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c index 6a5f273e731..2274e723be9 100644 --- a/innobase/ut/ut0ut.c +++ b/innobase/ut/ut0ut.c @@ -12,11 +12,36 @@ Created 5/11/1994 Heikki Tuuri #include "ut0ut.ic" #endif +#include <stdarg.h> + #include "ut0sort.h" ibool ut_always_false = FALSE; /************************************************************ +Uses vsprintf to emulate sprintf so that the function always returns +the printed length. Apparently in some old SCO Unixes sprintf did not +return the printed length but a pointer to the end of the printed string. */ + +ulint +ut_sprintf( +/*=======*/ + char* buf, /* in/out: buffer where to print */ + const char* format, /* in: format of prints */ + ...) /* in: arguments to be printed */ +{ + va_list args; + + va_start(args, format); + + vsprintf(buf, format, args); + + va_end(args); + + return((ulint)strlen(buf)); +} + +/************************************************************ Gets the high 32 bits in a ulint. That is makes a shift >> 32, but since there seem to be compiler bugs in both gcc and Visual C++, we do this by a special conversion. */ |