diff options
author | unknown <jimw@rama.(none)> | 2006-08-17 14:09:24 -0700 |
---|---|---|
committer | unknown <jimw@rama.(none)> | 2006-08-17 14:09:24 -0700 |
commit | 8d8fa0e312bd5e0fcb807fd757414d7d9eb4db32 (patch) | |
tree | 1c7dc589490315dd11fafb9b7e6efc33446857e0 /client | |
parent | 842ec2334118f67541c77bb824a7baffe5ba2b62 (diff) | |
download | mariadb-git-8d8fa0e312bd5e0fcb807fd757414d7d9eb4db32.tar.gz |
Bug #21288: mysqldump segmentation fault when using --where
The problem was that the error handling was using a too-small buffer to
print the error message generated. We fix this by not using a buffer at
all, but by using fprintf() directly. There were also some problems with
the error handling in table dumping that was exposed by this fix that were
also corrected.
client/mysqldump.c:
Use fprintf() instead of my_printf_error() to avoid buffer overflow issues.
Since ME_BELL wasn't specified, calling my_printf_error() offered no advantage
except for adding my_progname, which we just go ahead and do manually. Also,
fix the error handling in dumpTable() when queries to get data fail and --force
was specified.
mysql-test/r/mysqldump.result:
Add new results
mysql-test/t/mysqldump.test:
Add new regression test
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqldump.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c index 58e51b9b955..7f495ccdafb 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -783,8 +783,8 @@ static int get_options(int *argc, char ***argv) static void DBerror(MYSQL *mysql, const char *when) { DBUG_ENTER("DBerror"); - my_printf_error(0,"Got error: %d: %s %s", MYF(0), - mysql_errno(mysql), mysql_error(mysql), when); + fprintf(stderr, "%s: Got error: %d: %s %s\n", my_progname, + mysql_errno(mysql), mysql_error(mysql), when); safe_exit(EX_MYSQLERR); DBUG_VOID_RETURN; } /* DBerror */ @@ -811,9 +811,9 @@ static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res, if (mysql_query(mysql_con, query) || (res && !((*res)= mysql_store_result(mysql_con)))) { - my_printf_error(0, "%s: Couldn't execute '%s': %s (%d)", - MYF(0), my_progname, query, - mysql_error(mysql_con), mysql_errno(mysql_con)); + fprintf(stderr, "%s: Couldn't execute '%s': %s (%d)\n", + my_progname, query, + mysql_error(mysql_con), mysql_errno(mysql_con)); return 1; } return 0; @@ -1705,13 +1705,19 @@ static void dumpTable(uint numFields, char *table) check_io(md_result_file); } if (mysql_query_with_error_report(sock, 0, query)) + { DBerror(sock, "when retrieving data from server"); + goto err; + } if (quick) res=mysql_use_result(sock); else res=mysql_store_result(sock); if (!res) + { DBerror(sock, "when retrieving data from server"); + goto err; + } if (verbose) fprintf(stderr, "-- Retrieving rows...\n"); if (mysql_num_fields(res) != numFields) |