Skip to content

Commit 3f8b307

Browse files
cmbartschatjdiaz5513
authored andcommitted
fix(serialization): fix parse crash on null pointer dereference in resize (#107)
Fixes issue similar to #78 (perhaps same) where a sender doesn't set a text field in the source proto can cause a unexpected validation error on the receiver when parsing the proto message. What appears to happen is a null source pointer is dereferenced and the data is assigned to the destination pointer in the resize function.
1 parent 3cdf4b0 commit 3f8b307

File tree

1 file changed

+4
-0
lines changed
  • packages/capnp-ts/src/serialization/pointers

1 file changed

+4
-0
lines changed

packages/capnp-ts/src/serialization/pointers/struct.ts

+4
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ export function resize(dstSize: ObjectSize, s: Struct): void {
238238
srcContent.segment,
239239
srcContent.byteOffset + srcSize.dataByteLength + i * 8
240240
);
241+
if (isNull(srcPtr)) {
242+
// If source pointer is null, leave the destination pointer as default null.
243+
continue
244+
}
241245
const srcPtrTarget = followFars(srcPtr);
242246
const srcPtrContent = getContent(srcPtr);
243247
const dstPtr = new Pointer(

0 commit comments

Comments
 (0)