Skip to content

Commit 74a5252

Browse files
committed
fix(svc): add bounds check before memcpy/strncpy in dump_pool_info handler
When processing isc_info_svc_dump_pool_info, the SPB clumplet's declared length (length2) comes from the network and is only validated against the destination buffer (fname). However, the source pointer (items) is not checked against the SPB buffer end (end_items/end_items2). An attacker with service API access can craft an SPB where the clumplet length claims more data than the remaining buffer, causing memcpy or strncpy to read past the SPB buffer boundary. Add bounds checks in both Service::query() and Service::query2() to set length2 to zero when the declared length would exceed the buffer.
1 parent f0b0d0c commit 74a5252

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/jrd/svc.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,10 @@ ISC_STATUS Service::query2(thread_db* /*tdbb*/,
12571257
if (length2 >= sizeof(fname))
12581258
length2 = sizeof(fname) - 1; // truncation
12591259
items += sizeof(USHORT);
1260+
1261+
if (items >= end_items || items + length2 > end_items)
1262+
length2 = 0;
1263+
12601264
strncpy(fname, (const char*) items, length2);
12611265
fname[length2] = 0;
12621266
break;
@@ -1711,6 +1715,10 @@ void Service::query(USHORT send_item_length,
17111715
if (length2 >= sizeof(fname))
17121716
length2 = sizeof(fname) - 1; // truncation
17131717
items += sizeof(USHORT);
1718+
1719+
if (items >= end_items2 || items + length2 > end_items2)
1720+
length2 = 0;
1721+
17141722
memcpy(fname, items, length2);
17151723
fname[length2] = 0;
17161724
break;

0 commit comments

Comments
 (0)