summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-06-15 14:41:59 +0200
committerSergei Golubchik <serg@mariadb.org>2017-06-18 21:53:45 +0200
commitc7141fa75df91ae4c2a1214283111eeb1c2eda11 (patch)
tree34e8a64fb147baaedbdf4a26ec1723198082f916 /client
parentc661b4d0fb38c103fc0b659a95e8552ea72574cf (diff)
downloadmariadb-git-c7141fa75df91ae4c2a1214283111eeb1c2eda11.tar.gz
MDEV-13002 mysqltest regex replace results in incorrect result
regex didn't replace lines that were split by 16K chunk reads.
Diffstat (limited to 'client')
-rw-r--r--client/mysqltest.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index b22959677d0..4de40953f7d 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -1698,12 +1698,22 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename)
{
int fd;
size_t len;
- char buff[16384];
+ char *buff;
if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
return 1;
- while((len= 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)
@@ -1726,7 +1736,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;
}