mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Check there are no more than two consecutive nulls (UTF-16 can
have one null).
This commit is contained in:
@@ -248,9 +248,22 @@ namespace DiscImageChef.ImagePlugins
|
|||||||
imageFilter.GetDataForkStream().Read(testArray, 0, 512);
|
imageFilter.GetDataForkStream().Read(testArray, 0, 512);
|
||||||
imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin);
|
imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin);
|
||||||
// Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin
|
// Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin
|
||||||
foreach(byte b in testArray)
|
bool twoConsecutiveNulls = false;
|
||||||
|
for(int i = 0; i < 512; i++)
|
||||||
{
|
{
|
||||||
if(b < 0x20 && b != 0x0A && b != 0x0D && b != 0x00)
|
if(i >= imageFilter.GetDataForkStream().Length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if(testArray[i] == 0)
|
||||||
|
{
|
||||||
|
if(twoConsecutiveNulls)
|
||||||
|
return false;
|
||||||
|
twoConsecutiveNulls = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
twoConsecutiveNulls = false;
|
||||||
|
|
||||||
|
if(testArray[i] < 0x20 && testArray[i] != 0x0A && testArray[i] != 0x0D && testArray[i] != 0x00)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -320,9 +320,22 @@ namespace DiscImageChef.ImagePlugins
|
|||||||
imageFilter.GetDataForkStream().Read(testArray, 0, 512);
|
imageFilter.GetDataForkStream().Read(testArray, 0, 512);
|
||||||
imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin);
|
imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin);
|
||||||
// Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin
|
// Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin
|
||||||
foreach(byte b in testArray)
|
bool twoConsecutiveNulls = false;
|
||||||
|
for(int i = 0; i < 512; i++)
|
||||||
{
|
{
|
||||||
if(b < 0x20 && b != 0x0A && b != 0x0D && b != 0x00)
|
if(i >= imageFilter.GetDataForkStream().Length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if(testArray[i] == 0)
|
||||||
|
{
|
||||||
|
if(twoConsecutiveNulls)
|
||||||
|
return false;
|
||||||
|
twoConsecutiveNulls = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
twoConsecutiveNulls = false;
|
||||||
|
|
||||||
|
if(testArray[i] < 0x20 && testArray[i] != 0x0A && testArray[i] != 0x0D && testArray[i] != 0x00)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,9 +127,22 @@ namespace DiscImageChef.DiscImages
|
|||||||
imageFilter.GetDataForkStream().Read(testArray, 0, 512);
|
imageFilter.GetDataForkStream().Read(testArray, 0, 512);
|
||||||
imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin);
|
imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin);
|
||||||
// Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin
|
// Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin
|
||||||
foreach(byte b in testArray)
|
bool twoConsecutiveNulls = false;
|
||||||
|
for(int i = 0; i < 512; i++)
|
||||||
{
|
{
|
||||||
if(b < 0x20 && b != 0x0A && b != 0x0D && b != 0x00)
|
if(i >= imageFilter.GetDataForkStream().Length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if(testArray[i] == 0)
|
||||||
|
{
|
||||||
|
if(twoConsecutiveNulls)
|
||||||
|
return false;
|
||||||
|
twoConsecutiveNulls = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
twoConsecutiveNulls = false;
|
||||||
|
|
||||||
|
if(testArray[i] < 0x20 && testArray[i] != 0x0A && testArray[i] != 0x0D && testArray[i] != 0x00)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,9 +138,22 @@ namespace DiscImageChef.ImagePlugins
|
|||||||
imageFilter.GetDataForkStream().Read(testArray, 0, 512);
|
imageFilter.GetDataForkStream().Read(testArray, 0, 512);
|
||||||
imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin);
|
imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin);
|
||||||
// Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin
|
// Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin
|
||||||
foreach(byte b in testArray)
|
bool twoConsecutiveNulls = false;
|
||||||
|
for(int i = 0; i < 512; i++)
|
||||||
{
|
{
|
||||||
if(b < 0x20 && b != 0x0A && b != 0x0D && b != 0x00)
|
if(i >= imageFilter.GetDataForkStream().Length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if(testArray[i] == 0)
|
||||||
|
{
|
||||||
|
if(twoConsecutiveNulls)
|
||||||
|
return false;
|
||||||
|
twoConsecutiveNulls = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
twoConsecutiveNulls = false;
|
||||||
|
|
||||||
|
if(testArray[i] < 0x20 && testArray[i] != 0x0A && testArray[i] != 0x0D && testArray[i] != 0x00)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
gdiStream = new StreamReader(imageFilter.GetDataForkStream());
|
gdiStream = new StreamReader(imageFilter.GetDataForkStream());
|
||||||
|
|||||||
Reference in New Issue
Block a user