summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2010-10-29 09:56:45 +0200
committerunknown <knielsen@knielsen-hq.org>2010-10-29 09:56:45 +0200
commitc6b19ea001965b350df1248c33f709127d2c7e47 (patch)
treeabd11a29a57d1d63a6995e66fac211ed2b903f76 /client
parent4cb9a326cfc286a3e57f5f3901b14ad9064d8557 (diff)
downloadmariadb-git-c6b19ea001965b350df1248c33f709127d2c7e47.tar.gz
mysqltest: Fix reversed error check, causing truncated output when testcase fails.
Also fix missing zero termination in DBUG_PRINT, causing garbage output in --debug output.
Diffstat (limited to 'client')
-rw-r--r--client/mysqltest.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 60b7501b0cd..fbd76445e37 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -609,14 +609,14 @@ public:
lines++;
int show_offset= 0;
- char buf[256];
+ char buf[256+1]; /* + zero termination for DBUG_PRINT */
size_t bytes;
bool found_bof= false;
/* Search backward in file until "lines" newline has been found */
while (lines && !found_bof)
{
- show_offset-= sizeof(buf);
+ show_offset-= sizeof(buf)-1;
while(fseek(m_file, show_offset, SEEK_END) != 0 && show_offset < 0)
{
found_bof= true;
@@ -624,7 +624,7 @@ public:
show_offset++;
}
- if ((bytes= fread(buf, 1, sizeof(buf), m_file)) <= 0)
+ if ((bytes= fread(buf, 1, sizeof(buf)-1, m_file)) <= 0)
{
// ferror=0 will happen here if no queries executed yet
if (ferror(m_file))
@@ -634,6 +634,7 @@ public:
DBUG_VOID_RETURN;
}
+ IF_DBUG(buf[bytes]= '\0';)
DBUG_PRINT("info", ("Read %lu bytes from file, buf: %s",
(unsigned long)bytes, buf));
@@ -678,8 +679,8 @@ public:
}
}
- while ((bytes= fread(buf, 1, sizeof(buf), m_file)) > 0)
- if (fwrite(buf, 1, bytes, stderr))
+ while ((bytes= fread(buf, 1, sizeof(buf)-1, m_file)) > 0)
+ if (bytes != fwrite(buf, 1, bytes, stderr))
die("Failed to write to '%s', errno: %d",
m_file_name, errno);