From cdb02a2779ed7bfb59cf6d04891fb09c3c314e8d Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Mon, 27 Apr 2026 18:05:05 +0200 Subject: [PATCH] rust/dns: rustfmt --- .github/workflows/builds.yml | 1 + rust/src/dns/detect.rs | 4 +++- rust/src/dns/dns.rs | 12 +++--------- rust/src/dns/lua.rs | 3 +-- rust/src/dns/parser.rs | 3 ++- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 6b3dcf5cea..2f58b6d273 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -383,6 +383,7 @@ jobs: working-directory: rust/sys - run: cargo fmt --check working-directory: rust/derive + - run: rustfmt --check rust/src/dns/*.rs - name: Check if Cargo.lock.in is up to date run: | cp rust/Cargo.lock rust/Cargo.lock.in diff --git a/rust/src/dns/detect.rs b/rust/src/dns/detect.rs index 81a7b8bab9..79defe86e2 100644 --- a/rust/src/dns/detect.rs +++ b/rust/src/dns/detect.rs @@ -173,7 +173,9 @@ unsafe extern "C" fn dns_opcode_free(_de: *mut DetectEngineCtx, ctx: *mut c_void SCDetectU8Free(ctx); } -unsafe extern "C" fn dns_rcode_parse(ustr: *const std::os::raw::c_char) -> *mut DetectUintData { +unsafe extern "C" fn dns_rcode_parse( + ustr: *const std::os::raw::c_char, +) -> *mut DetectUintData { let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe if let Ok(s) = ft_name.to_str() { if let Some(ctx) = detect_parse_uint_enum::(s) { diff --git a/rust/src/dns/dns.rs b/rust/src/dns/dns.rs index 13e04c2e13..f0cb041e68 100644 --- a/rust/src/dns/dns.rs +++ b/rust/src/dns/dns.rs @@ -637,9 +637,7 @@ impl DNSState { } } - pub(crate) fn parse_request_udp( - &mut self, flow: *mut Flow, stream_slice: StreamSlice, - ) -> bool { + pub(crate) fn parse_request_udp(&mut self, flow: *mut Flow, stream_slice: StreamSlice) -> bool { let input = stream_slice.as_slice(); let frame = Frame::new( flow, @@ -701,9 +699,7 @@ impl DNSState { /// prefix. /// /// Returns the number of messages parsed. - fn parse_request_tcp( - &mut self, flow: *mut Flow, stream_slice: StreamSlice, - ) -> AppLayerResult { + fn parse_request_tcp(&mut self, flow: *mut Flow, stream_slice: StreamSlice) -> AppLayerResult { let input = stream_slice.as_slice(); if self.gap { let (is_dns, _, is_incomplete) = probe_tcp(input); @@ -765,9 +761,7 @@ impl DNSState { /// prefix. /// /// Returns the number of messages parsed. - fn parse_response_tcp( - &mut self, flow: *mut Flow, stream_slice: StreamSlice, - ) -> AppLayerResult { + fn parse_response_tcp(&mut self, flow: *mut Flow, stream_slice: StreamSlice) -> AppLayerResult { let input = stream_slice.as_slice(); if self.gap { let (is_dns, _, is_incomplete) = probe_tcp(input); diff --git a/rust/src/dns/lua.rs b/rust/src/dns/lua.rs index 802a66d38e..bba1cbbfd7 100644 --- a/rust/src/dns/lua.rs +++ b/rust/src/dns/lua.rs @@ -174,8 +174,7 @@ pub extern "C" fn SCDnsLuaGetAnswerTable(clua: &mut CLuaState, tx: &mut DNSTrans lua.settable(-3); } } - DNSRData::NULL(ref bytes) - | DNSRData::Unknown(ref bytes) => { + DNSRData::NULL(ref bytes) | DNSRData::Unknown(ref bytes) => { if !bytes.is_empty() { lua.pushstring("addr"); lua.pushstring(&String::from_utf8_lossy(bytes)); diff --git a/rust/src/dns/parser.rs b/rust/src/dns/parser.rs index 52e0bd0988..8fcd7b559e 100644 --- a/rust/src/dns/parser.rs +++ b/rust/src/dns/parser.rs @@ -440,7 +440,8 @@ pub fn dns_parse_body<'a>( let (i, queries) = count( |b| dns_parse_query(b, message, &mut flags), header.questions as usize, - ).parse(i)?; + ) + .parse(i)?; let (i, answers) = dns_parse_answer(i, message, header.answer_rr as usize, &mut flags)?; let mut invalid_authorities = false;