From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 9FD291FF13A for ; Wed, 10 Jun 2026 16:56:07 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 687591267C; Wed, 10 Jun 2026 16:56:07 +0200 (CEST) Message-ID: <1726dc87-cc28-48b5-a86d-6182a8584b78@proxmox.com> Date: Wed, 10 Jun 2026 16:56:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: applied: [PATCH log-tracker] handle smtp filter message: prevent panicking with non-standard output To: Dominik Csapak , pmg-devel@lists.proxmox.com References: <20260610131513.2907268-1-d.csapak@proxmox.com> Content-Language: en-US, de-DE From: Thomas Lamprecht In-Reply-To: <20260610131513.2907268-1-d.csapak@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1781103317093 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.005 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: BL6VJHTVVUWDMO4PUBWVZWMZVPJGLUJX X-Message-ID-Hash: BL6VJHTVVUWDMO4PUBWVZWMZVPJGLUJX X-MailFrom: t.lamprecht@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 10/06/2026 15:15, Dominik Csapak wrote: > Currently a custom checkscript can print it's output into the syslog > under the guise of the pmg-smtp-filter unit, so it will picked up > by the log tracker. In case there is a line with a delimiter and nothing > after it, every thing before is detected as a qid but the remaining > message only contains the delimiter. > > Prevent the panicking here by checking its length beforehand. > > While the real fix is either to prevent custom check scripts to output > to syslog, or to prefix it with something we can filter away here, > protecting against malformed output still makes sense. ack, and in fact it shouldn't be to hard to address that there too, but yeah the log-tracker panicking is not great in any case. > > Signed-off-by: Dominik Csapak > --- > src/main.rs | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/src/main.rs b/src/main.rs > index efdfd30..4787a36 100644 > --- a/src/main.rs > +++ b/src/main.rs > @@ -115,6 +115,11 @@ fn handle_pmg_smtp_filter_message(msg: &[u8], parser: &mut Parser, complete_line > Some((q, m)) => (q, m), > None => return, > }; > + if data.len() < 2 { > + // after the QID there is no separator and space, so it can't be a proper smtp-filter > + // message. It's possibly output from a custom check script or a malformed log line. > + return; > + } > // skip ': ' following the QID > let data = &data[2..]; > For the record: Stoiko already applied this [0], I did a follow-up commit to catch the other sites by refactoring this into a helper [1]. [0]: https://git.proxmox.com/?p=pmg-log-tracker.git;a=commitdiff;h=93bdf686a90d834b23704edd05f308a4d812e81c [1]: https://git.proxmox.com/?p=pmg-log-tracker.git;a=commitdiff;h=d1231c2c9533fc42b39d98eca48994f0d4426552