Skip to content

Commit

Permalink
Prevent UBSAN by explicitly setting the salt
Browse files Browse the repository at this point in the history
Presumably fixes #1
  • Loading branch information
bobjansen committed Apr 12, 2022
1 parent a24960e commit 4466ecd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ int getcpuperf(double *opps)
struct timespec st;
double resd, diffd;
uint64_t i = 0;
uint8_t salt[32] = {0};

/* Get the clock resolution. */
if (getclockres(&resd))
Expand All @@ -142,7 +143,7 @@ int getcpuperf(double *opps)
return (2);
do {
/* Do an scrypt. */
if (crypto_scrypt(NULL, 0, NULL, 0, 16, 1, 1, NULL, 0))
if (crypto_scrypt(NULL, 0, salt, 0, 16, 1, 1, NULL, 0))
return (3);

/* Has the clock ticked? */
Expand All @@ -157,7 +158,7 @@ int getcpuperf(double *opps)
return (2);
do {
/* Do an scrypt. */
if (crypto_scrypt(NULL, 0, NULL, 0, 128, 1, 1, NULL, 0))
if (crypto_scrypt(NULL, 0, salt, 0, 128, 1, 1, NULL, 0))
return (3);

/* We invoked the salsa20/8 core 512 times. */
Expand Down

0 comments on commit 4466ecd

Please sign in to comment.