Skip to content

Commit

Permalink
Fix seqset iterator when it ends in a comma
Browse files Browse the repository at this point in the history
If the seqset ended with a comma, the substr_end marker would be just
before the trailing nul.  In the next call, the loop to skip the
marker would iterate right past the end of string too.

The fix is simple: place the substr_end marker and skip past it
immediately.
  • Loading branch information
kevin8t8 authored and flatcap committed May 5, 2021
1 parent a89d744 commit fa1db57
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions imap/util.c
Expand Up @@ -1119,13 +1119,11 @@ int mutt_seqset_iterator_next(struct SeqsetIterator *iter, unsigned int *next)
if (iter->substr_cur == iter->eostr)
return 1;

while (!*(iter->substr_cur))
iter->substr_cur++;
iter->substr_end = strchr(iter->substr_cur, ',');
if (!iter->substr_end)
iter->substr_end = iter->eostr;
else
*(iter->substr_end) = '\0';
*(iter->substr_end++) = '\0';

char *range_sep = strchr(iter->substr_cur, ':');
if (range_sep)
Expand Down

0 comments on commit fa1db57

Please sign in to comment.