mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
Fix non-constant format string in calls to Printf-like functions
In a few places, we call Printf-like functions, but for the format we
use either non-format messages (which is not tidy, but okay), or
variable messages (which can be problematic if they contain %-format
directives).
The patch fixes the calls by either moving to Print-like functions, or
using `Printf("%s", message)` instead.
These were found by a combination of `go vet` (which complains about
"non-constant format string in call"), and manual inspection.
This commit is contained in:
@@ -97,8 +97,8 @@ func (l *Logger) Auth(netAddr net.Addr, user string, successful bool) {
|
|||||||
res = "failed"
|
res = "failed"
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("%s auth %s for %s\n", netAddr, res, user)
|
msg := fmt.Sprintf("%s auth %s for %s\n", netAddr, res, user)
|
||||||
l.printf(msg)
|
l.printf("%s", msg)
|
||||||
authLog.Debugf(msg)
|
authLog.Debugf("%s", msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rejected logs that we've rejected an email.
|
// Rejected logs that we've rejected an email.
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ func (tr *trace) Printf(format string, a ...interface{}) {
|
|||||||
func (tr *trace) Errorf(format string, a ...interface{}) error {
|
func (tr *trace) Errorf(format string, a ...interface{}) error {
|
||||||
tr.SetError()
|
tr.SetError()
|
||||||
err := fmt.Errorf(format, a...)
|
err := fmt.Errorf(format, a...)
|
||||||
tr.Printf(err.Error())
|
tr.Printf("%s", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -378,18 +378,18 @@ func (c *Conn) EHLO(params string) (code int, msg string) {
|
|||||||
c.isESMTP = true
|
c.isESMTP = true
|
||||||
|
|
||||||
buf := bytes.NewBuffer(nil)
|
buf := bytes.NewBuffer(nil)
|
||||||
fmt.Fprintf(buf, c.hostname+" - Your hour of destiny has come.\n")
|
fmt.Fprint(buf, c.hostname+" - Your hour of destiny has come.\n")
|
||||||
fmt.Fprintf(buf, "8BITMIME\n")
|
fmt.Fprint(buf, "8BITMIME\n")
|
||||||
fmt.Fprintf(buf, "PIPELINING\n")
|
fmt.Fprint(buf, "PIPELINING\n")
|
||||||
fmt.Fprintf(buf, "SMTPUTF8\n")
|
fmt.Fprint(buf, "SMTPUTF8\n")
|
||||||
fmt.Fprintf(buf, "ENHANCEDSTATUSCODES\n")
|
fmt.Fprint(buf, "ENHANCEDSTATUSCODES\n")
|
||||||
fmt.Fprintf(buf, "SIZE %d\n", c.maxDataSize)
|
fmt.Fprintf(buf, "SIZE %d\n", c.maxDataSize)
|
||||||
if c.onTLS {
|
if c.onTLS {
|
||||||
fmt.Fprintf(buf, "AUTH PLAIN\n")
|
fmt.Fprint(buf, "AUTH PLAIN\n")
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(buf, "STARTTLS\n")
|
fmt.Fprint(buf, "STARTTLS\n")
|
||||||
}
|
}
|
||||||
fmt.Fprintf(buf, "HELP\n")
|
fmt.Fprint(buf, "HELP\n")
|
||||||
return 250, buf.String()
|
return 250, buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func fuzzConnection(t *testing.T, modeI int, data []byte) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = tconn.PrintfLine(line); err != nil {
|
if err = tconn.PrintfLine("%s", line); err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ func FuzzConnection(f *testing.F) {
|
|||||||
func exchangeData(scanner *bufio.Scanner, tconn *textproto.Conn) error {
|
func exchangeData(scanner *bufio.Scanner, tconn *textproto.Conn) error {
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
if err := tconn.PrintfLine(line); err != nil {
|
if err := tconn.PrintfLine("%s", line); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if line == "." {
|
if line == "." {
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ func TestTooMuchData(t *testing.T) {
|
|||||||
|
|
||||||
func simpleCmd(t *testing.T, c *smtp.Client, cmd string, expected int) string {
|
func simpleCmd(t *testing.T, c *smtp.Client, cmd string, expected int) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if err := c.Text.PrintfLine(cmd); err != nil {
|
if err := c.Text.PrintfLine("%s", cmd); err != nil {
|
||||||
t.Fatalf("Failed to write %s: %v", cmd, err)
|
t.Fatalf("Failed to write %s: %v", cmd, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user