Fix possible out of bounds read in CDCPlainAuth

When the authentication string was decoded from hexadecimal to binary, it
was possible that an out of bounds read was done if the length of the data
was not an even number.
This commit is contained in:
Markus Makela
2016-09-29 14:57:44 +03:00
parent 3d5cfee348
commit dcf55d4099

View File

@ -285,6 +285,12 @@ cdc_auth_set_client_data(CDC_session *client_data,
uint8_t *client_auth_packet,
int client_auth_packet_size)
{
if (client_auth_packet_size % 2 != 0)
{
/** gw_hex2bin expects an even number of bytes */
client_auth_packet_size--;
}
int rval = CDC_STATE_AUTH_ERR;
int decoded_size = client_auth_packet_size / 2;
char decoded_buffer[decoded_size + 1]; // Extra for terminating null