Skip to content

Commit

Permalink
lib-smtp: reply-parser: Fix closing the text_lines array with NULL se…
Browse files Browse the repository at this point in the history
…ntinel.

For (EHLO) replies with more than 7 lines, the text_lines array of the reply did
not end in NULL, causing a segfault.
  • Loading branch information
stephanbosch authored and cmouse committed Sep 20, 2018
1 parent b2360fc commit d161ee8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib-smtp/smtp-reply-parser.c
Expand Up @@ -582,6 +582,9 @@ int smtp_reply_parse_next(struct smtp_reply_parser *parser,
return ret;
}

i_assert(array_count(&parser->state.reply_lines) > 0);
array_append_zero(&parser->state.reply_lines);

parser->state.state = SMTP_REPLY_PARSE_STATE_INIT;
parser->state.reply->text_lines =
array_idx(&parser->state.reply_lines, 0);
Expand Down Expand Up @@ -623,6 +626,9 @@ int smtp_reply_parse_ehlo(struct smtp_reply_parser *parser,
return ret;
}

i_assert(array_count(&parser->state.reply_lines) > 0);
array_append_zero(&parser->state.reply_lines);

parser->state.state = SMTP_REPLY_PARSE_STATE_INIT;
parser->state.reply->text_lines =
array_idx(&parser->state.reply_lines, 0);
Expand Down

0 comments on commit d161ee8

Please sign in to comment.