Skip to content

Commit 4b9069c

Browse files
jefdriesenmikeller
authored andcommitted
Increase the size of the device info buffer
In bluetooth protocol v1.30, the length of the CMD_GET_STATUS response increased from 20 to 36 bytes. Increase the size of the buffer and update the code to support both lengths.
1 parent 1125c6a commit 4b9069c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/halcyon_symbios.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,19 +443,27 @@ halcyon_symbios_device_foreach (dc_device_t *abstract, dc_dive_callback_t callba
443443
device_event_emit (abstract, DC_EVENT_PROGRESS, &progress);
444444

445445
// Read the device status.
446-
unsigned char info[20] = {0};
447-
status = halcyon_symbios_transfer (device, CMD_GET_STATUS, NULL, 0, info, sizeof(info), NULL, NULL);
446+
unsigned char info[36] = {0};
447+
unsigned int info_size = 0;
448+
status = halcyon_symbios_transfer (device, CMD_GET_STATUS, NULL, 0, info, sizeof(info), &info_size, NULL);
448449
if (status != DC_STATUS_SUCCESS) {
449450
ERROR (abstract->context, "Failed to read the device status.");
450451
goto error_exit;
451452
}
452453

453-
HEXDUMP (abstract->context, DC_LOGLEVEL_DEBUG, "Version", info, sizeof(info));
454+
// Verify the length of the packet.
455+
if (info_size < 20) {
456+
ERROR (abstract->context, "Unexpected packet length (%u).", info_size);
457+
status = DC_STATUS_PROTOCOL;
458+
goto error_exit;
459+
}
460+
461+
HEXDUMP (abstract->context, DC_LOGLEVEL_DEBUG, "Version", info, info_size);
454462

455463
// Emit a vendor event.
456464
dc_event_vendor_t vendor;
457465
vendor.data = info;
458-
vendor.size = sizeof(info);
466+
vendor.size = info_size;
459467
device_event_emit (abstract, DC_EVENT_VENDOR, &vendor);
460468

461469
// Emit a device info event.

0 commit comments

Comments
 (0)