mirror of
https://github.com/aaru-dps/Aaru.Decoders.git
synced 2025-12-16 19:24:32 +00:00
Fix overflows in ATA and SCSI encoders.
This commit is contained in:
@@ -3574,8 +3574,12 @@ namespace DiscImageChef.Decoders.ATA
|
||||
|
||||
static byte[] ScrambleATAString(string str, int length)
|
||||
{
|
||||
byte[] bytes = Encoding.ASCII.GetBytes(str);
|
||||
byte[] buf = new byte[length];
|
||||
for(int i = 0; i < length; i++) buf[i] = 0x20;
|
||||
|
||||
if(str is null) return buf;
|
||||
|
||||
byte[] bytes = Encoding.ASCII.GetBytes(str);
|
||||
Array.Copy(bytes, 0, buf, 0, bytes.Length);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -357,19 +357,19 @@ namespace DiscImageChef.Decoders.SCSI
|
||||
if(decoded.VendorIdentification != null)
|
||||
{
|
||||
length = 16;
|
||||
Array.Copy(decoded.VendorIdentification, 0, buffer, 8, 8);
|
||||
Array.Copy(decoded.VendorIdentification, 0, buffer, 8, decoded.VendorIdentification.Length >= 8 ? 8 : decoded.VendorIdentification.Length);
|
||||
}
|
||||
|
||||
if(decoded.ProductIdentification != null)
|
||||
{
|
||||
length = 32;
|
||||
Array.Copy(decoded.ProductIdentification, 0, buffer, 16, 16);
|
||||
Array.Copy(decoded.ProductIdentification, 0, buffer, 16, decoded.ProductIdentification.Length >= 16 ? 16 : decoded.ProductIdentification.Length);
|
||||
}
|
||||
|
||||
if(decoded.ProductRevisionLevel != null)
|
||||
{
|
||||
length = 36;
|
||||
Array.Copy(decoded.ProductRevisionLevel, 0, buffer, 32, 4);
|
||||
Array.Copy(decoded.ProductRevisionLevel, 0, buffer, 32, decoded.ProductRevisionLevel.Length >= 4 ? 4 : decoded.ProductRevisionLevel.Length);
|
||||
}
|
||||
|
||||
if(decoded.Seagate_DriveSerialNumber != null)
|
||||
|
||||
Reference in New Issue
Block a user