From 27775bd0773afa0ec07c99e34b4b7eab54f76fa7 Mon Sep 17 00:00:00 2001 From: "Wiedner, Daniel" Date: Wed, 24 Oct 2018 15:20:08 +0200 Subject: [PATCH] Added cyclic sector chain check to CompoundFile.GetMiniSectorChain --- sources/OpenMcdf/CompoundFile.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sources/OpenMcdf/CompoundFile.cs b/sources/OpenMcdf/CompoundFile.cs index 556ea88e..d0654175 100644 --- a/sources/OpenMcdf/CompoundFile.cs +++ b/sources/OpenMcdf/CompoundFile.cs @@ -1507,8 +1507,13 @@ StreamView miniFATView result.Add(ms); miniFATView.Seek(nextSecID * 4, SeekOrigin.Begin); - nextSecID = miniFATReader.ReadInt32(); - } + int next = miniFATReader.ReadInt32(); + + if (next != nextSecID) + nextSecID = next; + else + throw new CFCorruptedFileException("Cyclic sector chain found. File is corrupted"); + } } return result; }