summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorAlexander Nozdrin <alik@sun.com>2010-06-01 16:38:01 +0400
committerAlexander Nozdrin <alik@sun.com>2010-06-01 16:38:01 +0400
commitbf158eed8388f6c1b4c776b9ff6ee16a335cffa8 (patch)
tree27a04705528c5c8baecb74ee4ea6c6c03fdc56e8 /mysys
parentab6a5b4724ba957756f51f1390ac7447073f5415 (diff)
parent5cf1d385706097faab68dbca1053a2842a2dbd34 (diff)
downloadmariadb-git-bf158eed8388f6c1b4c776b9ff6ee16a335cffa8.tar.gz
Auto-merge from mysql-trunk-bugfixing.
Due to a BZR bug, that merge was done by the following command: bzr merge -r 'revid:tor.didriksen@sun.com-20100527074248-6qtv0p1ugy6o1hjo..' <mysql-trunk-bugfixing path>
Diffstat (limited to 'mysys')
-rwxr-xr-xmysys/CMakeLists.txt2
-rw-r--r--mysys/Makefile.am2
-rw-r--r--mysys/mf_loadpath.c11
-rw-r--r--mysys/mf_pack.c3
-rw-r--r--mysys/my_file.c2
-rw-r--r--mysys/my_getwd.c11
-rw-r--r--mysys/my_init.c2
-rw-r--r--mysys/my_mess.c (renamed from mysys/my_messnc.c)6
-rw-r--r--mysys/my_pthread.c5
-rw-r--r--mysys/my_static.c9
10 files changed, 29 insertions, 24 deletions
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index 2fbaac7fe72..4c93f5ffd57 100755
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -27,7 +27,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
my_clock.c my_compress.c my_copy.c my_crc32.c my_create.c my_delete.c
my_div.c my_error.c my_file.c my_fopen.c my_fstream.c my_gethostbyname.c
my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c
- my_lib.c my_lock.c my_lockmem.c my_malloc.c my_messnc.c
+ my_lib.c my_lock.c my_lockmem.c my_malloc.c my_mess.c
my_mkdir.c my_mmap.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c
my_quick.c my_read.c my_realloc.c my_redel.c my_rename.c my_seek.c my_sleep.c
my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index ad7f244e0fb..d5bffd874b2 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -34,7 +34,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
my_vle.c my_atomic.c lf_hash.c \
lf_dynarray.c lf_alloc-pin.c \
my_fopen.c my_fstream.c my_getsystime.c \
- my_error.c errors.c my_div.c my_messnc.c \
+ my_error.c errors.c my_div.c my_mess.c \
mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \
my_symlink.c my_symlink2.c \
mf_pack.c mf_unixpath.c mf_arr_appstr.c \
diff --git a/mysys/mf_loadpath.c b/mysys/mf_loadpath.c
index fbf6f7f5d57..07851ab6e92 100644
--- a/mysys/mf_loadpath.c
+++ b/mysys/mf_loadpath.c
@@ -34,7 +34,7 @@ char * my_load_path(char * to, const char *path,
if ((path[0] == FN_HOMELIB && path[1] == FN_LIBCHAR) ||
test_if_hard_path(path))
- (void) strmov(buff,path);
+ (void) strnmov(buff, path, FN_REFLEN);
else if ((is_cur=(path[0] == FN_CURLIB && path[1] == FN_LIBCHAR)) ||
(is_prefix(path,FN_PARENTDIR)) ||
! own_path_prefix)
@@ -42,13 +42,14 @@ char * my_load_path(char * to, const char *path,
if (is_cur)
is_cur=2; /* Remove current dir */
if (! my_getwd(buff,(uint) (FN_REFLEN-strlen(path)+is_cur),MYF(0)))
- (void) strcat(buff,path+is_cur);
+ (void) strncat(buff, path+is_cur, FN_REFLEN);
else
- (void) strmov(buff,path); /* Return org file name */
+ (void) strnmov(buff, path, FN_REFLEN); /* Return org file name */
}
else
- (void) strxmov(buff,own_path_prefix,path,NullS);
- strmov(to,buff);
+ (void) strxnmov(buff, FN_REFLEN, own_path_prefix, path, NullS);
+ strnmov(to, buff, FN_REFLEN);
+ to[FN_REFLEN-1]= '\0';
DBUG_PRINT("exit",("to: %s",to));
DBUG_RETURN(to);
} /* my_load_path */
diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c
index c13a5581b80..4f7cd90e8aa 100644
--- a/mysys/mf_pack.c
+++ b/mysys/mf_pack.c
@@ -311,6 +311,9 @@ size_t normalize_dirname(char *to, const char *from)
#endif
buff[length - 1] != FN_LIBCHAR && buff[length - 1] != '/')
{
+ /* we need reserve 2 bytes for the trailing slash and the zero */
+ if (length >= sizeof (buff) - 1)
+ length= sizeof (buff) - 2;
buff[length]= FN_LIBCHAR;
buff[length + 1]= '\0';
}
diff --git a/mysys/my_file.c b/mysys/my_file.c
index ec0c9c425ea..a31673b31bc 100644
--- a/mysys/my_file.c
+++ b/mysys/my_file.c
@@ -72,7 +72,7 @@ static uint set_max_open_files(uint max_file_limit)
}
#else
-static int set_max_open_files(uint max_file_limit)
+static uint set_max_open_files(uint max_file_limit)
{
/* We don't know the limit. Return best guess */
return min(max_file_limit, OS_FILE_LIMIT);
diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c
index 6ef8d571492..4182ea9826f 100644
--- a/mysys/my_getwd.c
+++ b/mysys/my_getwd.c
@@ -50,16 +50,21 @@ int my_getwd(char * buf, size_t size, myf MyFlags)
DBUG_PRINT("my",("buf: 0x%lx size: %u MyFlags %d",
(long) buf, (uint) size, MyFlags));
+ if (size < 1)
+ DBUG_RETURN(-1);
+
if (curr_dir[0]) /* Current pos is saved here */
(void) strmake(buf,&curr_dir[0],size-1);
else
{
#if defined(HAVE_GETCWD)
+ if (size < 2)
+ DBUG_RETURN(-1);
if (!getcwd(buf,(uint) (size-2)) && MyFlags & MY_WME)
{
my_errno=errno;
my_error(EE_GETWD,MYF(ME_BELL+ME_WAITTANG),errno);
- return(-1);
+ DBUG_RETURN(-1);
}
#elif defined(HAVE_GETWD)
{
@@ -68,11 +73,13 @@ int my_getwd(char * buf, size_t size, myf MyFlags)
strmake(buf,pathname,size-1);
}
#elif defined(VMS)
+ if (size < 2)
+ DBUG_RETURN(-1);
if (!getcwd(buf,size-2,1) && MyFlags & MY_WME)
{
my_errno=errno;
my_error(EE_GETWD,MYF(ME_BELL+ME_WAITTANG),errno);
- return(-1);
+ DBUG_RETURN(-1);
}
intern_filename(buf,buf);
#else
diff --git a/mysys/my_init.c b/mysys/my_init.c
index 80f9a493bb0..f27f3f7b3e8 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -204,7 +204,7 @@ void my_end(int infoflag)
char ebuff[512];
my_snprintf(ebuff, sizeof(ebuff), EE(EE_OPEN_WARNING),
my_file_opened, my_stream_opened);
- my_message_no_curses(EE_OPEN_WARNING, ebuff, ME_BELL);
+ my_message_stderr(EE_OPEN_WARNING, ebuff, ME_BELL);
DBUG_PRINT("error", ("%s", ebuff));
my_print_open_files();
}
diff --git a/mysys/my_messnc.c b/mysys/my_mess.c
index e2dee3f6710..0ec97525ae8 100644
--- a/mysys/my_messnc.c
+++ b/mysys/my_mess.c
@@ -15,10 +15,10 @@
#include "mysys_priv.h"
-void my_message_no_curses(uint error __attribute__((unused)),
- const char *str, myf MyFlags)
+void my_message_stderr(uint error __attribute__((unused)),
+ const char *str, myf MyFlags)
{
- DBUG_ENTER("my_message_no_curses");
+ DBUG_ENTER("my_message_stderr");
DBUG_PRINT("enter",("message: %s",str));
(void) fflush(stdout);
if (MyFlags & ME_BELL)
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c
index b6b7e7db857..3019e4bc5c1 100644
--- a/mysys/my_pthread.c
+++ b/mysys/my_pthread.c
@@ -492,11 +492,6 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex)
/* Some help functions */
-int pthread_no_free(void *not_used __attribute__((unused)))
-{
- return 0;
-}
-
int pthread_dummy(int ret)
{
return ret;
diff --git a/mysys/my_static.c b/mysys/my_static.c
index a86fe6c7ab7..ff5abba29d3 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -87,10 +87,10 @@ ulong my_time_to_wait_for_lock=2; /* In seconds */
char * NEAR globerrs[GLOBERRS]; /* my_error_messages is here */
#endif
void (*my_abort_hook)(int) = (void(*)(int)) exit;
-void (*error_handler_hook)(uint error,const char *str,myf MyFlags)=
- my_message_no_curses;
-void (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)=
- my_message_no_curses;
+void (*error_handler_hook)(uint error, const char *str, myf MyFlags)=
+ my_message_stderr;
+void (*fatal_error_handler_hook)(uint error, const char *str, myf MyFlags)=
+ my_message_stderr;
static const char *proc_info_dummy(void *a __attribute__((unused)),
const char *b __attribute__((unused)),
@@ -123,7 +123,6 @@ my_bool NEAR my_disable_locking=0;
my_bool NEAR my_disable_async_io=0;
my_bool NEAR my_disable_flush_key_blocks=0;
my_bool NEAR my_disable_symlinks=0;
-my_bool NEAR mysys_uses_curses=0;
/*
Note that PSI_hook and PSI_server are unconditionally