microtek: Fix null termination of string, and adjust buffer lengths

The Product Revision Level field in the SCSI inquiry data has a fixed
length of 4 bytes. When copying it as a null-terminated string, place
the null terminator in the correct position; currently the string has
an extra character that is never initialized in memory.

Reduce the length of each string buffer, so it does not extend beyond
the null terminator.
escl-add-user-and-password
David Ward 2022-03-08 19:00:00 -05:00
rodzic 95e2498fe9
commit f651d6f098
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -1925,7 +1925,7 @@ static SANE_Status
dump_suspect_inquiry(unsigned char *result)
{
int i;
char vendor_id[64], model_name[64], revision_num[16];
char vendor_id[9], model_name[17], revision_num[5];
SANE_Byte device_type, model_code;
SANE_Byte SCSI_firmware_ver_major, SCSI_firmware_ver_minor;
SANE_Byte scanner_firmware_ver_major, scanner_firmware_ver_minor;
@ -1952,7 +1952,7 @@ dump_suspect_inquiry(unsigned char *result)
strncpy(revision_num, (char *)&result[32], 4);
vendor_id[8] = 0;
model_name[16] = 0;
revision_num[5] = 0;
revision_num[4] = 0;
device_type = (SANE_Byte)(result[0] & 0x1f);
SCSI_firmware_ver_major = (SANE_Byte)((result[1] & 0xf0) >> 4);
SCSI_firmware_ver_minor = (SANE_Byte)(result[1] & 0x0f);