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.
This commit is contained in:
Winni Neessen 2023-11-29 16:43:50 +01:00
parent 1a166770b7
commit a50a3ceb18
Signed by: wneessen
GPG key ID: 5F3AF39B820C119D

3
msg.go
View file

@ -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 {