/src/dovecot/src/lib-mail/fuzz-message-parser.c
Line | Count | Source |
1 | | /* Copyright (c) 2020 Dovecot authors, see the included COPYING file */ |
2 | | |
3 | | #include "lib.h" |
4 | | #include "istream.h" |
5 | | #include "test-common.h" |
6 | | #include "test-common.h" |
7 | | #include "fuzzer.h" |
8 | | #include "message-parser.h" |
9 | | |
10 | 11.9k | FUZZ_BEGIN_DATA(const unsigned char *data, size_t size) |
11 | 11.9k | { |
12 | 11.9k | struct istream *input = test_istream_create_data(data, size); |
13 | 11.9k | const struct message_parser_settings set = { |
14 | 11.9k | .hdr_flags = 0, |
15 | 11.9k | .flags = MESSAGE_PARSER_FLAG_INCLUDE_MULTIPART_BLOCKS, |
16 | 11.9k | .max_nested_mime_parts = 0, |
17 | 11.9k | .max_total_mime_parts = 0, |
18 | 11.9k | }; |
19 | 11.9k | struct message_parser_ctx *ctx = |
20 | 11.9k | message_parser_init(pool_datastack_create(), input, &set); |
21 | 11.9k | struct message_block block ATTR_UNUSED; |
22 | 11.9k | i_zero(&block); |
23 | 741k | while(message_parser_parse_next_block(ctx, &block) > -1); |
24 | 11.9k | struct message_part *part ATTR_UNUSED; |
25 | 11.9k | message_parser_deinit(&ctx, &part); |
26 | 11.9k | i_stream_unref(&input); |
27 | 11.9k | } |
28 | 11.9k | FUZZ_END |