lib: check length for sense key specific sense data descriptors

Explicitly check that the sense data descriptor ADDITIONAL LENGTH field
matches the expected value for sense key specific sense data
descriptors.

Signed-off-by: David Disseldorp <ddiss@suse.de>
This commit is contained in:
David Disseldorp
2020-10-19 14:37:13 +02:00
parent 34a632a04e
commit 02b9b01fa1

View File

@@ -326,12 +326,14 @@ static void parse_sense_descriptors(struct scsi_sense *sense, const uint8_t *sb,
const unsigned char *p, *const end = sb + sb_len;
for (p = sb; p < end; p += p[1]) {
if (p[1] < 4) /* length */
uint8_t addl_len = p[1];
if (addl_len < 4)
break;
switch (p[0]) {
case 2:
/* Sense key specific sense data descriptor */
parse_sense_spec(sense, p + 4);
if (addl_len == 0x06)
parse_sense_spec(sense, p + 4);
break;
}
}