]> git.proxmox.com Git - pmg-log-tracker.git/commitdiff
make QID parsing more robust
authorMira Limbeck <m.limbeck@proxmox.com>
Fri, 15 May 2020 14:49:04 +0000 (16:49 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 18 May 2020 12:24:54 +0000 (14:24 +0200)
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@proxmox.com>
src/main.rs

index 64f3e47e5ad413106419899bf9d2dd871b231b80..7e7d746946526b1c0c809979e57bb34242f274a0 100644 (file)
@@ -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