mirror of
https://github.com/aaru-dps/Aaru.Decoders.git
synced 2025-12-16 19:24:32 +00:00
Do not skip pages when decoding a page longer than the MODE SENSE buffer.
This commit is contained in:
@@ -204,11 +204,12 @@ namespace Aaru.Decoders.SCSI
|
|||||||
if(isSubpage)
|
if(isSubpage)
|
||||||
{
|
{
|
||||||
pg.PageResponse = new byte[(modeResponse[offset + 2] << 8) + modeResponse[offset + 3] + 4];
|
pg.PageResponse = new byte[(modeResponse[offset + 2] << 8) + modeResponse[offset + 3] + 4];
|
||||||
|
int copyLen = pg.PageResponse.Length;
|
||||||
|
|
||||||
if(pg.PageResponse.Length + offset > modeResponse.Length)
|
if(pg.PageResponse.Length + offset > modeResponse.Length)
|
||||||
return decoded;
|
copyLen = modeResponse.Length - offset;
|
||||||
|
|
||||||
Array.Copy(modeResponse, offset, pg.PageResponse, 0, pg.PageResponse.Length);
|
Array.Copy(modeResponse, offset, pg.PageResponse, 0, copyLen);
|
||||||
pg.Page = (byte)(modeResponse[offset] & 0x3F);
|
pg.Page = (byte)(modeResponse[offset] & 0x3F);
|
||||||
pg.Subpage = modeResponse[offset + 1];
|
pg.Subpage = modeResponse[offset + 1];
|
||||||
offset += pg.PageResponse.Length;
|
offset += pg.PageResponse.Length;
|
||||||
@@ -216,11 +217,12 @@ namespace Aaru.Decoders.SCSI
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
pg.PageResponse = new byte[modeResponse[offset + 1] + 2];
|
pg.PageResponse = new byte[modeResponse[offset + 1] + 2];
|
||||||
|
int copyLen = pg.PageResponse.Length;
|
||||||
|
|
||||||
if(pg.PageResponse.Length + offset > modeResponse.Length)
|
if(pg.PageResponse.Length + offset > modeResponse.Length)
|
||||||
return decoded;
|
copyLen = modeResponse.Length - offset;
|
||||||
|
|
||||||
Array.Copy(modeResponse, offset, pg.PageResponse, 0, pg.PageResponse.Length);
|
Array.Copy(modeResponse, offset, pg.PageResponse, 0, copyLen);
|
||||||
pg.Page = (byte)(modeResponse[offset] & 0x3F);
|
pg.Page = (byte)(modeResponse[offset] & 0x3F);
|
||||||
pg.Subpage = 0;
|
pg.Subpage = 0;
|
||||||
offset += pg.PageResponse.Length;
|
offset += pg.PageResponse.Length;
|
||||||
|
|||||||
@@ -149,11 +149,12 @@ namespace Aaru.Decoders.SCSI
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
pg.PageResponse = new byte[(modeResponse[offset + 2] << 8) + modeResponse[offset + 3] + 4];
|
pg.PageResponse = new byte[(modeResponse[offset + 2] << 8) + modeResponse[offset + 3] + 4];
|
||||||
|
int copyLen = pg.PageResponse.Length;
|
||||||
|
|
||||||
if(pg.PageResponse.Length + offset > modeResponse.Length)
|
if(pg.PageResponse.Length + offset > modeResponse.Length)
|
||||||
return decoded;
|
copyLen = modeResponse.Length - offset;
|
||||||
|
|
||||||
Array.Copy(modeResponse, offset, pg.PageResponse, 0, pg.PageResponse.Length);
|
Array.Copy(modeResponse, offset, pg.PageResponse, 0, copyLen);
|
||||||
pg.Page = (byte)(modeResponse[offset] & 0x3F);
|
pg.Page = (byte)(modeResponse[offset] & 0x3F);
|
||||||
pg.Subpage = modeResponse[offset + 1];
|
pg.Subpage = modeResponse[offset + 1];
|
||||||
offset += pg.PageResponse.Length;
|
offset += pg.PageResponse.Length;
|
||||||
@@ -164,11 +165,12 @@ namespace Aaru.Decoders.SCSI
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
pg.PageResponse = new byte[modeResponse[offset + 1] + 2];
|
pg.PageResponse = new byte[modeResponse[offset + 1] + 2];
|
||||||
|
int copyLen = pg.PageResponse.Length;
|
||||||
|
|
||||||
if(pg.PageResponse.Length + offset > modeResponse.Length)
|
if(pg.PageResponse.Length + offset > modeResponse.Length)
|
||||||
return decoded;
|
copyLen = modeResponse.Length - offset;
|
||||||
|
|
||||||
Array.Copy(modeResponse, offset, pg.PageResponse, 0, pg.PageResponse.Length);
|
Array.Copy(modeResponse, offset, pg.PageResponse, 0, copyLen);
|
||||||
pg.Page = (byte)(modeResponse[offset] & 0x3F);
|
pg.Page = (byte)(modeResponse[offset] & 0x3F);
|
||||||
pg.Subpage = 0;
|
pg.Subpage = 0;
|
||||||
offset += pg.PageResponse.Length;
|
offset += pg.PageResponse.Length;
|
||||||
|
|||||||
Reference in New Issue
Block a user