mutt stable branch with some hacks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

+49 -35
+24 -16
imap/imap.c
··· 1800 1800 IMAP_STATUS scache; 1801 1801 #ifdef USE_HCACHE 1802 1802 header_cache_t *hc = NULL; 1803 - unsigned int *uidvalidity = NULL; 1804 - unsigned int *uidnext = NULL; 1805 - unsigned long long *modseq = NULL; 1803 + void *puidvalidity = NULL; 1804 + void *puidnext = NULL; 1805 + void *pmodseq = NULL; 1806 1806 #endif 1807 1807 1808 1808 for (cur = idata->mboxcache; cur; cur = cur->next) ··· 1829 1829 hc = imap_hcache_open (idata, mbox); 1830 1830 if (hc) 1831 1831 { 1832 - uidvalidity = mutt_hcache_fetch_raw (hc, "/UIDVALIDITY", imap_hcache_keylen); 1833 - uidnext = mutt_hcache_fetch_raw (hc, "/UIDNEXT", imap_hcache_keylen); 1834 - modseq = mutt_hcache_fetch_raw (hc, "/MODSEQ", imap_hcache_keylen); 1835 - if (uidvalidity) 1832 + puidvalidity = mutt_hcache_fetch_raw (hc, "/UIDVALIDITY", imap_hcache_keylen); 1833 + puidnext = mutt_hcache_fetch_raw (hc, "/UIDNEXT", imap_hcache_keylen); 1834 + pmodseq = mutt_hcache_fetch_raw (hc, "/MODSEQ", imap_hcache_keylen); 1835 + if (puidvalidity) 1836 1836 { 1837 1837 if (!status) 1838 1838 { 1839 - mutt_hcache_free ((void **)&uidvalidity); 1840 - mutt_hcache_free ((void **)&uidnext); 1841 - mutt_hcache_free ((void **)&modseq); 1839 + mutt_hcache_free ((void **)&puidvalidity); 1840 + mutt_hcache_free ((void **)&puidnext); 1841 + mutt_hcache_free ((void **)&pmodseq); 1842 1842 mutt_hcache_close (hc); 1843 1843 return imap_mboxcache_get (idata, mbox, 1); 1844 1844 } 1845 - status->uidvalidity = *uidvalidity; 1846 - status->uidnext = uidnext ? *uidnext: 0; 1847 - status->modseq = modseq ? *modseq: 0; 1845 + memcpy (&status->uidvalidity, puidvalidity, sizeof(unsigned int)); 1846 + 1847 + if (puidnext) 1848 + memcpy (&status->uidnext, puidnext, sizeof(unsigned int)); 1849 + else 1850 + status->uidnext = 0; 1851 + 1852 + if (pmodseq) 1853 + memcpy (&status->modseq, pmodseq, sizeof(unsigned long long)); 1854 + else 1855 + status->modseq = 0; 1848 1856 dprint (3, (debugfile, "mboxcache: hcache uidvalidity %u, uidnext %u, modseq %llu\n", 1849 1857 status->uidvalidity, status->uidnext, status->modseq)); 1850 1858 } 1851 - mutt_hcache_free ((void **)&uidvalidity); 1852 - mutt_hcache_free ((void **)&uidnext); 1853 - mutt_hcache_free ((void **)&modseq); 1859 + mutt_hcache_free ((void **)&puidvalidity); 1860 + mutt_hcache_free ((void **)&puidnext); 1861 + mutt_hcache_free ((void **)&pmodseq); 1854 1862 mutt_hcache_close (hc); 1855 1863 } 1856 1864 #endif
+11 -8
imap/message.c
··· 228 228 int evalhc = 0; 229 229 230 230 #if USE_HCACHE 231 - unsigned int *uid_validity = NULL; 232 - unsigned int *puidnext = NULL; 231 + void *puid_validity = NULL; 232 + unsigned int uid_validity = 0; 233 + void *puidnext = NULL; 233 234 unsigned int uidnext = 0; 234 235 int has_condstore = 0; 235 236 int has_qresync = 0; 236 237 int eval_condstore = 0; 237 238 int eval_qresync = 0; 238 - unsigned long long *pmodseq = NULL; 239 + void *pmodseq = NULL; 239 240 unsigned long long hc_modseq = 0; 240 241 char *uid_seqset = NULL; 241 242 #endif /* USE_HCACHE */ ··· 257 258 258 259 if (idata->hcache && initial_download) 259 260 { 260 - uid_validity = mutt_hcache_fetch_raw (idata->hcache, "/UIDVALIDITY", imap_hcache_keylen); 261 + puid_validity = mutt_hcache_fetch_raw (idata->hcache, "/UIDVALIDITY", imap_hcache_keylen); 262 + if (puid_validity) 263 + memcpy (&uid_validity, puid_validity, sizeof(unsigned int)); 261 264 puidnext = mutt_hcache_fetch_raw (idata->hcache, "/UIDNEXT", imap_hcache_keylen); 262 265 if (puidnext) 263 266 { 264 - uidnext = *puidnext; 267 + memcpy (&uidnext, puidnext, sizeof(unsigned int));; 265 268 mutt_hcache_free ((void **)&puidnext); 266 269 } 267 270 ··· 278 281 has_qresync = 1; 279 282 } 280 283 281 - if (uid_validity && uidnext && *uid_validity == idata->uid_validity) 284 + if (puid_validity && uidnext && (uid_validity == idata->uid_validity)) 282 285 { 283 286 evalhc = 1; 284 287 pmodseq = mutt_hcache_fetch_raw (idata->hcache, "/MODSEQ", imap_hcache_keylen); 285 288 if (pmodseq) 286 289 { 287 - hc_modseq = *pmodseq; 290 + memcpy (&hc_modseq, pmodseq, sizeof(unsigned long long));; 288 291 mutt_hcache_free ((void **)&pmodseq); 289 292 } 290 293 if (hc_modseq) ··· 300 303 eval_condstore = 1; 301 304 } 302 305 } 303 - mutt_hcache_free ((void **)&uid_validity); 306 + mutt_hcache_free ((void **)&puid_validity); 304 307 } 305 308 if (evalhc) 306 309 {
+10 -8
imap/util.c
··· 179 179 HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid) 180 180 { 181 181 char key[16]; 182 - unsigned int* uv; 182 + void *data; 183 + unsigned int uv; 183 184 HEADER* h = NULL; 184 185 185 186 if (!idata->hcache) 186 187 return NULL; 187 188 188 189 sprintf (key, "/%u", uid); 189 - uv = (unsigned int*)mutt_hcache_fetch (idata->hcache, key, 190 - imap_hcache_keylen); 191 - if (uv) 190 + data = mutt_hcache_fetch (idata->hcache, key, 191 + imap_hcache_keylen); 192 + if (data) 192 193 { 193 - if (*uv == idata->uid_validity) 194 - h = mutt_hcache_restore ((unsigned char*)uv, NULL); 194 + memcpy (&uv, data, sizeof(unsigned int)); 195 + if (uv == idata->uid_validity) 196 + h = mutt_hcache_restore ((unsigned char *)data, NULL); 195 197 else 196 - dprint (3, (debugfile, "hcache uidvalidity mismatch: %u", *uv)); 197 - mutt_hcache_free ((void **)&uv); 198 + dprint (3, (debugfile, "hcache uidvalidity mismatch: %u", uv)); 199 + mutt_hcache_free ((void **)&data); 198 200 } 199 201 200 202 return h;
+4 -3
mh.c
··· 1145 1145 #if USE_HCACHE 1146 1146 header_cache_t *hc = NULL; 1147 1147 void *data; 1148 - struct timeval *when = NULL; 1148 + struct timeval when; 1149 1149 struct stat lastchanged; 1150 1150 int ret; 1151 1151 #endif ··· 1207 1207 data = mutt_hcache_fetch (hc, p->h->path, strlen); 1208 1208 else 1209 1209 data = mutt_hcache_fetch (hc, p->h->path + 3, &maildir_hcache_keylen); 1210 - when = (struct timeval *) data; 1210 + if (data) 1211 + memcpy (&when, data, sizeof(struct timeval)); 1211 1212 1212 - if (data != NULL && !ret && lastchanged.st_mtime <= when->tv_sec) 1213 + if (data != NULL && !ret && lastchanged.st_mtime <= when.tv_sec) 1213 1214 { 1214 1215 p->h = mutt_hcache_restore ((unsigned char *)data, &p->h); 1215 1216 if (ctx->magic == MUTT_MAILDIR)