]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: test-stream.c - Remove pointer arithmetic in test_read_garbage()
authorMartti Rannanjärvi <martti.rannanjarvi@open-xchange.com>
Wed, 6 Apr 2022 17:13:24 +0000 (20:13 +0300)
committerMartti Rannanjärvi <martti.rannanjarvi@open-xchange.com>
Wed, 6 Apr 2022 19:20:00 +0000 (22:20 +0300)
Something is wrong with the pointer arithmetic given to random_fill(),
and easiest is to remove it altogether. This fixes a valgrind complaint
on use of uninitialized value.

src/lib-dcrypt/test-stream.c

index 8ec0a34581b89601fd360dd7ac22c7c6bfffd0bd..74725fc25648cdcbbb517df8f948e6316855a569 100644 (file)
@@ -595,9 +595,9 @@ static void test_read_garbage(void)
        test_begin("test_read_garbage");
        unsigned char buf[512];
        for (int i = 0; i < 5; i++) {
+               random_fill(buf, sizeof(buf));
                memcpy(buf, IOSTREAM_CRYPT_MAGIC, sizeof(IOSTREAM_CRYPT_MAGIC));
                buf[sizeof(IOSTREAM_CRYPT_MAGIC)+1] = '\x02';
-               random_fill(buf + 10, sizeof(buf) - 10);
                struct istream *is = test_istream_create_data(buf, sizeof(buf));
                struct istream *ds = i_stream_create_decrypt_callback(is,
                                        no_op_cb, NULL);