Fix for message length in COM_QUERY

This commit is contained in:
Mark Riddoch
2014-09-24 11:15:33 +01:00
parent 7da4aa1400
commit 48b1a77a27

View File

@ -76,7 +76,7 @@ unsigned char *ptr;
ptr = GWBUF_DATA(buf); ptr = GWBUF_DATA(buf);
*length = *ptr++; *length = *ptr++;
*length += (*ptr++ << 8); *length += (*ptr++ << 8);
*length += (*ptr++ << 8); *length += (*ptr++ << 16);
ptr += 2; // Skip sequence id and COM_QUERY byte ptr += 2; // Skip sequence id and COM_QUERY byte
*length = *length - 1; *length = *length - 1;
*sql = (char *)ptr; *sql = (char *)ptr;
@ -111,7 +111,7 @@ unsigned char *ptr;
ptr = GWBUF_DATA(buf); ptr = GWBUF_DATA(buf);
*residual = *ptr++; *residual = *ptr++;
*residual += (*ptr++ << 8); *residual += (*ptr++ << 8);
*residual += (*ptr++ << 8); *residual += (*ptr++ << 16);
ptr += 2; // Skip sequence id and COM_QUERY byte ptr += 2; // Skip sequence id and COM_QUERY byte
*residual = *residual - 1; *residual = *residual - 1;
*length = GWBUF_LENGTH(buf) - 5; *length = GWBUF_LENGTH(buf) - 5;
@ -143,7 +143,7 @@ GWBUF *addition;
ptr = GWBUF_DATA(orig); ptr = GWBUF_DATA(orig);
length = *ptr++; length = *ptr++;
length += (*ptr++ << 8); length += (*ptr++ << 8);
length += (*ptr++ << 8); length += (*ptr++ << 16);
ptr += 2; // Skip sequence id and COM_QUERY byte ptr += 2; // Skip sequence id and COM_QUERY byte
newlength = strlen(sql); newlength = strlen(sql);
@ -178,11 +178,11 @@ GWBUF *addition;
* *
* @param buf GWBUF buffer including the query * @param buf GWBUF buffer including the query
* *
* @return Plaint text query if the packet type is COM_QUERY. Otherwise return * @return Plain text query if the packet type is COM_QUERY. Otherwise return
* a string including the packet type. * a string including the packet type.
*/ */
char* modutil_get_query( char *
GWBUF* buf) modutil_get_query(GWBUF *buf)
{ {
uint8_t* packet; uint8_t* packet;
mysql_server_cmd_t packet_type; mysql_server_cmd_t packet_type;