]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: test-message-address - Add unit test for the one byte overread
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 7 Apr 2020 07:19:49 +0000 (10:19 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 8 Apr 2020 07:59:02 +0000 (07:59 +0000)
Note that this is visible only with valgrind.

src/lib-mail/test-message-address.c

index 3cb1b40d0d6689cdc0a36c608e46ad6cbb88ddf6..2488114cc7dbf9c1ceebdf72fed06e3e7bb8dc1f 100644 (file)
@@ -442,6 +442,8 @@ static void test_message_address_path(void)
                  { NULL, NULL, NULL, "user\"name", "domain", FALSE } },
                { "<\"\"@domain>", NULL,
                  { NULL, NULL, NULL, "", "domain", FALSE } },
+               { "<@source", "<>",
+                 { NULL, NULL, NULL, NULL, NULL, TRUE } },
        };
        const struct message_address *addr;
        string_t *str;
@@ -458,7 +460,10 @@ static void test_message_address_path(void)
 
                test_wanted_addr = &test->addr;
                ret = test_parse_path(test->input, &addr);
-               test_assert_idx(ret == 0, i);
+               if (addr->invalid_syntax)
+                       test_assert_idx(ret == -1, i);
+               else
+                       test_assert_idx(ret == 0, i);
                test_assert_idx(addr != NULL && addr->next == NULL &&
                                cmp_addr(addr, test_wanted_addr), i);