]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: add 0 to 400 byte stream test
authorMartti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
Thu, 4 Aug 2016 16:45:35 +0000 (19:45 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 7 Aug 2016 23:01:09 +0000 (02:01 +0300)
Remove 8 byte speacial case also.

src/lib-dcrypt/test-stream.c

index b47b087bff011eef0786954a8f29bbc305d59b7d..126639bd02d0ac572118d2ac7e8c28727a621abe 100644 (file)
@@ -406,17 +406,22 @@ static int no_op_cb(const char *digest ATTR_UNUSED,
        return 0;
 }
 
-static void test_read_8byte_garbage(void)
+static void test_read_0_to_400_byte_garbage(void)
 {
-       test_begin("test_read_8byte_garbage");
-
-       struct istream *is = i_stream_create_from_data("12345678", 8);
-       struct istream *ds = i_stream_create_decrypt_callback(is,
-                       no_op_cb, NULL);
-       ssize_t siz = i_stream_read(ds);
-       test_assert(siz < 0);
-       i_stream_unref(&ds);
-       i_stream_unref(&is);
+       test_begin("test_read_0_to_100_byte_garbage");
+
+       char data[512];
+       memset(data, 0, sizeof(data));
+
+       for (size_t s = 0; s <= 400; ++s) {
+               struct istream *is = i_stream_create_from_data(data, s);
+               struct istream *ds = i_stream_create_decrypt_callback(is,
+                               no_op_cb, NULL);
+               ssize_t siz = i_stream_read(ds);
+               test_assert(siz < 0);
+               i_stream_unref(&ds);
+               i_stream_unref(&is);
+       }
 
        test_end();
 }
@@ -452,7 +457,7 @@ int main(void) {
                test_write_read_v2_short,
                test_write_read_v2_empty,
                test_free_keys,
-               test_read_8byte_garbage,
+               test_read_0_to_400_byte_garbage,
                NULL
        };