Skip to content

Commit d48deed

Browse files
committed
crypto, bugfix: too large matrix size will cause crypto.randomArt to crash, #677
1 parent 6c6be87 commit d48deed

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

fibjs/src/crypto/crypto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ char* randomart(const unsigned char* dgst_raw, size_t dgst_raw_len,
288288
result_t crypto_base::randomArt(Buffer_base* data, exlib::string title,
289289
int32_t size, exlib::string& retVal)
290290
{
291-
if (size < 1)
291+
if (size < 1 || size > 128)
292292
return CHECK_ERROR(CALL_E_OUTRANGE);
293293

294294
exlib::string buf;

test/crypto_test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ describe('crypto', () => {
225225
assert.throws(() => {
226226
crypto.randomArt(data, "title", 0);
227227
});
228+
229+
assert.throws(() => {
230+
crypto.randomArt(undefined, '', 1064203628);
231+
});
228232
});
229233

230234
describe('Cipher', () => {

0 commit comments

Comments
 (0)