]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: Add rfc822_parser_deinit()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 22 Dec 2017 16:56:53 +0000 (18:56 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 6 Mar 2018 10:43:22 +0000 (12:43 +0200)
It's not a strict requirement to call this, but it assert-crashes if the
state isn't valid.

src/lib-mail/rfc822-parser.h

index 87e9aa23dc74e89823b6316573111c58c5fe02f4..466a68af5a1ce0897ae546e3bf010b59b2456af3 100644 (file)
@@ -16,6 +16,14 @@ extern unsigned char rfc822_atext_chars[256];
 void rfc822_parser_init(struct rfc822_parser_context *ctx,
                        const unsigned char *data, size_t size,
                        string_t *last_comment) ATTR_NULL(4);
+static inline void rfc822_parser_deinit(struct rfc822_parser_context *ctx)
+{
+       /* make sure the parsing didn't trigger a bug that caused reading
+          past the end pointer. */
+       i_assert(ctx->data <= ctx->end);
+       /* make sure the parser is no longer accessed */
+       ctx->data = ctx->end = NULL;
+}
 
 /* The functions below return 1 = more data available, 0 = no more data
    available (but a value might have been returned now), -1 = invalid input.