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())
{
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);
*pDisplacement = 0;
UINT nCount = 0;
- if (HRESULT hr = get_FrameCount(&nCount))
+ HRESULT hr;
+ if (FAILED(hr = get_FrameCount(&nCount)))
{
return hr;
}
HRESULT hr;
USHORT nCount = 0;
- if (hr = get_InnerExceptionCount(&nCount))
+ if (FAILED(hr = get_InnerExceptionCount(&nCount)))
{
return hr;
}
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");
*pDisplacement = 0;
UINT nCount = 0;
- if (HRESULT hr = get_FrameCount(&nCount))
+ HRESULT hr;
+ if (FAILED(hr= get_FrameCount(&nCount)))
{
return hr;
}