summaryrefslogtreecommitdiffstats
path: root/imap/imap.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2019-09-30 18:50:27 -0700
committerKevin McCarthy <kevin@8t8.us>2019-09-30 19:01:59 -0700
commita6bccbe1d1b731e69b2b609278ef0811d547a6e7 (patch)
treeb949e1bddce29d8dfb43da6d12f06b57e6fae54e /imap/imap.c
parentfb1686b66f028e0c844b3bb828c2882a3b8c0673 (diff)
Memcpy header cache fetch values to ensure alignment.
While testing the hcache buffer pool changes, I noticed a misaligned pointer warning when using LMDB. The other header cache backends must ensure alignment of the pointer they return, but LMDB apparently does not. Instead of directly assigning and dereferencing the pointer fetched, use memcpy to the appropriate type, just as the header cache restore operation does.
Diffstat (limited to 'imap/imap.c')
-rw-r--r--imap/imap.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/imap/imap.c b/imap/imap.c
index ccba3a38..33469f5f 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -1800,9 +1800,9 @@ IMAP_STATUS* imap_mboxcache_get (IMAP_DATA* idata, const char* mbox, int create)
IMAP_STATUS scache;
#ifdef USE_HCACHE
header_cache_t *hc = NULL;
- unsigned int *uidvalidity = NULL;
- unsigned int *uidnext = NULL;
- unsigned long long *modseq = NULL;
+ void *puidvalidity = NULL;
+ void *puidnext = NULL;
+ void *pmodseq = NULL;
#endif
for (cur = idata->mboxcache; cur; cur = cur->next)
@@ -1829,28 +1829,36 @@ IMAP_STATUS* imap_mboxcache_get (IMAP_DATA* idata, const char* mbox, int create)
hc = imap_hcache_open (idata, mbox);
if (hc)
{
- uidvalidity = mutt_hcache_fetch_raw (hc, "/UIDVALIDITY", imap_hcache_keylen);
- uidnext = mutt_hcache_fetch_raw (hc, "/UIDNEXT", imap_hcache_keylen);
- modseq = mutt_hcache_fetch_raw (hc, "/MODSEQ", imap_hcache_keylen);
- if (uidvalidity)
+ puidvalidity = mutt_hcache_fetch_raw (hc, "/UIDVALIDITY", imap_hcache_keylen);
+ puidnext = mutt_hcache_fetch_raw (hc, "/UIDNEXT", imap_hcache_keylen);
+ pmodseq = mutt_hcache_fetch_raw (hc, "/MODSEQ", imap_hcache_keylen);
+ if (puidvalidity)
{
if (!status)
{
- mutt_hcache_free ((void **)&uidvalidity);
- mutt_hcache_free ((void **)&uidnext);
- mutt_hcache_free ((void **)&modseq);
+ mutt_hcache_free ((void **)&puidvalidity);
+ mutt_hcache_free ((void **)&puidnext);
+ mutt_hcache_free ((void **)&pmodseq);
mutt_hcache_close (hc);
return imap_mboxcache_get (idata, mbox, 1);
}
- status->uidvalidity = *uidvalidity;
- status->uidnext = uidnext ? *uidnext: 0;
- status->modseq = modseq ? *modseq: 0;
+ memcpy (&status->uidvalidity, puidvalidity, sizeof(unsigned int));
+
+ if (puidnext)
+ memcpy (&status->uidnext, puidnext, sizeof(unsigned int));
+ else
+ status->uidnext = 0;
+
+ if (pmodseq)
+ memcpy (&status->modseq, pmodseq, sizeof(unsigned long long));
+ else
+ status->modseq = 0;
dprint (3, (debugfile, "mboxcache: hcache uidvalidity %u, uidnext %u, modseq %llu\n",
status->uidvalidity, status->uidnext, status->modseq));
}
- mutt_hcache_free ((void **)&uidvalidity);
- mutt_hcache_free ((void **)&uidnext);
- mutt_hcache_free ((void **)&modseq);
+ mutt_hcache_free ((void **)&puidvalidity);
+ mutt_hcache_free ((void **)&puidnext);
+ mutt_hcache_free ((void **)&pmodseq);
mutt_hcache_close (hc);
}
#endif