Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Alexander_Naumov:SLE-12:Update
dovecot22
0007-global-Call-rfc822_parser_deinit-wherever-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0007-global-Call-rfc822_parser_deinit-wherever-possible.patch of Package dovecot22
From 0ed696987e5e5d44e971da2a10f6275b276ece34 Mon Sep 17 00:00:00 2001 From: Timo Sirainen <timo.sirainen@dovecot.fi> Date: Fri, 22 Dec 2017 18:58:11 +0200 Subject: [PATCH 7/7] global: Call rfc822_parser_deinit() wherever possible --- src/lib-mail/istream-attachment-extractor.c | 1 + src/lib-mail/message-address.c | 1 + src/lib-mail/message-date.c | 1 + src/lib-mail/message-decoder.c | 6 +++++- src/lib-mail/message-id.c | 1 + src/lib-mail/message-parser.c | 5 ++++- src/lib-mail/message-part-data.c | 8 +++++++- src/lib-mail/message-search.c | 1 + src/lib-mail/test-rfc2231-parser.c | 1 + src/lib-mail/test-rfc822-parser.c | 2 ++ src/plugins/fts/fts-build-mail.c | 1 + src/plugins/fts/fts-parser-script.c | 5 ++++- 12 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/lib-mail/istream-attachment-extractor.c b/src/lib-mail/istream-attachment-extractor.c index 68e6deb..28a2d93 100644 --- a/src/lib-mail/istream-attachment-extractor.c +++ b/src/lib-mail/istream-attachment-extractor.c @@ -87,6 +87,7 @@ static void parse_content_type(struct attachment_istream *astream, (void)rfc822_parse_content_type(&parser, content_type); astream->part.content_type = i_strdup(str_c(content_type)); } T_END; + rfc822_parser_deinit(&parser); } static void diff --git a/src/lib-mail/message-address.c b/src/lib-mail/message-address.c index afeef88..14cc4b5 100644 --- a/src/lib-mail/message-address.c +++ b/src/lib-mail/message-address.c @@ -403,6 +403,7 @@ message_address_parse_real(pool_t pool, const unsigned char *data, size_t size, } else { (void)parse_address_list(&ctx, max_addresses); } + rfc822_parser_deinit(&ctx.parser); return ctx.first_addr; } diff --git a/src/lib-mail/message-date.c b/src/lib-mail/message-date.c index b67b21e..9a15011 100644 --- a/src/lib-mail/message-date.c +++ b/src/lib-mail/message-date.c @@ -252,6 +252,7 @@ bool message_date_parse(const unsigned char *data, size_t size, ctx.str = t_str_new(128); success = message_date_parser_tokens(&ctx, timestamp_r, timezone_offset_r); + rfc822_parser_deinit(&ctx.parser); } T_END; return success; diff --git a/src/lib-mail/message-decoder.c b/src/lib-mail/message-decoder.c index e1f329e..4c283b7 100644 --- a/src/lib-mail/message-decoder.c +++ b/src/lib-mail/message-decoder.c @@ -117,6 +117,7 @@ enum message_cte message_decoder_parse_cte(struct message_header_line *hdr) message_cte = MESSAGE_CTE_QP; break; } + rfc822_parser_deinit(&parser); return message_cte; } @@ -137,8 +138,10 @@ parse_content_type(struct message_decoder_context *ctx, str = t_str_new(64); ret = rfc822_parse_content_type(&parser, str); ctx->content_type = i_strdup(str_c(str)); - if (ret < 0) + if (ret < 0) { + rfc822_parser_deinit(&parser); return; + } rfc2231_parse(&parser, &results); for (; *results != NULL; results += 2) { @@ -147,6 +150,7 @@ parse_content_type(struct message_decoder_context *ctx, break; } } + rfc822_parser_deinit(&parser); } static bool message_decode_header(struct message_decoder_context *ctx, diff --git a/src/lib-mail/message-id.c b/src/lib-mail/message-id.c index 772535b..68e2be0 100644 --- a/src/lib-mail/message-id.c +++ b/src/lib-mail/message-id.c @@ -39,6 +39,7 @@ static bool get_untokenized_msgid(const char **msgid_p, string_t *msgid) success = TRUE; } } + rfc822_parser_deinit(&parser); return success; } diff --git a/src/lib-mail/message-parser.c b/src/lib-mail/message-parser.c index b95448a..b1de195 100644 --- a/src/lib-mail/message-parser.c +++ b/src/lib-mail/message-parser.c @@ -501,8 +501,10 @@ static void parse_content_type(struct message_parser_ctx *ctx, if (ret < 0 || (ctx->part->flags & MESSAGE_PART_FLAG_MULTIPART) == 0 || - ctx->last_boundary != NULL) + ctx->last_boundary != NULL) { + rfc822_parser_deinit(&parser); return; + } rfc2231_parse(&parser, &results); for (; *results != NULL; results += 2) { @@ -512,6 +514,7 @@ static void parse_content_type(struct message_parser_ctx *ctx, break; } } + rfc822_parser_deinit(&parser); } static bool block_is_at_eoh(const struct message_block *block) diff --git a/src/lib-mail/message-part-data.c b/src/lib-mail/message-part-data.c index 7f13244..35f35a0 100644 --- a/src/lib-mail/message-part-data.c +++ b/src/lib-mail/message-part-data.c @@ -309,6 +309,7 @@ parse_content_type(struct message_part_data *data, parse_mime_parameters(&parser, pool, &data->content_type_params, &data->content_type_params_count); + rfc822_parser_deinit(&parser); } static void @@ -327,6 +328,7 @@ parse_content_transfer_encoding(struct message_part_data *data, data->content_transfer_encoding = p_strdup(pool, str_c(str)); } + rfc822_parser_deinit(&parser); } static void @@ -340,13 +342,16 @@ parse_content_disposition(struct message_part_data *data, rfc822_skip_lwsp(&parser); str = t_str_new(256); - if (rfc822_parse_mime_token(&parser, str) < 0) + if (rfc822_parse_mime_token(&parser, str) < 0) { + rfc822_parser_deinit(&parser); return; + } data->content_disposition = p_strdup(pool, str_c(str)); parse_mime_parameters(&parser, pool, &data->content_disposition_params, &data->content_disposition_params_count); + rfc822_parser_deinit(&parser); } static void @@ -379,6 +384,7 @@ parse_content_language(struct message_part_data *data, parser.data++; rfc822_skip_lwsp(&parser); } + rfc822_parser_deinit(&parser); if (array_count(&langs) > 0) { array_append_zero(&langs); diff --git a/src/lib-mail/message-search.c b/src/lib-mail/message-search.c index 73509ee..8cd4e1c 100644 --- a/src/lib-mail/message-search.c +++ b/src/lib-mail/message-search.c @@ -61,6 +61,7 @@ static void parse_content_type(struct message_search_context *ctx, ctx->content_type_text = strncasecmp(str_c(content_type), "text/", 5) == 0 || strncasecmp(str_c(content_type), "message/", 8) == 0; + rfc822_parser_deinit(&parser); } static void handle_header(struct message_search_context *ctx, diff --git a/src/lib-mail/test-rfc2231-parser.c b/src/lib-mail/test-rfc2231-parser.c index 085d126..cc32dec 100644 --- a/src/lib-mail/test-rfc2231-parser.c +++ b/src/lib-mail/test-rfc2231-parser.c @@ -36,6 +36,7 @@ static void test_rfc2231_parser(void) test_assert(rfc2231_parse(&parser, &result) == 0); for (i = 0; output[i] != NULL && result[i] != NULL; i++) test_assert(strcmp(output[i], result[i]) == 0); + rfc822_parser_deinit(&parser); test_assert(output[i] == NULL && result[i] == NULL); test_end(); } diff --git a/src/lib-mail/test-rfc822-parser.c b/src/lib-mail/test-rfc822-parser.c index 29102fc..a758fa6 100644 --- a/src/lib-mail/test-rfc822-parser.c +++ b/src/lib-mail/test-rfc822-parser.c @@ -31,6 +31,7 @@ static void test_rfc822_parse_quoted_string(void) test_assert_idx(rfc822_parse_quoted_string(&parser, str) == tests[i].ret, i); test_assert_idx(tests[i].ret < 0 || strcmp(tests[i].output, str_c(str)) == 0, i); + rfc822_parser_deinit(&parser); str_truncate(str, 0); } test_end(); @@ -60,6 +61,7 @@ static void test_rfc822_parse_content_param(void) test_assert_idx(strcmp(output[i].value, value) == 0, i); i++; } + rfc822_parser_deinit(&parser); test_assert(ret == 0); test_assert(i == N_ELEMENTS(output)); test_end(); diff --git a/src/plugins/fts/fts-build-mail.c b/src/plugins/fts/fts-build-mail.c index 3a64032..5c6293e 100644 --- a/src/plugins/fts/fts-build-mail.c +++ b/src/plugins/fts/fts-build-mail.c @@ -56,6 +56,7 @@ static void fts_build_parse_content_type(struct fts_mail_build_context *ctx, (void)rfc822_parse_content_type(&parser, content_type); ctx->content_type = str_lcase(i_strdup(str_c(content_type))); } T_END; + rfc822_parser_deinit(&parser); } static void diff --git a/src/plugins/fts/fts-parser-script.c b/src/plugins/fts/fts-parser-script.c index 5eab69e..422b8dc 100644 --- a/src/plugins/fts/fts-parser-script.c +++ b/src/plugins/fts/fts-parser-script.c @@ -173,8 +173,10 @@ static void parse_content_disposition(const char *content_disposition, /* type; param; param; .. */ str = t_str_new(32); - if (rfc822_parse_mime_token(&parser, str) < 0) + if (rfc822_parse_mime_token(&parser, str) < 0) { + rfc822_parser_deinit(&parser); return; + } rfc2231_parse(&parser, &results); filename2 = NULL; @@ -191,6 +193,7 @@ static void parse_content_disposition(const char *content_disposition, much about the filename actually, just about its extension */ *filename_r = filename2; } + rfc822_parser_deinit(&parser); } static struct fts_parser * -- 2.1.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor