fix unbounded read

This commit is contained in:
srevn 2025-07-06 17:53:04 +03:00
parent 9ed96e5d8b
commit 47da3aeea6

View file

@ -256,13 +256,13 @@ func parseTopicMessageCommand(c *cli.Context) (topic string, message string, com
message = c.String("message") message = c.String("message")
} }
if message == "" && isStdinRedirected() { if message == "" && isStdinRedirected() {
var bytes []byte var data []byte
bytes, err = io.ReadAll(c.App.Reader) data, err = io.ReadAll(io.LimitReader(c.App.Reader, 1024*1024))
if err != nil { if err != nil {
log.Debug("Failed to read from stdin: %s", err.Error()) log.Debug("Failed to read from stdin: %s", err.Error())
return return
} }
message = strings.TrimSpace(string(bytes)) message = strings.TrimSpace(string(data))
} }
return return
} }