diff --git a/DiscImageChef.DiscImages/CDRDAO.cs b/DiscImageChef.DiscImages/CDRDAO.cs index 8ead711b..3ef22c8a 100644 --- a/DiscImageChef.DiscImages/CDRDAO.cs +++ b/DiscImageChef.DiscImages/CDRDAO.cs @@ -244,7 +244,17 @@ namespace DiscImageChef.ImagePlugins try { imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); - tocStream = new StreamReader(imageFilter.GetDataForkStream()); + byte[] testArray = new byte[512]; + imageFilter.GetDataForkStream().Read(testArray, 0, 512); + 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 + foreach(byte b in testArray) + { + if(b < 0x20 && b != 0x0A && b != 0x0D) + return false; + } + + tocStream = new StreamReader(imageFilter.GetDataForkStream()); string _line = tocStream.ReadLine(); Regex Dr = new Regex(DiskTypeRegEx); diff --git a/DiscImageChef.DiscImages/CDRWin.cs b/DiscImageChef.DiscImages/CDRWin.cs index 9dfe0bfb..7b6d3819 100644 --- a/DiscImageChef.DiscImages/CDRWin.cs +++ b/DiscImageChef.DiscImages/CDRWin.cs @@ -315,8 +315,18 @@ namespace DiscImageChef.ImagePlugins try { - imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); - cueStream = new StreamReader(this.imageFilter.GetDataForkStream()); + imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); + byte[] testArray = new byte[512]; + imageFilter.GetDataForkStream().Read(testArray, 0, 512); + 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 + foreach(byte b in testArray) + { + if(b < 0x20 && b != 0x0A && b != 0x0D) + return false; + } + + cueStream = new StreamReader(this.imageFilter.GetDataForkStream()); int line = 0; while(cueStream.Peek() >= 0) diff --git a/DiscImageChef.DiscImages/GDI.cs b/DiscImageChef.DiscImages/GDI.cs index 264d2c09..e74b53a6 100644 --- a/DiscImageChef.DiscImages/GDI.cs +++ b/DiscImageChef.DiscImages/GDI.cs @@ -133,8 +133,17 @@ namespace DiscImageChef.ImagePlugins { try { - imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); - gdiStream = new StreamReader(imageFilter.GetDataForkStream()); + imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); + byte[] testArray = new byte[512]; + imageFilter.GetDataForkStream().Read(testArray, 0, 512); + 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 + foreach(byte b in testArray) + { + if(b < 0x20 && b != 0x0A && b != 0x0D) + return false; + } + gdiStream = new StreamReader(imageFilter.GetDataForkStream()); int line = 0; int tracksFound = 0; int tracks = 0; diff --git a/DiscImageChef.Filesystems/FATX.cs b/DiscImageChef.Filesystems/FATX.cs new file mode 100644 index 00000000..7d40a485 --- /dev/null +++ b/DiscImageChef.Filesystems/FATX.cs @@ -0,0 +1,42 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : FATX.cs +// Author(s) : Natalia Portillo +// +// Component : Component +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2016 Natalia Portillo +// ****************************************************************************/ +using System; +namespace DiscImageChef.Filesystems +{ + public class FATX + { + public FATX() + { + } + } +} + diff --git a/DiscImageChef.Filters/MacBinary.cs b/DiscImageChef.Filters/MacBinary.cs index bf122e47..8ac14763 100644 --- a/DiscImageChef.Filters/MacBinary.cs +++ b/DiscImageChef.Filters/MacBinary.cs @@ -277,7 +277,8 @@ namespace DiscImageChef.Filters header = BigEndianMarshal.ByteArrayToStructureBigEndian(hdr_b); return header.magic == MacBinaryMagic || (header.version == 0 && header.filename[0] > 0 && header.filename[0] < 64 && - header.zero1 == 0 && header.zero2 == 0 && header.reserved == 0); + header.zero1 == 0 && header.zero2 == 0 && header.reserved == 0 && ( + header.dataLength > 0 || header.resourceLength > 0)); } public override bool Identify(Stream stream) @@ -291,7 +292,8 @@ namespace DiscImageChef.Filters header = BigEndianMarshal.ByteArrayToStructureBigEndian(hdr_b); return header.magic == MacBinaryMagic || (header.version == 0 && header.filename[0] > 0 && header.filename[0] < 64 && - header.zero1 == 0 && header.zero2 == 0 && header.reserved == 0); + header.zero1 == 0 && header.zero2 == 0 && header.reserved == 0 && ( + header.dataLength > 0 || header.resourceLength > 0)); } public override bool Identify(string path) @@ -306,7 +308,8 @@ namespace DiscImageChef.Filters fstream.Close(); return header.magic == MacBinaryMagic || (header.version == 0 && header.filename[0] > 0 && header.filename[0] < 64 && - header.zero1 == 0 && header.zero2 == 0 && header.reserved == 0); + header.zero1 == 0 && header.zero2 == 0 && header.reserved == 0 && ( + header.dataLength > 0 || header.resourceLength > 0)); } public override bool IsOpened() diff --git a/DiscImageChef.Partitions/Xbox.cs b/DiscImageChef.Partitions/Xbox.cs new file mode 100644 index 00000000..d0740e57 --- /dev/null +++ b/DiscImageChef.Partitions/Xbox.cs @@ -0,0 +1,42 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Xbox.cs +// Author(s) : Natalia Portillo +// +// Component : Component +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2016 Natalia Portillo +// ****************************************************************************/ +using System; +namespace DiscImageChef.Partitions +{ + public class Xbox + { + public Xbox() + { + } + } +} +