Added checks for possible NULL value and out-of-bounds reads.

This commit is contained in:
Markus Makela
2015-08-16 22:30:04 +03:00
parent 86ad570af8
commit 458598141b

View File

@ -1633,11 +1633,17 @@ static GWBUF* process_response_data (
{ {
uint8_t* data; uint8_t* data;
/** Read next packet length */ /** Read next packet length if there is at least
data = GWBUF_DATA(readbuf); * three bytes left. If there is less than three
nbytes_left = MYSQL_GET_PACKET_LEN(data)+MYSQL_HEADER_LEN; * bytes in the buffer or it is NULL, we need to
/** Store new status to protocol structure */ wait for more data from the backend server.*/
protocol_set_response_status(p, npackets_left, nbytes_left); if(readbuf == NULL || GWBUF_LENGTH(readbuf) < 3)
break;
data = GWBUF_DATA(readbuf);
nbytes_left = MYSQL_GET_PACKET_LEN(data)+MYSQL_HEADER_LEN;
/** Store new status to protocol structure */
protocol_set_response_status(p, npackets_left, nbytes_left);
} }
} }
} }