Skip to content
Permalink
Browse files

lib-mail: rfc822-parser - Add asserts to make sure parser state is co…

…rrect
  • Loading branch information...
sirainen committed Dec 22, 2017
1 parent 1171a7e commit 30dc856f7b97b75b0e0d69f5003d5d99a13249b4
Showing with 3 additions and 0 deletions.
  1. +3 −0 src/lib-mail/rfc822-parser.c
@@ -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++;

0 comments on commit 30dc856

Please sign in to comment.
You can’t perform that action at this time.