Skip to content

Commit 7ac126b

Browse files
JoostKtargos
authored andcommitted
src: fix out-of-bounds check of serialization indices
The usage of `CHECK_LE` to verify that the index is within bounds of a vector's size allows for reading one item past the vector's end, which is in invalid memory read. This commit fixes the off-by-one error by changing the bounds check to use `CHECK_LT`. PR-URL: #41452 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 5c0c459 commit 7ac126b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/node_messaging.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,19 @@ class DeserializerDelegate : public ValueDeserializer::Delegate {
9898
uint32_t id;
9999
if (!deserializer->ReadUint32(&id))
100100
return MaybeLocal<Object>();
101-
CHECK_LE(id, host_objects_.size());
101+
CHECK_LT(id, host_objects_.size());
102102
return host_objects_[id]->object(isolate);
103103
}
104104

105105
MaybeLocal<SharedArrayBuffer> GetSharedArrayBufferFromId(
106106
Isolate* isolate, uint32_t clone_id) override {
107-
CHECK_LE(clone_id, shared_array_buffers_.size());
107+
CHECK_LT(clone_id, shared_array_buffers_.size());
108108
return shared_array_buffers_[clone_id];
109109
}
110110

111111
MaybeLocal<WasmModuleObject> GetWasmModuleFromId(
112112
Isolate* isolate, uint32_t transfer_id) override {
113-
CHECK_LE(transfer_id, wasm_modules_.size());
113+
CHECK_LT(transfer_id, wasm_modules_.size());
114114
return WasmModuleObject::FromCompiledModule(
115115
isolate, wasm_modules_[transfer_id]);
116116
}

0 commit comments

Comments
 (0)