mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 18:24:35 +03:00
add message size consistency check
the bulk of a message is stored on disk. a message prefix is stored in the database (for prefixed headers like "Received:"). this adds a check to ensure Size = prefix length + on-disk file size. verifydata also checks for this now. and one older and one new (since yesterday) bug was found. the first when appending a message without a header/body section (uncommon). the second when sending messages from webmail with localserve (uncommon).
This commit is contained in:
@ -404,6 +404,7 @@ func TestSpam(t *testing.T) {
|
||||
MsgFromValidated: true,
|
||||
MsgFromValidation: store.ValidationStrict,
|
||||
Flags: store.Flags{Seen: true, Junk: true},
|
||||
Size: int64(len(deliverMessage)),
|
||||
}
|
||||
for i := 0; i < 3; i++ {
|
||||
nm := m
|
||||
@ -503,6 +504,7 @@ func TestDMARCSent(t *testing.T) {
|
||||
RcptToLocalpart: smtp.Localpart("mjl"),
|
||||
RcptToDomain: "mox.example",
|
||||
Flags: store.Flags{Seen: true, Junk: true},
|
||||
Size: int64(len(deliverMessage)),
|
||||
}
|
||||
for i := 0; i < 3; i++ {
|
||||
nm := m
|
||||
@ -524,7 +526,7 @@ func TestDMARCSent(t *testing.T) {
|
||||
})
|
||||
|
||||
// Insert a message that we sent to the address that is about to send to us.
|
||||
var sentMsg store.Message
|
||||
sentMsg := store.Message{Size: int64(len(deliverMessage))}
|
||||
tinsertmsg(t, ts.acc, "Sent", &sentMsg, deliverMessage)
|
||||
err := ts.acc.DB.Insert(ctxbg, &store.Recipient{MessageID: sentMsg.ID, Localpart: "remote", Domain: "example.org", OrgDomain: "example.org", Sent: time.Now()})
|
||||
tcheck(t, err, "inserting message recipient")
|
||||
|
Reference in New Issue
Block a user