]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: reply-parser: Fix closing the text_lines array with NULL sentinel.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Wed, 19 Sep 2018 20:26:08 +0000 (22:26 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 20 Sep 2018 12:16:33 +0000 (12:16 +0000)
For (EHLO) replies with more than 7 lines, the text_lines array of the reply did
not end in NULL, causing a segfault.

src/lib-smtp/smtp-reply-parser.c

index b1bdf5253e521457f0779c47e85c5e977ec61a32..d47eab4513b8ddef4912295bf02670f0593ac181 100644 (file)
@@ -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);
@@ -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);