From 483b11e33d57d5d280bb05cc21c4abb8e5b73274 Mon Sep 17 00:00:00 2001 From: Bruno Kirschner Date: Wed, 12 Jul 2017 16:58:12 +0200 Subject: [PATCH] [Wrapper] Trims the result of Message#as_xml() from the total buffer length to the length of the generated xml string. --- src/message.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/message.rs b/src/message.rs index 95e4e53..7b8affa 100644 --- a/src/message.rs +++ b/src/message.rs @@ -327,7 +327,7 @@ impl Message { let rc = unsafe { nfq_snprintf_xml(buf_ptr, buf_len, self.nfad, xml_flags) }; if rc < 0 { panic!("nfq_snprintf_xml"); } // XXX see snprintf error codes - match std::str::from_utf8(&buf) { + match std::str::from_utf8(&buf[..rc as usize]) { Ok(v) => Ok(v.to_string()), Err(e) => Err(e), }