Fix BIO_dgram_pair stochastic test failure
authorHugo Landau <hlandau@openssl.org>
Fri, 23 Sep 2022 08:41:15 +0000 (09:41 +0100)
committerHugo Landau <hlandau@openssl.org>
Fri, 23 Sep 2022 09:52:45 +0000 (10:52 +0100)
Fixes #19267.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19268)

test/bio_dgram_test.c

index 4dd2893c1b31b4216f0e22d0ca31ad761f8d7f62..f2b1bb6f4bcfc15874471147f13ee7815625e1ac 100644 (file)
@@ -530,7 +530,7 @@ static int test_bio_dgram_pair(void)
         if (!TEST_int_eq(random_data(key, scratch, sizeof(scratch), i), 1))
             goto err;
 
-        blen = (*(uint32_t*)scratch) % mtu1;
+        blen = ((*(uint32_t*)scratch) % mtu1) + 1;
         r = BIO_write(bio1, scratch + 4, blen);
         if (r == -1)
             break;
@@ -556,7 +556,7 @@ static int test_bio_dgram_pair(void)
         if (!TEST_int_eq(random_data(key, scratch, sizeof(scratch), i), 1))
             goto err;
 
-        blen = (*(uint32_t*)scratch) % mtu1;
+        blen = ((*(uint32_t*)scratch) % mtu1) + 1;
         r = BIO_read(bio2, scratch2, sizeof(scratch2));
         if (!TEST_int_eq(r, blen))
             goto err;