Skip to content

Commit 877f206

Browse files
authored
Merge pull request #10 from microsoft/benjaming/address-codeql
Address CodeQL
2 parents b5d0911 + 6db67d8 commit 877f206

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

Diff for: src/ProfileExplorerCore/Utilities/CompressionUtils.cs

-15
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,6 @@ public static string DecompressString(byte[] data) {
3939
return Encoding.UTF8.GetString(Decompress(data));
4040
}
4141

42-
public static byte[] CreateMD5(byte[] data) {
43-
using var md5 = MD5.Create();
44-
return md5.ComputeHash(data);
45-
}
46-
47-
public static string CreateMD5String(byte[] data) {
48-
byte[] hash = CreateMD5(data);
49-
return BitConverter.ToString(hash).Replace("-", string.Empty, StringComparison.Ordinal).
50-
ToLowerInvariant();
51-
}
52-
53-
public static string CreateMD5String(string text) {
54-
return CreateMD5String(Encoding.UTF8.GetBytes(text));
55-
}
56-
5742
public static byte[] CreateSHA256(byte[] data) {
5843
using var sha = SHA256.Create();
5944
return sha.ComputeHash(data);

Diff for: src/ProfileExplorerUI/Binary/PDBDebugInfoProvider.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,10 @@ private bool SourceFileChecksumMatchesPDB(IDiaSourceFile sourceFile, string file
638638
}
639639

640640
var hashAlgo = GetSourceFileChecksumHashAlgorithm(sourceFile);
641+
if (hashAlgo == null) {
642+
return false;
643+
}
644+
641645
byte[] pdbChecksum = GetSourceFileChecksum(sourceFile);
642646
byte[] fileChecksum = ComputeSourceFileChecksum(filePath, hashAlgo);
643647
return pdbChecksum != null && fileChecksum != null &&
@@ -695,10 +699,8 @@ private bool SourceFileChecksumMatchesPDB(IDiaSourceFile sourceFile, string file
695699

696700
private HashAlgorithm GetSourceFileChecksumHashAlgorithm(IDiaSourceFile sourceFile) {
697701
return sourceFile.checksumType switch {
698-
1 => MD5.Create(),
699-
2 => SHA1.Create(),
700702
3 => SHA256.Create(),
701-
_ => MD5.Create()
703+
_ => null
702704
};
703705
}
704706

0 commit comments

Comments
 (0)