Skip to content

Commit

Permalink
codeQL issues (#4948)
Browse files Browse the repository at this point in the history
Fix codeQL issues
  • Loading branch information
mikelle-rogers authored Sep 19, 2024
1 parent 551e68d commit aafed67
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ private static async Task Unzip(string zipPath, string expandedDirPath, ITestOut
ZipArchive zip = new(zipStream);
foreach (ZipArchiveEntry entry in zip.Entries)
{
string extractedFilePath = Path.Combine(expandedDirPath, entry.FullName);
string extractedFilePath = Path.GetFullPath(Path.Combine(expandedDirPath, entry.FullName));
string fullExtractedDirPath = Path.GetFullPath(expandedDirPath + Path.DirectorySeparatorChar);
if (!extractedFilePath.StartsWith(fullExtractedDirPath))
{
throw new InvalidDataException("Entry is outside of the target dir: " + entry.FullName);
}
Directory.CreateDirectory(Path.GetDirectoryName(extractedFilePath));
using (Stream zipFileStream = entry.Open())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public override IEnumerable<SymbolStoreKey> GetKeys(KeyTypeFlags flags)
if ((flags & KeyTypeFlags.IdentityKey) != 0)
{
#pragma warning disable CA5350 // Do Not Use Weak Cryptographic Algorithms
// CodeQL [SM02196] SSQP protocol requires the use of SHA1 and this doesn't constitute a security boundary.
byte[] hash = SHA1.Create().ComputeHash(_file.Stream);
#pragma warning restore CA5350 // Do Not Use Weak Cryptographic Algorithms
yield return GetKey(_file.FileName, hash);
Expand Down
7 changes: 4 additions & 3 deletions src/SOS/Strike/clrma/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ ClrmaException::Frame(
*pDisplacement = 0;

UINT nCount = 0;
if (HRESULT hr = get_FrameCount(&nCount))
HRESULT hr;
if (FAILED(hr = get_FrameCount(&nCount)))
{
return hr;
}
Expand Down Expand Up @@ -411,7 +412,7 @@ ClrmaException::InnerException(

HRESULT hr;
USHORT nCount = 0;
if (hr = get_InnerExceptionCount(&nCount))
if (FAILED(hr = get_InnerExceptionCount(&nCount)))
{
return hr;
}
Expand Down Expand Up @@ -453,7 +454,7 @@ ClrmaException::GetStackFrames()
TraceError("ClrmaException::GetStackFrames GetObjectData(%016llx) FAILED %08x\n", m_exceptionData.StackTrace, hr);
return hr;
}

if (arrayObjData.ObjectType != OBJ_ARRAY || arrayObjData.dwNumComponents == 0)
{
TraceError("ClrmaException::GetStackFrames StackTrace not array or empty\n");
Expand Down
3 changes: 2 additions & 1 deletion src/SOS/Strike/clrma/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ ClrmaThread::Frame(
*pDisplacement = 0;

UINT nCount = 0;
if (HRESULT hr = get_FrameCount(&nCount))
HRESULT hr;
if (FAILED(hr= get_FrameCount(&nCount)))
{
return hr;
}
Expand Down

0 comments on commit aafed67

Please sign in to comment.