[pmg-devel] [PATCH pmg-log-tracker 1/3] make QID parsing more robust

Mira Limbeck m.limbeck at proxmox.com
Fri May 15 16:49:04 CEST 2020


As a user had the problem that 'fa' of 'fatal' matched for a QID,
increase the number of characters that have to match. The QID always has
at least 5 characters for the microseconds, so increase it to 5.

See http://www.postfix.org/postconf.5.html#enable_long_queue_ids

Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
---
 src/main.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 9e3883f..55e1516 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2124,8 +2124,10 @@ fn parse_qid(data: &[u8], max: usize) -> Option<(&[u8], &[u8])> {
     let max = max.min(data.len());
     // take at most max, find the first non-hex-digit
     match data.iter().take(max).position(|b| !b.is_ascii_hexdigit()) {
-        // if there were less than 2 return nothing
-        Some(n) if n < 2 => None,
+        // if there were less than 5 return nothing
+        // the QID always has at least 5 characters for the microseconds (see
+        // http://www.postfix.org/postconf.5.html#enable_long_queue_ids)
+        Some(n) if n < 5 => None,
         // otherwise split at the first non-hex-digit
         Some(n) => Some(data.split_at(n)),
         // or return 'max' length QID if no non-hex-digit is found
-- 
2.20.1




More information about the pmg-devel mailing list