src: add aliased-buffer-overflow abort test · nodejs/node@0dfb951 · GitHub
Skip to content

Commit 0dfb951

Browse files
amdokutargos
authored andcommitted
src: add aliased-buffer-overflow abort test
Added native extension similar to test/addons/stringbytes-external-exceeded-max. Added an abort test to regression test the non overflow behaviour. PR-URL: #31740 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 28cfaa8 commit 0dfb951

4 files changed

Lines changed: 68 additions & 0 deletions

File tree

test/abort/common.gypi

Lines changed: 8 additions & 0 deletions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <stdlib.h>
2+
#include <node.h>
3+
#include <v8.h>
4+
5+
#include <aliased_buffer.h>
6+
#include <util-inl.h>
7+
8+
void AllocateAndResizeBuffer(
9+
const v8::FunctionCallbackInfo<v8::Value>& args) {
10+
v8::Isolate* isolate = args.GetIsolate();
11+
int64_t length = args[0].As<v8::BigInt>()->Int64Value();
12+
13+
node::AliasedBigUint64Array array{isolate, 0};
14+
15+
array.reserve(length);
16+
assert(false);
17+
}
18+
19+
void init(v8::Local<v8::Object> exports) {
20+
NODE_SET_METHOD(exports,
21+
"allocateAndResizeBuffer",
22+
AllocateAndResizeBuffer);
23+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
'targets': [
3+
{
4+
'target_name': 'binding',
5+
'sources': [ 'binding.cc' ],
6+
'includes': ['../common.gypi'],
7+
}
8+
]
9+
}
Lines changed: 28 additions & 0 deletions

0 commit comments

Comments
 (0)