summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2017-06-21 16:19:43 +0300
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2017-06-21 16:19:43 +0300
commit2e335a471ced0d86716f8c657f4d67f510712a30 (patch)
tree6fa56f9d9083007e874449b9c2b27579f718ed94 /client
parent472c2d9b2fbb262665bdd08338ea902e8398010d (diff)
parent8baf9b0c469e2845d15cc1181bc6b101cdfba087 (diff)
downloadmariadb-git-2e335a471ced0d86716f8c657f4d67f510712a30.tar.gz
Merge remote-tracking branch '10.0' into 10.1
Diffstat (limited to 'client')
-rw-r--r--client/mysqltest.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 6ed45beec00..d8eb43aeeb2 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -1721,12 +1721,23 @@ void log_msg(const char *fmt, ...)
int cat_file(DYNAMIC_STRING* ds, const char* filename)
{
int fd;
- int len;
- char buff[16384];
+ size_t len;
+ char *buff;
if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
return 1;
- while((len= (int)my_read(fd, (uchar*)&buff, sizeof(buff)-1, MYF(0))) > 0)
+
+ len= (size_t) my_seek(fd, 0, SEEK_END, MYF(0));
+ my_seek(fd, 0, SEEK_SET, MYF(0));
+ if (len == (size_t)MY_FILEPOS_ERROR ||
+ !(buff= (char*)my_malloc(len + 1, MYF(0))))
+ {
+ my_close(fd, MYF(0));
+ return 1;
+ }
+ len= my_read(fd, (uchar*)buff, len, MYF(0));
+ my_close(fd, MYF(0));
+
{
char *p= buff, *start= buff,*end=buff+len;
while (p < end)
@@ -1749,7 +1760,7 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename)
*p= 0;
replace_dynstr_append_mem(ds, start, p-start);
}
- my_close(fd, MYF(0));
+ my_free(buff);
return 0;
}