]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: rfc822-parser - Add asserts to make sure parser state is correct
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 22 Dec 2017 16:31:52 +0000 (18:31 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 6 Mar 2018 10:43:22 +0000 (12:43 +0200)
src/lib-mail/rfc822-parser.c

index f3e82d24c39c12cfe919196c18ea30aa3b96a806..7c89892b695553edfdaf5847f171ae80f216819e 100644 (file)
@@ -211,6 +211,7 @@ int rfc822_parse_quoted_string(struct rfc822_parser_context *ctx, string_t *str)
        const unsigned char *start;
        size_t len;
 
+       i_assert(ctx->data < ctx->end);
        i_assert(*ctx->data == '"');
        ctx->data++;
 
@@ -313,6 +314,7 @@ rfc822_parse_domain_literal(struct rfc822_parser_context *ctx, string_t *str)
                             %d94-126        ;  characters not including "[",
                                             ;  "]", or "\"
        */
+       i_assert(ctx->data < ctx->end);
        i_assert(*ctx->data == '[');
 
        for (start = ctx->data; ctx->data != ctx->end; ctx->data++) {
@@ -338,6 +340,7 @@ int rfc822_parse_domain(struct rfc822_parser_context *ctx, string_t *str)
           domain-literal  = [CFWS] "[" *([FWS] dcontent) [FWS] "]" [CFWS]
           obs-domain      = atom *("." atom)
        */
+       i_assert(ctx->data < ctx->end);
        i_assert(*ctx->data == '@');
        ctx->data++;