diff options
author | Jeffrey Stedfast <jestedfa@microsoft.com> | 2019-06-07 03:44:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-07 03:44:06 +0300 |
commit | 56d5c462ffc9b1c0067cbf27195ba243e7063160 (patch) | |
tree | bd10571acb6b9e068bc70f3533ba000a62b6ac62 /main | |
parent | 389c396b6e88d6e99e3c07dd675c9c6eb27ad839 (diff) | |
parent | 51c223960bd20df37c49b3dc35100a58a7846343 (diff) |
Merge pull request #7822 from mono/jstedfast-debugger-checksums
[Debugger] Improved source checksum logic for UNIX and DOS line endings
Diffstat (limited to 'main')
m--------- | main/external/debugger-libs | 0 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/SourceCodeLookup.cs | 56 |
2 files changed, 8 insertions, 48 deletions
diff --git a/main/external/debugger-libs b/main/external/debugger-libs -Subproject 7bca91a582a8161b0765e9121abb61b2aa28541 +Subproject 0ab6b6eb9331f4dcbda476d5652584ed8feeac2 diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/SourceCodeLookup.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/SourceCodeLookup.cs index bd69d29c79..91cc41a8e8 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/SourceCodeLookup.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/SourceCodeLookup.cs @@ -23,15 +23,17 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + using System; -using MonoDevelop.Core; -using System.Collections.Generic; using System.IO; -using System.Security.Cryptography; using System.Linq; +using System.Collections.Generic; + +using Mono.Debugging.Client; + using MonoDevelop.Ide; +using MonoDevelop.Core; using MonoDevelop.Projects; -using Mono.Debugging.Client; namespace MonoDevelop.Debugger { @@ -120,50 +122,9 @@ namespace MonoDevelop.Debugger return FilePath.Null; } - public static bool CheckFileHash (FilePath file, byte[] hash) + public static bool CheckFileHash (FilePath path, byte[] checksum) { - if (hash == null) - return false; - if (File.Exists (file)) { - using (var fs = File.OpenRead (file)) { - // Roslyn SHA1 checksum always starts with 20 - if (hash.Length > 0 && hash [0] == 20) - using (var sha1 = SHA1.Create ()) { - if (sha1.ComputeHash (fs).Take (15).SequenceEqual (hash.Skip (1))) { - return true; - } - } - if (hash.Length > 0 && hash [0] == 32) - using (var sha1 = SHA256.Create ()) { - if (sha1.ComputeHash (fs).Take (15).SequenceEqual (hash.Skip (1))) { - return true; - } - } - if (hash.Length == 20) { - using (var sha1 = SHA1.Create ()) { - fs.Position = 0; - if (sha1.ComputeHash (fs).SequenceEqual (hash)) { - return true; - } - } - } - if (hash.Length == 32) { - using (var sha256 = SHA256.Create ()) { - fs.Position = 0; - if (sha256.ComputeHash (fs).SequenceEqual (hash)) { - return true; - } - } - } - fs.Position = 0; - using (var md5 = MD5.Create ()) { - if (md5.ComputeHash (fs).SequenceEqual (hash)) { - return true; - } - } - } - } - return false; + return SourceLocation.CheckFileHash (path, checksum); } /// <summary> @@ -223,4 +184,3 @@ namespace MonoDevelop.Debugger } } } - |