Skip to content

Commit

Permalink
Fix the crash issue for 7-Zip's hash algorithms wrappers which mentio…
Browse files Browse the repository at this point in the history
…ned #542. (Thanks to RuesanG.)
  • Loading branch information
MouriNaruto committed Jan 7, 2025
1 parent a32520b commit 3c78701
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions NanaZip.Core/Wrappers/Sha256Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ void Sha256_InitState(
void Sha256_Init(
CSha256* p)
{
if (p)
{
// Workaround for using the uninitialized memory.
std::memset(p, 0, sizeof(CSha256));
}

::Sha256_InitState(p);
}

Expand Down
6 changes: 6 additions & 0 deletions NanaZip.Core/Wrappers/Sha512Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ void Sha512_Init(
CSha512* p,
unsigned digestSize)
{
if (p)
{
// Workaround for using the uninitialized memory.
std::memset(p, 0, sizeof(CSha512));
}

::Sha512_InitState(p, digestSize);
}

Expand Down

0 comments on commit 3c78701

Please sign in to comment.