* [PATCH log-tracker] handle smtp filter message: prevent panicking with non-standard output
@ 2026-06-10 13:15 Dominik Csapak
2026-06-10 13:51 ` Thomas Lamprecht
2026-06-10 14:56 ` applied: " Thomas Lamprecht
0 siblings, 2 replies; 4+ messages in thread
From: Dominik Csapak @ 2026-06-10 13:15 UTC (permalink / raw)
To: pmg-devel
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.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
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..];
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH log-tracker] handle smtp filter message: prevent panicking with non-standard output
2026-06-10 13:15 [PATCH log-tracker] handle smtp filter message: prevent panicking with non-standard output Dominik Csapak
@ 2026-06-10 13:51 ` Thomas Lamprecht
2026-06-10 14:00 ` Dominik Csapak
2026-06-10 14:56 ` applied: " Thomas Lamprecht
1 sibling, 1 reply; 4+ messages in thread
From: Thomas Lamprecht @ 2026-06-10 13:51 UTC (permalink / raw)
To: Dominik Csapak, pmg-devel
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.
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> 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.
this comment confuses me, reads like a separator and space after a QID
being wrong, but it's what's expected, with the &data[2..]; IMO no comment
would be required, but short one can be fine - will squash that in on applying.
> + return;
> + }
> // skip ': ' following the QID
> let data = &data[2..];
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH log-tracker] handle smtp filter message: prevent panicking with non-standard output
2026-06-10 13:51 ` Thomas Lamprecht
@ 2026-06-10 14:00 ` Dominik Csapak
0 siblings, 0 replies; 4+ messages in thread
From: Dominik Csapak @ 2026-06-10 14:00 UTC (permalink / raw)
To: Thomas Lamprecht, pmg-devel
On 6/10/26 3:51 PM, Thomas Lamprecht wrote:
> 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.
>>
>> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
>> ---
>> 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.
>
> this comment confuses me, reads like a separator and space after a QID
> being wrong, but it's what's expected, with the &data[2..]; IMO no comment
> would be required, but short one can be fine - will squash that in on applying.
ah ok sorry, i wanted to express that this is missing in this branch,
so after the length check shows it's shorter
>
>> + return;
>> + }
>> // skip ': ' following the QID
>> let data = &data[2..];
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* applied: [PATCH log-tracker] handle smtp filter message: prevent panicking with non-standard output
2026-06-10 13:15 [PATCH log-tracker] handle smtp filter message: prevent panicking with non-standard output Dominik Csapak
2026-06-10 13:51 ` Thomas Lamprecht
@ 2026-06-10 14:56 ` Thomas Lamprecht
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2026-06-10 14:56 UTC (permalink / raw)
To: Dominik Csapak, pmg-devel
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 <d.csapak@proxmox.com>
> ---
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-10 14:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-10 13:15 [PATCH log-tracker] handle smtp filter message: prevent panicking with non-standard output Dominik Csapak
2026-06-10 13:51 ` Thomas Lamprecht
2026-06-10 14:00 ` Dominik Csapak
2026-06-10 14:56 ` applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox