From 5f5a277c36ec0e586adbc1e40f431beb042e7dd2 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Thu, 9 May 2019 16:23:24 +0100 Subject: [PATCH] Replace atoi() to mutt_str_atoi() mutt_str_atoi() has error checking. --- color.c | 2 +- email/rfc2231.c | 2 +- maildir/shared.c | 2 +- mutt/regex.c | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/color.c b/color.c index d4c424275..51c8aae48 100644 --- a/color.c +++ b/color.c @@ -1132,7 +1132,7 @@ static enum CommandResult parse_color(struct Buffer *buf, struct Buffer *s, { struct Buffer temporary = { 0 }; mutt_extract_token(&temporary, s, MUTT_TOKEN_NO_FLAGS); - match = atoi(temporary.data); + mutt_str_atoui(temporary.data, &match); FREE(&temporary.data); } diff --git a/email/rfc2231.c b/email/rfc2231.c index 72b29ddf1..c69b9916f 100644 --- a/email/rfc2231.c +++ b/email/rfc2231.c @@ -285,7 +285,7 @@ void rfc2231_decode_parameters(struct ParameterList *p) encoded = (*t == '*'); *t = '\0'; - index = atoi(s); + mutt_str_atoi(s, &index); conttmp = new_parameter(); conttmp->attribute = np->attribute; diff --git a/maildir/shared.c b/maildir/shared.c index 105952f66..442ad8779 100644 --- a/maildir/shared.c +++ b/maildir/shared.c @@ -933,7 +933,7 @@ int mh_commit_msg(struct Mailbox *m, struct Message *msg, struct Email *e, bool } if (!*cp) { - n = atoi(dep); + mutt_str_atoui(dep, &n); if (n > hi) hi = n; } diff --git a/mutt/regex.c b/mutt/regex.c index 2be1a9377..e0e4e6658 100644 --- a/mutt/regex.c +++ b/mutt/regex.c @@ -313,7 +313,8 @@ int mutt_replacelist_add(struct ReplaceList *rl, const char *pat, { if (*p == '%') { - int n = atoi(++p); + int n = 0; + mutt_str_atoi(++p, &n); if (n > np->nmatch) np->nmatch = n; while (*p && isdigit((int) *p)) -- 2.40.0