]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: fix cookie length in nts_ke_client unit test
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 24 Aug 2020 12:03:06 +0000 (14:03 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 25 Aug 2020 09:49:44 +0000 (11:49 +0200)
test/unit/nts_ke_client.c

index dbb0364a11d7f8d595e014d10e28ce7c8dd903b0..a90757309549ed322648a6b37735d9afeae1cdaf 100644 (file)
@@ -92,7 +92,7 @@ prepare_response(NKSN_Instance session, int valid)
     for (i = 0; i < NKE_MAX_COOKIES; i++) {
       length = (random() % sizeof (data) + 1) / 4 * 4;
       if (index == 9)
-        length += random() % 3 + 1;
+        length += (length < sizeof (data) ? 1 : -1) * (random() % 3 + 1);
       TEST_CHECK(NKSN_AddRecord(session, 0, NKE_RECORD_COOKIE, data, length));
     }
   }