From 303e33302709ee990ce7db091876d22ab2c5b24c Mon Sep 17 00:00:00 2001 From: Rocco Rutte Date: Mon, 1 Jun 2009 13:22:17 +0200 Subject: [PATCH] More atoi() fixes --- hcache.c | 10 ++++++++-- mh.c | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hcache.c b/hcache.c index 4bcaeb001..8b14aef1b 100644 --- a/hcache.c +++ b/hcache.c @@ -940,7 +940,10 @@ mutt_hcache_delete(header_cache_t *h, const char *filename, static int hcache_open_gdbm (struct header_cache* h, const char* path) { - int pagesize = atoi(HeaderCachePageSize) ? atoi(HeaderCachePageSize) : 16384; + int pagesize; + + if (mutt_atoi (HeaderCachePageSize, &pagesize) < 0 || pagesize <= 0) + pagesize = 16384; h->db = gdbm_open((char *) path, pagesize, GDBM_WRCREAT, 00600, NULL); if (h->db) @@ -1008,7 +1011,10 @@ hcache_open_db4 (struct header_cache* h, const char* path) struct stat sb; int ret; u_int32_t createflags = DB_CREATE; - int pagesize = atoi (HeaderCachePageSize); + int pagesize; + + if (mutt_atoi (HeaderCachePageSize, &pagesize) < 0 || pagesize <= 0) + pagesize = 16384; snprintf (h->lockfile, _POSIX_PATH_MAX, "%s-lock-hack", path); diff --git a/mh.c b/mh.c index 42b188378..ebe8cd970 100644 --- a/mh.c +++ b/mh.c @@ -389,7 +389,8 @@ static void mh_update_sequences (CONTEXT * ctx) else p = ctx->hdrs[l]->path; - i = atoi (p); + if (mutt_atoi (p, &i) < 0) + continue; if (!ctx->hdrs[l]->read) { @@ -517,7 +518,8 @@ static void mh_update_maildir (struct maildir *md, struct mh_sequences *mhs) else p = md->h->path; - i = atoi (p); + if (mutt_atoi (p, &i) < 0) + continue; f = mhs_check (mhs, i); md->h->read = (f & MH_SEQ_UNSEEN) ? 0 : 1; -- 2.40.0