From a50a3ceb18071e4c6424452a6a24b6be3cff596e Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Wed, 29 Nov 2023 16:43:50 +0100 Subject: [PATCH] Add validation for nil STDERR or STDIN pipe Introduced a new condition that checks and returns an error if either STDERR or STDIN pipe is nil in the msg function of msg.go. This improves error handling by preventing potential panic due to referencing a nil pipe. --- msg.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/msg.go b/msg.go index ab098f4..3797612 100644 --- a/msg.go +++ b/msg.go @@ -1001,6 +1001,9 @@ func (m *Msg) WriteToSendmailWithContext(ctx context.Context, sp string, a ...st if err != nil { return fmt.Errorf("failed to set STDIN pipe: %w", err) } + if se == nil || si == nil { + return fmt.Errorf("received nil for STDERR or STDIN pipe") + } // Start the execution and write to STDIN if err = ec.Start(); err != nil {