Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG

Merge Jef's upstream updates.

Trivial conflicts just because of whitespace differences and a comment
difference in our Suunto D5 support changes.

* git://github.com/libdivecomputer/libdivecomputer:
  Add support for the Suunto D5
  Add support for the Tusa Talis
  Add the G2 HUD bluetooth device name
  Detect Mares Quad with more flash memory
  Fix the limit for an invalid sample temperature
  Fix a buffer overflow
This commit is contained in:
Linus Torvalds 2019-05-31 09:49:17 -07:00
commit 8fb2b75c25
6 changed files with 36 additions and 8 deletions

View File

@ -212,6 +212,7 @@ static const dc_descriptor_t g_descriptors[] = {
{"Aeris", "F11", DC_FAMILY_OCEANIC_ATOM2, 0x4549, DC_TRANSPORT_SERIAL, NULL},
{"Oceanic", "OCi", DC_FAMILY_OCEANIC_ATOM2, 0x454B, DC_TRANSPORT_SERIAL, NULL},
{"Aeris", "A300CS", DC_FAMILY_OCEANIC_ATOM2, 0x454C, DC_TRANSPORT_SERIAL, NULL},
{"Tusa", "Talis", DC_FAMILY_OCEANIC_ATOM2, 0x454E, DC_TRANSPORT_SERIAL, NULL},
{"Beuchat", "Mundial 3", DC_FAMILY_OCEANIC_ATOM2, 0x4550, DC_TRANSPORT_SERIAL, NULL},
{"Oceanic", "Pro Plus X", DC_FAMILY_OCEANIC_ATOM2, 0x4552, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLE, NULL},
{"Oceanic", "F10", DC_FAMILY_OCEANIC_ATOM2, 0x4553, DC_TRANSPORT_SERIAL, NULL},
@ -431,6 +432,7 @@ static int dc_filter_uwatec (dc_transport_t transport, const void *userdata)
static const char *bluetooth[] = {
"G2",
"Aladin",
"HUD",
};
if (transport == DC_TRANSPORT_IRDA) {
@ -449,7 +451,7 @@ static int dc_filter_suunto (dc_transport_t transport, const void *userdata)
static const dc_usb_desc_t usbhid[] = {
{0x1493, 0x0030}, // Eon Steel
{0x1493, 0x0033}, // Eon Core
{0x1493, 0x0035}, // Suunto D5
{0x1493, 0x0035}, // D5
};
static const char *bluetooth[] = {
"EON Steel",

View File

@ -380,6 +380,20 @@ mares_iconhd_device_open (dc_device_t **out, dc_context_t *context, dc_iostream_
// Autodetect the model using the version packet.
device->model = mares_iconhd_get_model (device);
// Read the size of the flash memory.
unsigned int memsize = 0;
if (device->model == QUAD) {
unsigned char cmd_flash[] = {0xB3, 0x16};
unsigned char rsp_flash[4] = {0};
status = mares_iconhd_transfer (device, cmd_flash, sizeof (cmd_flash), rsp_flash, sizeof (rsp_flash));
if (status != DC_STATUS_SUCCESS) {
WARNING (context, "Failed to read the flash memory size.");
} else {
memsize = array_uint32_le (rsp_flash);
DEBUG (context, "Flash memory size is %u bytes.", memsize);
}
}
// Load the correct memory layout.
switch (device->model) {
case MATRIX:
@ -391,10 +405,17 @@ mares_iconhd_device_open (dc_device_t **out, dc_context_t *context, dc_iostream_
case NEMOWIDE2:
case SMART:
case SMARTAPNEA:
case QUAD:
device->layout = &mares_nemowide2_layout;
device->packetsize = 256;
break;
case QUAD:
if (memsize > 0x40000) {
device->layout = &mares_iconhd_layout;
} else {
device->layout = &mares_nemowide2_layout;
}
device->packetsize = 256;
break;
case QUADAIR:
case SMARTAIR:
device->layout = &mares_iconhdnet_layout;

View File

@ -100,13 +100,13 @@ mares_iconhd_parser_cache (mares_iconhd_parser_t *parser)
else if (parser->model == SMARTAPNEA)
header = 6; // Type and number of samples only!
if (size < header + 4) {
if (size < 4) {
ERROR (abstract->context, "Buffer overflow detected!");
return DC_STATUS_DATAFORMAT;
}
unsigned int length = array_uint32_le (data);
if (length > size) {
if (length < 4 + header || length > size) {
ERROR (abstract->context, "Buffer overflow detected!");
return DC_STATUS_DATAFORMAT;
}
@ -146,7 +146,7 @@ mares_iconhd_parser_cache (mares_iconhd_parser_t *parser)
samplesize = 14;
}
if (length < headersize) {
if (length < 4 + headersize) {
ERROR (abstract->context, "Buffer overflow detected!");
return DC_STATUS_DATAFORMAT;
}

View File

@ -152,6 +152,7 @@ static const oceanic_common_version_t tusa_zenair_version[] = {
{"AMPHOSSW \0\0 512K"},
{"AMPHOAIR \0\0 512K"},
{"VOYAGE2G \0\0 512K"},
{"TUSTALIS \0\0 512K"},
};
static const oceanic_common_version_t oceanic_oc1_version[] = {

View File

@ -76,6 +76,7 @@
#define F11A 0x4549
#define OCI 0x454B
#define A300CS 0x454C
#define TALIS 0x454E
#define MUNDIAL3 0x4550
#define PROPLUSX 0x4552
#define F10B 0x4553
@ -292,6 +293,7 @@ oceanic_atom2_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetim
case AMPHOS:
case AMPHOSAIR:
case VOYAGER2G:
case TALIS:
datetime->year = (p[3] & 0x1F) + 2000;
datetime->month = (p[7] & 0xF0) >> 4;
datetime->day = ((p[3] & 0x80) >> 3) + ((p[5] & 0xF0) >> 4);
@ -731,7 +733,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
parser->model == GEO || parser->model == GEO20 ||
parser->model == MANTA || parser->model == I300 ||
parser->model == I200 || parser->model == I100 ||
parser->model == I300C) {
parser->model == I300C || TALIS) {
have_pressure = 0;
}
@ -881,6 +883,8 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
parser->model == ELEMENT2 || parser->model == MANTA ||
parser->model == ZEN) {
temperature = data[offset + 6];
} else if (parser->model == TALIS) {
temperature = data[offset + 7];
} else if (parser->model == GEO20 || parser->model == VEO20 ||
parser->model == VEO30 || parser->model == OC1A ||
parser->model == OC1B || parser->model == OC1C ||

View File

@ -489,7 +489,7 @@ static void sample_temp(struct sample_data *info, short temp)
{
dc_sample_value_t sample = {0};
if (temp < -3000)
if (temp <= -3000)
return;
sample.temperature = temp / 10.0;