Commit a316a30d authored by eric@mysql.com's avatar eric@mysql.com

BUG#12659 error handling in federated needs improvement. Sanja pointed out...

BUG#12659 error handling in federated needs improvement. Sanja pointed out that we were copying an entire buffer, most of which was probably garbage, and possibly hidden by null termination in the middle of the buffer. Now we are only copying the error message.
parent a60a6b0f
......@@ -2615,8 +2615,11 @@ int ha_federated::stash_remote_error()
{
DBUG_ENTER("ha_federated::stash_remote_error()");
remote_error_number= mysql_errno(mysql);
my_snprintf(remote_error_buf, FEDERATED_QUERY_BUFFER_SIZE,
mysql_error(mysql));
const char *remote_error= mysql_error(mysql);
remote_error_len= strlen(remote_error);
if(remote_error_len > (sizeof(remote_error_buf) - 1))
remote_error_len= (sizeof(remote_error_buf) - 1);
my_snprintf(remote_error_buf, remote_error_len + 1, remote_error);
DBUG_RETURN(HA_FEDERATED_ERROR_WITH_REMOTE_SYSTEM);
}
......@@ -2630,10 +2633,11 @@ bool ha_federated::get_error_message(int error, String* buf)
buf->append("Error on remote system: ");
buf->qs_append(remote_error_number);
buf->append(": ");
buf->append(remote_error_buf, FEDERATED_QUERY_BUFFER_SIZE);
buf->append(remote_error_buf, remote_error_len);
remote_error_number= 0;
remote_error_buf[0]= '\0';
remote_error_len= 0;
}
DBUG_PRINT("exit", ("message: %s", buf->ptr()));
DBUG_RETURN(FALSE);
......
......@@ -159,6 +159,7 @@ class ha_federated: public handler
MYSQL_ROW_OFFSET current_position; // Current position used by ::position()
int remote_error_number;
char remote_error_buf[FEDERATED_QUERY_BUFFER_SIZE];
uint remote_error_len;
private:
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment