From: Rodrigo Moya Date: Fri, 8 Sep 2017 17:36:20 +0000 (+0200) Subject: [Mono.Profiler.Log] Check MLPD version when reading header X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=mono.git;a=commitdiff_plain;h=de1633042b052df25b407007d9cb772319eb1895 [Mono.Profiler.Log] Check MLPD version when reading header Right now, when reading a MLPD of an old version, it just silently fails, so throw an exception when the version is unsuported. --- diff --git a/mcs/class/Mono.Profiler.Log/Mono.Profiler.Log/LogStreamHeader.cs b/mcs/class/Mono.Profiler.Log/Mono.Profiler.Log/LogStreamHeader.cs index b8eb4413fd7..494044d60ce 100644 --- a/mcs/class/Mono.Profiler.Log/Mono.Profiler.Log/LogStreamHeader.cs +++ b/mcs/class/Mono.Profiler.Log/Mono.Profiler.Log/LogStreamHeader.cs @@ -7,6 +7,8 @@ using System; namespace Mono.Profiler.Log { public sealed class LogStreamHeader { + const int MinimumMLPDSupportedVersion = 13; + const int MaximumMLPDSupportedVersion = 14; const int Id = 0x4d505a01; @@ -41,6 +43,10 @@ namespace Mono.Profiler.Log { Version = new Version (reader.ReadByte (), reader.ReadByte ()); FormatVersion = reader.ReadByte (); + + if (FormatVersion < MinimumMLPDSupportedVersion || FormatVersion > MaximumMLPDSupportedVersion) + throw new LogException ($"Unsupported MLPD version {FormatVersion}. Should be >= {MinimumMLPDSupportedVersion} and <= {MaximumMLPDSupportedVersion}"); + PointerSize = reader.ReadByte (); StartupTime = reader.ReadUInt64 (); TimerOverhead = reader.ReadInt32 ();