aboutsummaryrefslogtreecommitdiffstats
path: root/worker
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2024-01-19 21:54:02 +0100
committerRobin Jarry <robin@jarry.cc>2024-01-20 00:29:19 +0100
commit635f1fb49920e807c38f7a61c062c48879634c6c (patch)
tree9a56dfe82e07f0a32d3a9924a7f2307247acef0a /worker
parent65c0fb7820e1046ad3cbe012e1a291a9f6c4d224 (diff)
downloadaerc-635f1fb49920e807c38f7a61c062c48879634c6c.tar.gz
jmap: avoid crash when server returns garbage
For some reason, a JMAP server may send message details with empty blobId values. This is invalid but it should not cause a crash. Error: runtime error: slice bounds out of range [-2:] goroutine 16 [running]: git.sr.ht/~rjarry/aerc/worker/jmap/cache.(*JMAPCache).blobPath() git.sr.ht/~rjarry/aerc/worker/jmap/cache/blob.go:43 +0x95 git.sr.ht/~rjarry/aerc/worker/jmap/cache.(*JMAPCache).GetBlob() git.sr.ht/~rjarry/aerc/worker/jmap/cache/blob.go:11 +0x18 git.sr.ht/~rjarry/aerc/worker/jmap.(*JMAPWorker).handleFetchMessageBodyPart() git.sr.ht/~rjarry/aerc/worker/jmap/fetch.go:116 +0x26f git.sr.ht/~rjarry/aerc/worker/jmap.(*JMAPWorker).handleMessage() git.sr.ht/~rjarry/aerc/worker/jmap/worker.go:142 +0x25f git.sr.ht/~rjarry/aerc/worker/jmap.(*JMAPWorker).Run() git.sr.ht/~rjarry/aerc/worker/jmap/worker.go:177 +0x105 git.sr.ht/~rjarry/aerc/app.NewAccountView.func3() git.sr.ht/~rjarry/aerc/app/account.go:105 +0x57 created by git.sr.ht/~rjarry/aerc/app.NewAccountView in goroutine 1 git.sr.ht/~rjarry/aerc/app/account.go:98 +0x468 Ignore a blobId when it is an empty string. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io>
Diffstat (limited to 'worker')
-rw-r--r--worker/jmap/cache/blob.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/worker/jmap/cache/blob.go b/worker/jmap/cache/blob.go
index 2a239835..e704f2c6 100644
--- a/worker/jmap/cache/blob.go
+++ b/worker/jmap/cache/blob.go
@@ -36,7 +36,7 @@ func (c *JMAPCache) DeleteBlob(id jmap.ID) error {
}
func (c *JMAPCache) blobPath(id jmap.ID) string {
- if c.blobsDir == "" {
+ if c.blobsDir == "" || id == "" {
return ""
}
name := string(id)