Skip to content

Commit

Permalink
use pointer to whole struct instead publicKey for buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Jan 19, 2025
1 parent 4edde33 commit 5e30193
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions libi2pd/Identity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ namespace data

size_t Identity::FromBuffer (const uint8_t * buf, size_t len)
{
if ( len < DEFAULT_IDENTITY_SIZE ) {
// buffer too small, don't overflow
return 0;
}
memcpy (publicKey, buf, DEFAULT_IDENTITY_SIZE);
if (len < DEFAULT_IDENTITY_SIZE) return 0; // buffer too small, don't overflow
memcpy (this, buf, DEFAULT_IDENTITY_SIZE);
return DEFAULT_IDENTITY_SIZE;
}

IdentHash Identity::Hash () const
{
IdentHash hash;
SHA256(publicKey, DEFAULT_IDENTITY_SIZE, hash);
SHA256((const uint8_t *)this, DEFAULT_IDENTITY_SIZE, hash);
return hash;
}

Expand Down

0 comments on commit 5e30193

Please sign in to comment.