Skip to content

Commit 4466ecd

Browse files
committed
Prevent UBSAN by explicitly setting the salt
Presumably fixes #1
1 parent a24960e commit 4466ecd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/util.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ int getcpuperf(double *opps)
128128
struct timespec st;
129129
double resd, diffd;
130130
uint64_t i = 0;
131+
uint8_t salt[32] = {0};
131132

132133
/* Get the clock resolution. */
133134
if (getclockres(&resd))
@@ -142,7 +143,7 @@ int getcpuperf(double *opps)
142143
return (2);
143144
do {
144145
/* Do an scrypt. */
145-
if (crypto_scrypt(NULL, 0, NULL, 0, 16, 1, 1, NULL, 0))
146+
if (crypto_scrypt(NULL, 0, salt, 0, 16, 1, 1, NULL, 0))
146147
return (3);
147148

148149
/* Has the clock ticked? */
@@ -157,7 +158,7 @@ int getcpuperf(double *opps)
157158
return (2);
158159
do {
159160
/* Do an scrypt. */
160-
if (crypto_scrypt(NULL, 0, NULL, 0, 128, 1, 1, NULL, 0))
161+
if (crypto_scrypt(NULL, 0, salt, 0, 128, 1, 1, NULL, 0))
161162
return (3);
162163

163164
/* We invoked the salsa20/8 core 512 times. */

0 commit comments

Comments
 (0)