Skip to content

Commit

Permalink
Fix the crash issue for 7-Zip's hash algorithms wrappers I commited b…
Browse files Browse the repository at this point in the history
…efore.
  • Loading branch information
MouriNaruto committed Dec 24, 2024
1 parent cab96cf commit 5a3786b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion NanaZip.Core/Wrappers/Sha256Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@

#include "Sha256Wrapper.h"

#include <cstring>

BoolInt Sha256_SetFunction(
CSha256* p,
unsigned algo)
{
UNREFERENCED_PARAMETER(p);
UNREFERENCED_PARAMETER(algo);

if (p)
{
// Workaround for using the uninitialized memory.
std::memset(p, 0, sizeof(CSha256));
}

// Only return true because it's a wrapper to K7Pal.
return True;
}
Expand Down
10 changes: 9 additions & 1 deletion NanaZip.Core/Wrappers/Sha512Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@

#include "Sha512Wrapper.h"

#include <cstring>

BoolInt Sha512_SetFunction(
CSha512* p,
unsigned algo)
{
UNREFERENCED_PARAMETER(p);
UNREFERENCED_PARAMETER(algo);

if (p)
{
// Workaround for using the uninitialized memory.
std::memset(p, 0, sizeof(CSha512));
}

// Only return true because it's a wrapper to K7Pal.
return True;
}
Expand Down

0 comments on commit 5a3786b

Please sign in to comment.