Skip to content

Commit

Permalink
scpi_usbtmc_libusb: Check that bulk in requests read the entire header
Browse files Browse the repository at this point in the history
The Rigol DS1054Z sometimes returns zero bytes in response to a bulk in
request.  sigrok ends up reading out of bounds and failing ungracefully
when this happens.  Check that libusb returned a full USBTMC header and
fail gracefully if it did not.
  • Loading branch information
amluto authored and uwehermann committed Jun 24, 2020
1 parent 6999029 commit e228331
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/scpi/scpi_usbtmc_libusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,11 @@ static int scpi_usbtmc_bulkin_start(struct scpi_usbtmc_libusb *uscpi,
return SR_ERR;
}

if (transferred < USBTMC_BULK_HEADER_SIZE) {
sr_err("USBTMC bulk in returned too little data: %d/%d bytes\n", transferred, size);
return SR_ERR;
}

if (usbtmc_bulk_in_header_read(data, msg_id, uscpi->bTag, &message_size,
transfer_attributes) != SR_OK) {
sr_err("USBTMC invalid bulk in header.");
Expand Down

0 comments on commit e228331

Please sign in to comment.