Fix OK packet generation

The packet was generated with the wrong number of elements due to usage of
sizeof on an integer where the correct type was an uint8_t.

This only fixes the malformed packets but does not fix the root cause of
the problem. The affected rows and last insert ID are length encoded
integers which should be handled. The current code treats them as one byte
fields.
This commit is contained in:
Markus Makela 2016-11-22 21:31:57 +02:00
parent 83ffdcf4ed
commit 502eba8b4f
2 changed files with 3 additions and 3 deletions

View File

@ -394,7 +394,7 @@ bool gw_read_backend_handshake(DCB *dcb, GWBUF *buffer);
mxs_auth_state_t gw_send_backend_auth(DCB *dcb);
/** Write an OK packet to a DCB */
int mxs_mysql_send_ok(DCB *dcb, int sequence, int affected_rows, const char* message);
int mxs_mysql_send_ok(DCB *dcb, int sequence, uint8_t affected_rows, const char* message);
/** Check for OK packet */
bool mxs_mysql_is_ok_packet(GWBUF *buffer);

View File

@ -1086,11 +1086,11 @@ bool gw_get_shared_session_auth_info(DCB* dcb, MYSQL_session* session)
* @param dcb DCB where packet is written
* @param sequence Packet sequence number
* @param affected_rows Number of affected rows
* * @param message SQL message
* @param message SQL message
* @return 1 on success, 0 on error
*
*/
int mxs_mysql_send_ok(DCB *dcb, int sequence, int affected_rows, const char* message)
int mxs_mysql_send_ok(DCB *dcb, int sequence, uint8_t affected_rows, const char* message)
{
uint8_t *outbuf = NULL;
uint32_t mysql_payload_size = 0;