Skip to content

Commit 720e66c

Browse files
Merge commit from fork
* NULL dereference and integer overflow in op_batch_msg handler CWE-476: added rsr_format NULL check before dereferencing fmt_length. CWE-190: replaced unchecked ULONG multiplication with 64-bit overflow guard using FB_UINT64 and UINT_MAX. * Use MAX_ULONG instead of UINT_MAX to match ULONG type of cstr_length
1 parent 1b827d9 commit 720e66c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/remote/protocol.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,12 @@ bool_t xdr_protocol(RemoteXdr* xdrs, PACKET* p)
911911
statement->rsr_batch_size = size = FB_ALIGN(statement->rsr_format->fmt_length, FB_ALIGNMENT);
912912
if (xdrs->x_op == XDR_DECODE)
913913
{
914-
b->p_batch_data.cstr_length = (count ? count : 1) * size;
914+
const ULONG safe_count = count ? count : 1;
915+
const FB_UINT64 product = (FB_UINT64)safe_count * size;
916+
if (product > MAX_ULONG)
917+
return P_FALSE(xdrs, p);
918+
919+
b->p_batch_data.cstr_length = (ULONG)product;
915920
b->p_batch_data.alloc(xdrs);
916921
}
917922

0 commit comments

Comments
 (0)