]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: test-message-address: Add test for parsing empty path.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 12 Apr 2018 18:54:50 +0000 (20:54 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Wed, 25 Apr 2018 08:12:06 +0000 (11:12 +0300)
src/lib-mail/test-message-address.c

index 8fe9989f0dfa5a3c7d729208c5cbf6569d3af3df..d50a08d3fbc5a77b7149533027664fab3ded8991 100644 (file)
@@ -323,15 +323,19 @@ static int
 test_parse_path(const char *input, const struct message_address **addr_r)
 {
        struct message_address *addr;
+       char *input_dup;
        int ret;
 
        /* duplicate the input (without trailing NUL) so valgrind notices
           if there's any out-of-bounds access */
        size_t input_len = strlen(input);
-       unsigned char *input_dup = i_memdup(input, input_len);
+       if (input_len > 0)
+               input = input_dup = i_memdup(input, input_len);
        ret = message_address_parse_path(pool_datastack_create(),
-                                        input_dup, input_len, &addr);
-       i_free(input_dup);
+                                        (unsigned char *)input, input_len,
+                                        &addr);
+       if (input_len > 0)
+               i_free(input_dup);
        *addr_r = addr;
        return ret;
 }
@@ -396,6 +400,7 @@ static void test_message_address_path(void)
 static void test_message_address_path_invalid(void)
 {
        static const char *tests[] = {
+               "",
                "<",
                " < ",
                ">",