summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2009-12-17 15:58:38 -0200
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2009-12-17 15:58:38 -0200
commit06a1df91813ea2c39f7312bcf8af972c7e8a926f (patch)
treedac324abc82ad6d66e71348f8270ff42658c84a9 /mysys
parent522c084631ad581ec8f17b187a689f9b992ca06e (diff)
downloadmariadb-git-06a1df91813ea2c39f7312bcf8af972c7e8a926f.tar.gz
Bug#48983: Bad strmake calls (length one too long)
The problem is a somewhat common misusage of the strmake function. The strmake(dst, src, len) function writes at most /len/ bytes to the string pointed to by src, not including the trailing null byte. Hence, if /len/ is the exact length of the destination buffer, a one byte buffer overflow can occur if the length of the source string is equal to or greater than /len/. client/mysqldump.c: Make room for the trailing null byte. libmysql/libmysql.c: Add comment, there is enough room in the buffer. Increase buffer length, two strings are concatenated. libmysqld/lib_sql.cc: Make room for the trailing null byte. mysys/default.c: Make room for the trailing null bytes. mysys/mf_pack.c: Make room for the trailing null byte. server-tools/instance-manager/commands.cc: Copy only if overflow isn't possible in both cases. server-tools/instance-manager/listener.cc: Make room for the trailing null byte. sql/log.cc: Make room for the trailing null byte. sql/sp_pcontext.h: Cosmetic fix. sql/sql_acl.cc: MAX_HOSTNAME already specifies space for the trailing null byte. sql/sql_parse.cc: Make room for the trailing null byte. sql/sql_table.cc: Make room for the trailing null byte.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/default.c2
-rw-r--r--mysys/mf_pack.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/mysys/default.c b/mysys/default.c
index 362aa0d4605..0d162dc13d5 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -605,7 +605,7 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
int recursion_level)
{
char name[FN_REFLEN + 10], buff[4096], curr_gr[4096], *ptr, *end, **tmp_ext;
- char *value, option[4096], tmp[FN_REFLEN];
+ char *value, option[4096+2], tmp[FN_REFLEN];
static const char includedir_keyword[]= "includedir";
static const char include_keyword[]= "include";
const int max_recursion_level= 10;
diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c
index d2bac95b391..3053699f457 100644
--- a/mysys/mf_pack.c
+++ b/mysys/mf_pack.c
@@ -234,7 +234,7 @@ my_bool my_use_symdir=0; /* Set this if you want to use symdirs */
#ifdef USE_SYMDIR
void symdirget(char *dir)
{
- char buff[FN_REFLEN];
+ char buff[FN_REFLEN+1];
char *pos=strend(dir);
if (dir[0] && pos[-1] != FN_DEVCHAR && my_access(dir, F_OK))
{
@@ -246,7 +246,7 @@ void symdirget(char *dir)
*pos++=temp; *pos=0; /* Restore old filename */
if (file >= 0)
{
- if ((length= my_read(file, buff, sizeof(buff), MYF(0))) > 0)
+ if ((length= my_read(file, buff, sizeof(buff) - 1, MYF(0))) > 0)
{
for (pos= buff + length ;
pos > buff && (iscntrl(pos[-1]) || isspace(pos[-1])) ;