From d4008a650809bee7676ff8a781437c2195e1e87b Mon Sep 17 00:00:00 2001 From: Shivani Bhardwaj Date: Wed, 14 Jan 2026 16:04:33 +0530 Subject: [PATCH] dcerpc: remove bad tests Unittests test_parse_bind_pdu_infinite_loop and test_parse_bindack_pdu_infinite_loop seem to have artificially made up header which does not hold up to the strict calculations enforced by the parser now. Their headers mark the fraglens as 64 and 72 respectively which are not enough to hold the kind of bind(ack) items that are expected. It worked so far as the parser passed the entire input slice around but with the bugfix for issue 7546, the input passed around is strictly restricted to the fraglen parsed in the header. Bug 7546 --- rust/src/dcerpc/dcerpc.rs | 41 +-------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/rust/src/dcerpc/dcerpc.rs b/rust/src/dcerpc/dcerpc.rs index af91fbe827..ff69522d39 100644 --- a/rust/src/dcerpc/dcerpc.rs +++ b/rust/src/dcerpc/dcerpc.rs @@ -558,6 +558,7 @@ impl DCERPCState { for i in 0..numctxitems { retval = self.handle_bindctxitem(&input[idx as usize..], i as u16, hdr); if retval == -1 { + SCLogDebug!("Error handling BindCtxItem"); return -1; } idx += retval; @@ -1721,46 +1722,6 @@ mod tests { } } - #[test] - // Check for endless loop with bind PDUs (Imported from C code) - pub fn test_parse_bind_pdu_infinite_loop() { - let bindbuf: &[u8] = &[ - 0x05, 0x00, 0x0b, 0x03, 0x10, 0x00, 0x00, 0x00, 0x4A, 0x00, 0x00, 0x00, 0x7f, 0x00, - 0x00, 0x00, 0xd0, 0x16, 0xd0, 0x16, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x00, 0x04, 0x5d, 0x88, 0x8a, - 0xeb, 0x1c, 0xc9, 0x11, 0x9f, 0xe8, 0x08, 0x00, 0x2b, 0x10, 0x48, 0x60, 0x02, 0x00, - 0x00, 0x00, 0x02, 0x00, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x01, 0x02, 0x03, 0x04, 0xFF, /* ka boom - endless loop */ - ]; - let mut dcerpc_state = DCERPCState::new(); - assert_eq!( - AppLayerResult::ok(), - dcerpc_state.handle_input_data(StreamSlice::from_slice(bindbuf, STREAM_TOSERVER, 0), Direction::ToServer) - ); - } - - #[test] - // Check for endless loop with bind_ack PDUs (Imported from C code) - pub fn test_parse_bindack_pdu_infinite_loop() { - let bind_ack: &[u8] = &[ - 0x05, 0x00, 0x0c, 0x03, 0x10, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7f, 0x00, - 0x00, 0x00, 0xd0, 0x16, 0xd0, 0x16, 0xfd, 0x04, 0x01, 0x00, 0x04, 0x00, 0x31, 0x33, - 0x35, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x5d, - 0x88, 0x8a, 0xeb, 0x1c, 0xc9, 0x11, 0x9f, 0xe8, 0x08, 0x00, 0x2b, 0x10, 0x48, 0x60, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x5d, 0x88, 0x8a, 0xeb, 0x1c, - 0xc9, 0x11, 0x9f, 0xe8, 0x08, 0x00, 0x2b, 0x10, 0x48, 0x60, 0x01, 0x02, 0x03, 0x04, - 0xFF, - ]; - let mut dcerpc_state = DCERPCState::new(); - assert_eq!( - AppLayerResult::ok(), - dcerpc_state.handle_input_data(StreamSlice::from_slice(bind_ack, STREAM_TOSERVER, 0), Direction::ToServer) - ); - } - #[test] // Check for correct internal ids for bind_acks pub fn test_parse_bindack_internal_ids() {