Skip to content

Commit

Permalink
for localserve, validate the incoming message
Browse files Browse the repository at this point in the history
it must be completely parsable.
normally, if we receive a message that we cannot fully parse, we accept it and
treat it as opaque application/octet-stream.

also make it more clear that localserve accepts email intended for any email
address.
  • Loading branch information
mjl- committed Mar 12, 2023
1 parent 19ea0d9 commit 7681f8b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ automatically initialized with configuration files, an account with email
address mox@localhost and password moxmoxmox, and a newly generated self-signed
TLS certificate.
All incoming email is accepted (if checks pass), unless the recipient localpart
ends with:
All incoming email to any address is accepted (if checks pass), unless the
recipient localpart ends with:
- "temperror": fail with a temporary error code
- "permerror": fail with a permanent error code
Expand Down
6 changes: 3 additions & 3 deletions localserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ automatically initialized with configuration files, an account with email
address mox@localhost and password moxmoxmox, and a newly generated self-signed
TLS certificate.
All incoming email is accepted (if checks pass), unless the recipient localpart
ends with:
All incoming email to any address is accepted (if checks pass), unless the
recipient localpart ends with:
- "temperror": fail with a temporary error code
- "permerror": fail with a permanent error code
Expand Down Expand Up @@ -120,7 +120,7 @@ during those commands instead of during "data".
golog.Printf("the default admin password is moxadmin")
golog.Printf("port numbers are those common for the services + 1000")
golog.Printf("tls uses generated self-signed certificate %s", filepath.Join(dir, "localhost.crt"))
golog.Printf("all incoming email is accepted (if checks pass), unless the recipient localpart ends with:")
golog.Printf("all incoming email to any address is accepted (if checks pass), unless the recipient localpart ends with:")
golog.Print("")
golog.Printf(`- "temperror": fail with a temporary error code.`)
golog.Printf(`- "permerror": fail with a permanent error code.`)
Expand Down
12 changes: 12 additions & 0 deletions smtpserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,18 @@ func (c *conn) cmdData(p *parser) {
}
}

if Localserve {
// Require that message can be parsed fully.
p, err := message.Parse(dataFile)
if err == nil {
err = p.Walk(nil)
}
if err != nil {
// ../rfc/6409:541
xsmtpUserErrorf(smtp.C554TransactionFailed, smtp.SeMsg6Other0, "malformed message: %v", err)
}
}

// Prepare "Received" header.
// ../rfc/5321:2051 ../rfc/5321:3302
// ../rfc/5321:3311 ../rfc/6531:578
Expand Down

0 comments on commit 7681f8b

Please sign in to comment.