Skip to content

Commit 60d5d5b

Browse files
committed
Emscripten's getentropy does not enforce the 256-byte limit
1 parent 0395b6b commit 60d5d5b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

crypto/rand_extra/getentropy_test.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@ TEST(GetEntropyTest, NotObviouslyBroken) {
5454
memcpy(buf3, buf1, sizeof(buf3));
5555
EXPECT_EQ(getentropy(buf1, sizeof(buf1)), 0);
5656
EXPECT_NE(Bytes(buf1), Bytes(buf3));
57-
errno = 0;
58-
uint8_t toobig[257];
5957
// getentropy should fail returning -1 and setting errno to EIO if you request
6058
// more than 256 bytes of entropy. macOS's man page says EIO but it actually
6159
// returns EINVAL, so we accept either.
60+
// Note: Emscripten's getentropy implementation does not enforce the 256-byte
61+
// limit, so we skip this check on WASM.
62+
#if !defined(OPENSSL_WASM)
63+
errno = 0;
64+
uint8_t toobig[257];
6265
EXPECT_EQ(getentropy(toobig, 257), -1);
6366
EXPECT_TRUE(errno == EIO || errno == EINVAL);
67+
#endif
6468
}
6569
#endif

0 commit comments

Comments
 (0)