]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: test-stream - Make static analyzer happier
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 17 Nov 2017 18:53:41 +0000 (20:53 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 17 Nov 2017 18:54:56 +0000 (20:54 +0200)
Without this clang thinks it's possible that siz>sizeof(payload).

src/lib-dcrypt/test-stream.c

index 0c071be911192c17f654055936e3cfc4cd7ba396..b096e540edb22393baf1a4620c0fbc96a9b03237 100644 (file)
@@ -265,7 +265,7 @@ void test_write_read_v1_short(void)
                        test_istream_set_size(is, ++offset);
 
                test_assert_idx(pos + siz <= sizeof(payload), pos);
-               if (pos + siz > sizeof(payload)) break;
+               if (siz > sizeof(payload) || pos + siz > sizeof(payload)) break;
                test_assert_idx(siz == 0 || memcmp(ptr, payload + pos, siz) == 0, pos);
                i_stream_skip(is_2, siz); pos += siz;
        }
@@ -406,7 +406,7 @@ void test_write_read_v2_short(void)
                test_istream_set_size(is, ++offset);
 
                test_assert_idx(pos + siz <= sizeof(payload), pos);
-               if (pos + siz > sizeof(payload)) break;
+               if (siz > sizeof(payload) || pos + siz > sizeof(payload)) break;
                test_assert_idx(siz == 0 || memcmp(ptr, payload + pos, siz) == 0, pos);
                i_stream_skip(is_2, siz); pos += siz;
        }