Branch Coverage

dovecot-parser.c
Criterion Covered Total %
branch 246 370 66.4


line true false branch
76 0 321 if (!initial_size)
79 0 321 if (initial_size >= SIZE_MAX / 2)
83 0 321 if (!buf)
87 0 321 if (!str)
123 1871 0 if (len >= SIZE_MAX / 2 || need_size >= SIZE_MAX / 2)
0 1871 if (len >= SIZE_MAX / 2 || need_size >= SIZE_MAX / 2)
126 6 1865 if (need_size > str->size) {
128 50 6 while (str->size < need_size)
132 0 6 if (!new_buf)
158 5458 660 while (len < max_len && ((const char *)cstr)[len] != '\0')
5458 0 while (len < max_len && ((const char *)cstr)[len] != '\0')
166 516 0 if (str->size - 1 <= len || str->len <= len)
192 324 if (str->size - 1 <= len || str->len <= len)
232 1975 192 for (p = cstr; *p != '\0'; p++) {
233 101 1874 if (!IS_ATEXT(*p) && (escape_dot || *p != '.'))
73 28 if (!IS_ATEXT(*p) && (escape_dot || *p != '.'))
69 4 if (!IS_ATEXT(*p) && (escape_dot || *p != '.'))
237 192 32 if (*p == '\0') {
243 402 24 for (p = cstr; *p != '\0'; p++) {
244 394 8 if (IS_ESCAPED_CHAR(*p))
394 0 if (IS_ESCAPED_CHAR(*p))
394 0 if (IS_ESCAPED_CHAR(*p))
248 24 8 if (*p == '\0') {
260 109 8 for (; *p != '\0'; p++) {
261 96 13 if (IS_ESCAPED_CHAR(*p))
96 0 if (IS_ESCAPED_CHAR(*p))
0 96 if (IS_ESCAPED_CHAR(*p))
294 25 13 if (ctx->last_comment != NULL)
298 623 0 for (; ctx->data != ctx->end; ctx->data++) {
304 38 14 if (--level == 0) {
305 25 13 if (ctx->last_comment != NULL) {
314 0 0 if (ctx->last_comment != NULL) {
321 0 0 if (ctx->data == ctx->end)
334 1386 33 for (; ctx->data != ctx->end;) {
335 1219 167 if (*ctx->data == ' ' || *ctx->data == '\t' ||
1219 0 if (*ctx->data == ' ' || *ctx->data == '\t' ||
1219 0 if (*ctx->data == ' ' || *ctx->data == '\t' ||
336 1 1218 *ctx->data == '\r' || *ctx->data == '\n') {
341 1180 38 if (*ctx->data != '(')
344 0 38 if (rfc822_skip_comment(ctx) < 0)
365 288 0 if (ctx->data == ctx->end || !IS_ATEXT(*ctx->data))
1 287 if (ctx->data == ctx->end || !IS_ATEXT(*ctx->data))
368 3191 94 for (start = ctx->data++; ctx->data != ctx->end; ) {
369 2811 380 if (IS_ATEXT(*ctx->data)) {
376 6 374 if ((ret = rfc822_skip_lwsp(ctx)) <= 0)
379 187 187 if (*ctx->data != '.')
385 0 187 if ((ret = rfc822_skip_lwsp(ctx)) <= 0)
403 1263 0 for (start = ctx->data; ctx->data != ctx->end; ctx->data++) {
412 0 0 if (len > 0 && start[len-1] == '\r')
0 0 if (len > 0 && start[len-1] == '\r')
419 0 27 if (ctx->data == ctx->end)
445 737 6 for (start = ctx->data; ctx->data != ctx->end; ctx->data++) {
446 82 655 if (IS_ATEXT(*ctx->data) || *ctx->data == '.')
16 66 if (IS_ATEXT(*ctx->data) || *ctx->data == '.')
468 0 119 if (ctx->data == ctx->end)
470 0 119 if (*ctx->data == '.')
474 58 72 if (*ctx->data == '"')
479 6 124 if (ret <= 0)
482 115 9 if (!IS_ATEXT(*ctx->data) && *ctx->data != '"'
113 2 if (!IS_ATEXT(*ctx->data) && *ctx->data != '"'
483 113 0 && *ctx->data != '.')
505 0 0 for (start = ctx->data; ctx->data != ctx->end; ctx->data++) {
506 0 0 if (*ctx->data == '\\') {
508 0 0 if (ctx->data == ctx->end)
510 0 0 } else if (*ctx->data == ']') {
532 0 141 if (rfc822_skip_lwsp(ctx) <= 0)
535 0 141 if (*ctx->data == '[')
546 0 78 if (!addr)
552 33 45 if (ctx->first_addr == NULL)
570 4 147 if (*ctx->parser.data == '"')
574 1 150 if (ret < 0)
586 0 141 if ((ret = rfc822_parse_domain(&ctx->parser, ctx->str)) < 0)
600 0 0 if (ctx->parser.data == ctx->parser.end)
603 0 0 if (*ctx->parser.data != '@')
606 0 0 if (str_len(ctx->str) > 0)
610 0 0 if ((ret = rfc822_parse_domain(&ctx->parser, ctx->str)) <= 0)
613 0 0 while (rfc822_skip_lwsp(&ctx->parser) > 0 &&
0 0 while (rfc822_skip_lwsp(&ctx->parser) > 0 &&
629 0 43 if ((ret = rfc822_skip_lwsp(&ctx->parser)) <= 0)
632 0 43 if (*ctx->parser.data == '@') {
633 0 0 if (parse_domain_list(ctx) <= 0 || *ctx->parser.data != ':') {
0 0 if (parse_domain_list(ctx) <= 0 || *ctx->parser.data != ':') {
634 0 0 if (ctx->fill_missing)
637 0 0 if (ctx->parser.data == ctx->parser.end)
644 0 0 if ((ret = rfc822_skip_lwsp(&ctx->parser)) <= 0)
648 43 0 if (*ctx->parser.data == '>') {
651 0 43 if ((ret = parse_local_part(ctx)) <= 0)
653 43 0 if (*ctx->parser.data == '@') {
654 0 43 if ((ret = parse_domain(ctx)) <= 0)
659 0 43 if (*ctx->parser.data != '>')
673 57 3 if (rfc822_parse_phrase(&ctx->parser, ctx->str) <= 0 ||
14 43 if (rfc822_parse_phrase(&ctx->parser, ctx->str) <= 0 ||
677 1 42 if (*str_c(ctx->str) == '\0') {
684 43 0 if (ctx->parser.last_comment != NULL)
687 0 43 if (parse_angle_addr(ctx) < 0) {
689 0 0 if (ctx->fill_missing)
694 43 0 if (ctx->parser.last_comment != NULL) {
695 7 36 if (str_len(ctx->parser.last_comment) > 0) {
711 17 91 if (ctx->parser.last_comment != NULL)
718 8 100 if (ret <= 0) {
722 101 7 if (ret != 0 && *ctx->parser.data == '@') {
98 3 if (ret != 0 && *ctx->parser.data == '@') {
724 93 5 if (ret2 <= 0)
728 17 91 if (ctx->parser.last_comment != NULL && str_len(ctx->parser.last_comment) > 0)
3 14 if (ctx->parser.last_comment != NULL && str_len(ctx->parser.last_comment) > 0)
755 3 57 if (ctx->addr.mailbox == NULL) {
756 3 0 ctx->addr.mailbox = strdup(!ctx->fill_missing ? "" : "MISSING_MAILBOX");
759 56 4 if (ctx->addr.domain == NULL || ctx->addr.domain[0] == '\0') {
0 56 if (ctx->addr.domain == NULL || ctx->addr.domain[0] == '\0') {
760 4 0 ctx->addr.domain = strdup(!ctx->fill_missing ? "" : "MISSING_DOMAIN");
774 17 43 if ((ret = parse_name_addr(ctx)) < 0) {
776 0 17 if (ctx->addr.name != NULL) {
780 0 17 if (ctx->addr.route != NULL) {
784 0 17 if (ctx->addr.mailbox != NULL) {
788 0 17 if (ctx->addr.domain != NULL) {
792 0 17 if (ctx->addr.comment != NULL) {
796 0 17 if (ctx->addr.original != NULL) {
802 3 14 if (ctx->addr.invalid_syntax && ctx->addr.name == NULL &&
3 0 if (ctx->addr.invalid_syntax && ctx->addr.name == NULL &&
3 0 if (ctx->addr.invalid_syntax && ctx->addr.name == NULL &&
803 3 0 ctx->addr.mailbox != NULL && ctx->addr.domain == NULL) {
809 0 60 if (ret < 0)
814 0 60 if (!ctx->addr.original)
836 56 3 if (rfc822_parse_phrase(&ctx->parser, ctx->str) <= 0 ||
47 9 if (rfc822_parse_phrase(&ctx->parser, ctx->str) <= 0 ||
843 0 9 if ((ret = rfc822_skip_lwsp(&ctx->parser)) <= 0)
849 9 0 if (ret > 0 && *ctx->parser.data != ';') {
7 2 if (ret > 0 && *ctx->parser.data != ';') {
856 9 1 if (ctx->parser.data == ctx->parser.end ||
3 6 if (ctx->parser.data == ctx->parser.end ||
860 0 3 if (rfc822_skip_lwsp(&ctx->parser) <= 0) {
866 9 0 if (ret >= 0) {
867 8 1 if (ctx->parser.data == ctx->parser.end ||
0 8 if (ctx->parser.data == ctx->parser.end ||
875 1 8 if (ret < 0)
889 50 9 if ((ret = parse_group(ctx)) < 0) {
905 59 0 while (max_addresses > 0) {
907 31 28 if ((ret = parse_address(ctx)) == 0)
909 27 1 if (ctx->parser.data == ctx->parser.end ||
1 26 if (ctx->parser.data == ctx->parser.end ||
916 0 26 if ((ret = rfc822_skip_lwsp(&ctx->parser)) <= 0) {
917 0 0 if (ret < 0) {
921 0 0 if (!ctx->addr.original)
945 0 107 if (!message)
948 48 59 message->name = name ? strdup(name) : NULL;
949 0 107 message->route = route ? strdup(route) : NULL;
950 87 20 message->mailbox = mailbox ? strdup(mailbox) : NULL;
951 67 40 message->domain = domain ? strdup(domain) : NULL;
952 19 88 message->comment = comment ? strdup(comment) : NULL;
956 49 58 if (!*first)
971 185 104 while (current) {
999 8 33 if (rfc822_skip_lwsp(&ctx.parser) <= 0) {
1028 107 63 while (addr != NULL) {
1029 69 38 if (first)
1034 40 67 if (addr->domain == NULL) {
1035 20 20 if (!in_group) {
1038 20 0 if (addr->mailbox != NULL && *addr->mailbox != '\0') {
19 1 if (addr->mailbox != NULL && *addr->mailbox != '\0') {
1040 1 18 if (strstr(addr->mailbox, "=?") != NULL)
1060 14 6 if (tmp[0] == ',' && tmp[1] == ' ')
14 0 if (tmp[0] == ',' && tmp[1] == ' ')
1062 6 0 else if (tmp[0] == ':' && tmp[1] == ' ')
6 0 else if (tmp[0] == ':' && tmp[1] == ' ')
1068 48 19 } else if ((addr->name == NULL || *addr->name == '\0') &&
0 48 } else if ((addr->name == NULL || *addr->name == '\0') &&
19 0 } else if ((addr->name == NULL || *addr->name == '\0') &&
1077 1 18 if (addr->comment != NULL) {
1086 48 0 if (addr->name != NULL && *addr->name != '\0') {
48 0 if (addr->name != NULL && *addr->name != '\0') {
1088 2 46 if (strstr(addr->name, "=?"))
1096 48 0 if (addr->route != NULL ||
0 48 if (addr->route != NULL ||
1097 0 0 addr->mailbox[0] != '\0' ||
1099 48 0 if (addr->name != NULL && addr->name[0] != '\0')
48 0 if (addr->name != NULL && addr->name[0] != '\0')
1102 0 48 if (addr->route != NULL) {
1106 0 48 if (addr->mailbox[0] == '\0')
1110 48 0 if (addr->domain[0] != '\0') {
1116 18 30 if (addr->comment != NULL) {
1149 92 0 if (!input || !input[0]) {
1 91 if (!input || !input[0]) {
1164 91 0 if (ret > 0)
1169 90 1 if (ret < 0 || ctx.parser.data != ctx.parser.end || ctx.addr.invalid_syntax) {
87 3 if (ret < 0 || ctx.parser.data != ctx.parser.end || ctx.addr.invalid_syntax) {
4 83 if (ret < 0 || ctx.parser.data != ctx.parser.end || ctx.addr.invalid_syntax) {