Skip to content

Commit

Permalink
v8: out of bounds copy
Browse files Browse the repository at this point in the history
Fixes: #54573

Co-authored-by: ronag <[email protected]>
Co-authored-by: ramidzkh <[email protected]>
  • Loading branch information
ronag and ramidzkh committed Oct 4, 2024
1 parent d2ad9b4 commit 3d3950f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ if (internalBinding('config').hasInspector) {
}

const assert = require('internal/assert');
const { copy } = internalBinding('buffer');
const { inspect } = require('internal/util/inspect');
const { FastBuffer } = require('internal/buffer');
const { getValidatedPath } = require('internal/fs/utils');
Expand Down Expand Up @@ -368,7 +367,7 @@ class DefaultDeserializer extends Deserializer {
}
// Copy to an aligned buffer first.
const buffer_copy = Buffer.allocUnsafe(byteLength);
copy(this.buffer, buffer_copy, 0, byteOffset, byteOffset + byteLength);
this.buffer.copy(buffer_copy, 0, byteOffset, byteOffset + byteLength);
return new ctor(buffer_copy.buffer,
buffer_copy.byteOffset,
byteLength / BYTES_PER_ELEMENT);
Expand Down
4 changes: 4 additions & 0 deletions test/parallel/test-v8-deserialize-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ const v8 = require('v8');

process.on('warning', common.mustNotCall());
v8.deserialize(v8.serialize(Buffer.alloc(0)));
v8.deserialize(v8.serialize({a: new Int32Array(1024)}));

Check failure on line 8 in test/parallel/test-v8-deserialize-buffer.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

A space is required after '{'

Check failure on line 8 in test/parallel/test-v8-deserialize-buffer.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

A space is required before '}'
v8.deserialize(v8.serialize({b: new Int16Array(8192)}));

Check failure on line 9 in test/parallel/test-v8-deserialize-buffer.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

A space is required after '{'

Check failure on line 9 in test/parallel/test-v8-deserialize-buffer.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

A space is required before '}'
v8.deserialize(v8.serialize({c: new Uint32Array(1024)}));

Check failure on line 10 in test/parallel/test-v8-deserialize-buffer.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

A space is required after '{'

Check failure on line 10 in test/parallel/test-v8-deserialize-buffer.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

A space is required before '}'
v8.deserialize(v8.serialize({d: new Uint16Array(8192)}));

Check failure on line 11 in test/parallel/test-v8-deserialize-buffer.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

A space is required after '{'

Check failure on line 11 in test/parallel/test-v8-deserialize-buffer.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

A space is required before '}'

0 comments on commit 3d3950f

Please sign in to comment.