GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: fix CipherBase Update int32 overflow · nodejs/node@2fbf956

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/crypto
    • crypto_cipher.cc
  • test/parallel
    • test-crypto-cipheriv-decipheriv.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/crypto/crypto_cipher.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_cipher.cc
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,11 @@ CipherBase::UpdateResult CipherBase::Update(
803803
if (kind_ == kDecipher && IsAuthenticatedMode())
804804
CHECK(MaybePassAuthTagToOpenSSL());
805805

806-
int buf_len = len + EVP_CIPHER_CTX_block_size(ctx_.get());
806+
const int block_size = EVP_CIPHER_CTX_block_size(ctx_.get());
807+
CHECK_GT(block_size, 0);
808+
if (len + block_size > INT_MAX) return kErrorState;
809+
int buf_len = len + block_size;
810+
807811
// For key wrapping algorithms, get output size by calling
808812
// EVP_CipherUpdate() with null output.
809813
if (kind_ == kCipher && mode == EVP_CIPH_WRAP_MODE &&
Collapse file

‎test/parallel/test-crypto-cipheriv-decipheriv.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-cipheriv-decipheriv.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,11 @@ for (let n = minIvLength; n < maxIvLength; n += 1) {
215215
() => crypto.createCipheriv('aes-128-ecb', Buffer.alloc(17), null),
216216
/Invalid key length/);
217217
}
218+
219+
{
220+
// https://github.com/nodejs/node/issues/45757
221+
// eslint-disable-next-line no-restricted-syntax
222+
assert.throws(() =>
223+
crypto.createCipheriv('aes-128-gcm', Buffer.alloc(16), Buffer.alloc(12))
224+
.update(Buffer.allocUnsafeSlow(2 ** 31 - 1)));
225+
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.