diff options
author | Kevin McCarthy <kevin@8t8.us> | 2019-09-30 18:50:27 -0700 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2019-09-30 19:01:59 -0700 |
commit | a6bccbe1d1b731e69b2b609278ef0811d547a6e7 (patch) | |
tree | b949e1bddce29d8dfb43da6d12f06b57e6fae54e /imap/message.c | |
parent | fb1686b66f028e0c844b3bb828c2882a3b8c0673 (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/message.c')
-rw-r--r-- | imap/message.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/imap/message.c b/imap/message.c index f32f5db6..48dc0437 100644 --- a/imap/message.c +++ b/imap/message.c @@ -228,14 +228,15 @@ int imap_read_headers (IMAP_DATA* idata, unsigned int msn_begin, unsigned int ms int evalhc = 0; #if USE_HCACHE - unsigned int *uid_validity = NULL; - unsigned int *puidnext = NULL; + void *puid_validity = NULL; + unsigned int uid_validity = 0; + void *puidnext = NULL; unsigned int uidnext = 0; int has_condstore = 0; int has_qresync = 0; int eval_condstore = 0; int eval_qresync = 0; - unsigned long long *pmodseq = NULL; + void *pmodseq = NULL; unsigned long long hc_modseq = 0; char *uid_seqset = NULL; #endif /* USE_HCACHE */ @@ -257,11 +258,13 @@ int imap_read_headers (IMAP_DATA* idata, unsigned int msn_begin, unsigned int ms if (idata->hcache && initial_download) { - uid_validity = mutt_hcache_fetch_raw (idata->hcache, "/UIDVALIDITY", imap_hcache_keylen); + puid_validity = mutt_hcache_fetch_raw (idata->hcache, "/UIDVALIDITY", imap_hcache_keylen); + if (puid_validity) + memcpy (&uid_validity, puid_validity, sizeof(unsigned int)); puidnext = mutt_hcache_fetch_raw (idata->hcache, "/UIDNEXT", imap_hcache_keylen); if (puidnext) { - uidnext = *puidnext; + memcpy (&uidnext, puidnext, sizeof(unsigned int));; mutt_hcache_free ((void **)&puidnext); } @@ -278,13 +281,13 @@ int imap_read_headers (IMAP_DATA* idata, unsigned int msn_begin, unsigned int ms has_qresync = 1; } - if (uid_validity && uidnext && *uid_validity == idata->uid_validity) + if (puid_validity && uidnext && (uid_validity == idata->uid_validity)) { evalhc = 1; pmodseq = mutt_hcache_fetch_raw (idata->hcache, "/MODSEQ", imap_hcache_keylen); if (pmodseq) { - hc_modseq = *pmodseq; + memcpy (&hc_modseq, pmodseq, sizeof(unsigned long long));; mutt_hcache_free ((void **)&pmodseq); } if (hc_modseq) @@ -300,7 +303,7 @@ int imap_read_headers (IMAP_DATA* idata, unsigned int msn_begin, unsigned int ms eval_condstore = 1; } } - mutt_hcache_free ((void **)&uid_validity); + mutt_hcache_free ((void **)&puid_validity); } if (evalhc) { |