if ((frag_data != nullptr) && (seg_data != nullptr))
{
uint16_t hdr_size = sizeof(DceRpcCoHdr) + sizeof(DceRpcCoRequest);
-
- /* Need to just extract the stub data from the seg buffer
- * if there is enough data there */
- // FIXIT-L PORT_IF_NEEDED seg len check
- const DceRpcCoHdr* co_hdr = (const DceRpcCoHdr*)seg_data;
-
- /* Don't use it if it's not a request and therefore doesn't
- * belong with the frag data. This is an insanity check -
- * shouldn't have seg data that's not a request if there are
- * frags queued up */
- if (DceRpcCoPduType(co_hdr) != DCERPC_PDU_TYPE__REQUEST)
+ if (seg_len >= hdr_size)
{
- seg_data = nullptr;
- seg_len = 0;
+ /* Need to just extract the stub data from the seg buffer
+ * if there is enough data there */
+ const DceRpcCoHdr* co_hdr = (const DceRpcCoHdr*)seg_data;
+
+ /* Don't use it if it's not a request and therefore doesn't
+ * belong with the frag data. This is an insanity check -
+ * shouldn't have seg data that's not a request if there are
+ * frags queued up */
+ if (DceRpcCoPduType(co_hdr) != DCERPC_PDU_TYPE__REQUEST)
+ {
+ seg_data = nullptr;
+ seg_len = 0;
+ }
+ else
+ {
+ dce2_move(seg_data, seg_len, hdr_size);
+ }
}
else
{
- dce2_move(seg_data, seg_len, hdr_size);
+ seg_data = nullptr;
+ seg_len = 0;
}
}
{
uint16_t hdr_size = sizeof(DceRpcCoHdr) + sizeof(DceRpcCoRequest);
- // FIXIT-L PORT_IF_NEEDED header size check
- DceRpcCoHdr* co_hdr = (DceRpcCoHdr*)DCE2_BufferData(cot->cli_seg.buf);
-
- if (DceRpcCoPduType(co_hdr) == DCERPC_PDU_TYPE__REQUEST)
+ if (DCE2_BufferLength(cot->cli_seg.buf) >= hdr_size)
{
- seg_bytes = DCE2_BufferLength(cot->cli_seg.buf) - hdr_size;
+ DceRpcCoHdr* co_hdr = (DceRpcCoHdr*)DCE2_BufferData(cot->cli_seg.buf);
- if ((UINT32_MAX - bytes) < seg_bytes)
- seg_bytes = UINT32_MAX - bytes;
+ if (DceRpcCoPduType(co_hdr) == DCERPC_PDU_TYPE__REQUEST)
+ {
+ seg_bytes = DCE2_BufferLength(cot->cli_seg.buf) - hdr_size;
+
+ if ((UINT32_MAX - bytes) < seg_bytes)
+ seg_bytes = UINT32_MAX - bytes;
- bytes += seg_bytes;
+ bytes += seg_bytes;
+ }
}
}