Check the buffer size before using the data.

For the Galileo Trimix, the header length isn't fixed. The actual length
depends on whether the dive has the trimix setting enabled or not.
Because at this point we're still trying to determine the length of the
header, it hasn't been checked yet and an extra check is necessary.
This commit is contained in:
Jef Driesen 2013-10-19 21:48:00 +02:00
parent 8da80ea0a2
commit 3536086015

View File

@ -363,6 +363,9 @@ uwatec_smart_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
unsigned int trimix = 0;
if (parser->model == GALILEOTRIMIX) {
if (size < 44)
return DC_STATUS_DATAFORMAT;
if (data[43] & 0x80) {
header = 0xB1;
trimix = 1;
@ -473,6 +476,9 @@ uwatec_smart_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
unsigned int trimix = 0;
if (parser->model == GALILEOTRIMIX) {
if (size < 44)
return DC_STATUS_DATAFORMAT;
if (data[43] & 0x80) {
header = 0xB1;
trimix = 1;