mirror of
https://github.com/mjl-/mox.git
synced 2025-06-28 01:48:15 +03:00
In imapserver with RENAME of Inbox, we didn't check for the metadata quota.
Rename of Inbox is special, it copies the mailbox including metadata.
This commit is contained in:
parent
f5b67b5d3d
commit
bc50c3bf7f
@ -283,25 +283,7 @@ func (c *conn) cmdSetmetadata(tag, cmd string, p *parser) {
|
|||||||
xcheckf(err, "updating metadata annotation")
|
xcheckf(err, "updating metadata annotation")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for total size. We allow a total of 1000 entries, with total capacity of 1MB.
|
c.xcheckMetadataSize(tx)
|
||||||
// ../rfc/5464:383
|
|
||||||
var n int
|
|
||||||
var size int
|
|
||||||
err := bstore.QueryTx[store.Annotation](tx).ForEach(func(a store.Annotation) error {
|
|
||||||
n++
|
|
||||||
if n > metadataMaxKeys {
|
|
||||||
// ../rfc/5464:590
|
|
||||||
xusercodeErrorf("METADATA TOOMANY", "too many metadata entries, 1000 allowed in total")
|
|
||||||
}
|
|
||||||
size += len(a.Key) + len(a.Value)
|
|
||||||
if size > metadataMaxSize {
|
|
||||||
// ../rfc/5464:585 We only have a max total size limit, not per entry. We'll
|
|
||||||
// mention the max total size.
|
|
||||||
xusercodeErrorf(fmt.Sprintf("METADATA MAXSIZE %d", metadataMaxSize), "metadata entry values too large, total maximum size is 1MB")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
xcheckf(err, "checking metadata annotation size")
|
|
||||||
|
|
||||||
// ../rfc/7162:1335
|
// ../rfc/7162:1335
|
||||||
if mb.ID != 0 && modseq != 0 {
|
if mb.ID != 0 && modseq != 0 {
|
||||||
@ -316,3 +298,25 @@ func (c *conn) cmdSetmetadata(tag, cmd string, p *parser) {
|
|||||||
|
|
||||||
c.ok(tag, cmd)
|
c.ok(tag, cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *conn) xcheckMetadataSize(tx *bstore.Tx) {
|
||||||
|
// Check for total size. We allow a total of 1000 entries, with total capacity of 1MB.
|
||||||
|
// ../rfc/5464:383
|
||||||
|
var n int
|
||||||
|
var size int
|
||||||
|
err := bstore.QueryTx[store.Annotation](tx).ForEach(func(a store.Annotation) error {
|
||||||
|
n++
|
||||||
|
if n > metadataMaxKeys {
|
||||||
|
// ../rfc/5464:590
|
||||||
|
xusercodeErrorf("METADATA TOOMANY", "too many metadata entries, 1000 allowed in total")
|
||||||
|
}
|
||||||
|
size += len(a.Key) + len(a.Value)
|
||||||
|
if size > metadataMaxSize {
|
||||||
|
// ../rfc/5464:585 We only have a max total size limit, not per entry. We'll
|
||||||
|
// mention the max total size.
|
||||||
|
xusercodeErrorf(fmt.Sprintf("METADATA MAXSIZE %d", metadataMaxSize), "metadata entry values too large, total maximum size is 1MB")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
xcheckf(err, "checking metadata annotation size")
|
||||||
|
}
|
||||||
|
@ -3037,6 +3037,8 @@ func (c *conn) cmdRename(tag, cmd string, p *parser) {
|
|||||||
xcheckf(err, "copy annotation to destination mailbox")
|
xcheckf(err, "copy annotation to destination mailbox")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.xcheckMetadataSize(tx)
|
||||||
|
|
||||||
changes[0] = store.ChangeRemoveUIDs{MailboxID: srcMB.ID, UIDs: oldUIDs, ModSeq: modseq}
|
changes[0] = store.ChangeRemoveUIDs{MailboxID: srcMB.ID, UIDs: oldUIDs, ModSeq: modseq}
|
||||||
changes[1] = store.ChangeAddMailbox{Mailbox: dstMB, Flags: dstFlags, ModSeq: modseq}
|
changes[1] = store.ChangeAddMailbox{Mailbox: dstMB, Flags: dstFlags, ModSeq: modseq}
|
||||||
// changes[2:...] are ChangeAddUIDs
|
// changes[2:...] are ChangeAddUIDs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user