tape: changer: handle libraries that sends wrong amount of data
if the library sends more data than advertised, simply cut it off, but if it sends less data, bail out (depending on how much data is missing, trying to parse it could lead to a panic, so bail out early) Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
3ab2432ab6
commit
13e13d836f
@ -692,6 +692,15 @@ fn decode_element_status_page(
|
|||||||
bail!("got wrong first_element_address_reported"); // sanity check
|
bail!("got wrong first_element_address_reported"); // sanity check
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let len = head.byte_count_of_report_available;
|
||||||
|
let len = ((len[0] as usize) << 16) + ((len[1] as usize) << 8) + (len[2] as usize);
|
||||||
|
|
||||||
|
if len < reader.len() {
|
||||||
|
reader = &reader[..len];
|
||||||
|
} else if len > reader.len() {
|
||||||
|
bail!("wrong amount of data: expected {}, got {}", len, reader.len());
|
||||||
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if reader.is_empty() {
|
if reader.is_empty() {
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user