Skip to content

Commit

Permalink
lib-mail: rfc822-parser: Don't truncate comment/quoted-string/domain-…
Browse files Browse the repository at this point in the history
…literal at NUL

The other tokens couldn't have contained NULs in the first place.
  • Loading branch information
sirainen committed Aug 30, 2018
1 parent 3a4767c commit 69bb572
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lib-mail/rfc822-parser.c
Expand Up @@ -80,17 +80,17 @@ int rfc822_skip_comment(struct rfc822_parser_context *ctx)
case ')':
if (--level == 0) {
if (ctx->last_comment != NULL) {
str_append_n(ctx->last_comment, start,
ctx->data - start);
str_append_data(ctx->last_comment, start,
ctx->data - start);
}
ctx->data++;
return ctx->data < ctx->end ? 1 : 0;
}
break;
case '\\':
if (ctx->last_comment != NULL) {
str_append_n(ctx->last_comment, start,
ctx->data - start);
str_append_data(ctx->last_comment, start,
ctx->data - start);
}
start = ctx->data + 1;

Expand Down Expand Up @@ -218,23 +218,23 @@ int rfc822_parse_quoted_string(struct rfc822_parser_context *ctx, string_t *str)
for (start = ctx->data; ctx->data < ctx->end; ctx->data++) {
switch (*ctx->data) {
case '"':
str_append_n(str, start, ctx->data - start);
str_append_data(str, start, ctx->data - start);
ctx->data++;
return rfc822_skip_lwsp(ctx);
case '\n':
/* folding whitespace, remove the (CR)LF */
len = ctx->data - start;
if (len > 0 && start[len-1] == '\r')
len--;
str_append_n(str, start, len);
str_append_data(str, start, len);
start = ctx->data + 1;
break;
case '\\':
ctx->data++;
if (ctx->data >= ctx->end)
return -1;

str_append_n(str, start, ctx->data - start - 1);
str_append_data(str, start, ctx->data - start - 1);
start = ctx->data;
break;
}
Expand Down Expand Up @@ -324,7 +324,7 @@ rfc822_parse_domain_literal(struct rfc822_parser_context *ctx, string_t *str)
break;
} else if (*ctx->data == ']') {
ctx->data++;
str_append_n(str, start, ctx->data - start);
str_append_data(str, start, ctx->data - start);
return rfc822_skip_lwsp(ctx);
}
}
Expand Down

0 comments on commit 69bb572

Please sign in to comment.