From dd76914d002b07b6a0e8b2efa97c34bb388606a9 Mon Sep 17 00:00:00 2001 From: Mira Limbeck Date: Fri, 15 May 2020 16:49:04 +0200 Subject: [PATCH] make QID parsing more robust 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 --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 64f3e47..7e7d746 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2126,8 +2126,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.39.5