Updated MODE SENSE error handling in case of an overflow (#732)

* Updated MODE SENSE error handling

* Updated range check
This commit is contained in:
Uwe Seimet 2022-03-14 01:46:43 +01:00 committed by GitHub
parent 08156f763f
commit 32fb022a41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -459,6 +459,11 @@ int Disk::ModeSense6(const DWORD *cdb, BYTE *buf)
}
size += pages_size;
if (size > 255) {
SetStatusCode(STATUS_INVALIDPRM);
return 0;
}
// Do not return more than ALLOCATION LENGTH bytes
if (size > length) {
size = length;
@ -541,6 +546,11 @@ int Disk::ModeSense10(const DWORD *cdb, BYTE *buf, int max_length)
}
size += pages_size;
if (size > 65535) {
SetStatusCode(STATUS_INVALIDPRM);
return 0;
}
// Do not return more than ALLOCATION LENGTH bytes
if (size > length) {
size = length;