From 44eb0b903a82d1ef3cc4ec23135432c0af44c133 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Fri, 11 Jun 2021 10:03:06 +0100 Subject: [PATCH] smtpsrv: Quote unknown commands for debugging When we receive unknown commands, we use the first 6 bytes for troubleshooting (e.g. put them in traces and exported metrics). While this is safe, since the different places know how to quote them properly, it makes things more difficult to analyse, since it's not uncommon to see be binary blobs. This patch makes us use the ascii-quoted version instead, to make things easier to analyze. --- internal/smtpsrv/conn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/smtpsrv/conn.go b/internal/smtpsrv/conn.go index f3d76cb..3397331 100644 --- a/internal/smtpsrv/conn.go +++ b/internal/smtpsrv/conn.go @@ -278,7 +278,7 @@ loop: default: // Sanitize it a bit to avoid filling the logs and events with // noisy data. Keep the first 6 bytes for debugging. - cmd = fmt.Sprintf("unknown<%.6s>", cmd) + cmd = fmt.Sprintf("unknown<%.6q>", cmd) code = 500 msg = "5.5.1 Unknown command" }