]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
nts: avoid assumption about cookie record
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 27 Apr 2021 13:39:59 +0000 (15:39 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 29 Apr 2021 07:44:32 +0000 (09:44 +0200)
The cookie record is currently assumed to be the longest record that
needs to be accepted by the client, but that does not have to be always
the case. Define the processing buffer using the maximum body record
constant instead and add an assertion to make sure it's not smaller than
the maximum accepted cookie length.

nts_ke_client.c

index 89dc6fede4a783040997385971c22fe72406bf9b..d895bf1e76cc7306fd3df473c0b34bb42090ac4b 100644 (file)
@@ -127,9 +127,10 @@ process_response(NKC_Instance inst)
 {
   int next_protocol = -1, aead_algorithm = -1, error = 0;
   int i, critical, type, length;
-  uint16_t data[NKE_MAX_COOKIE_LENGTH / sizeof (uint16_t)];
+  uint16_t data[NKE_MAX_RECORD_BODY_LENGTH / sizeof (uint16_t)];
 
-  assert(NKE_MAX_COOKIE_LENGTH % sizeof (uint16_t) == 0);
+  assert(NKE_MAX_COOKIE_LENGTH <= NKE_MAX_RECORD_BODY_LENGTH);
+  assert(sizeof (data) % sizeof (uint16_t) == 0);
   assert(sizeof (uint16_t) == 2);
 
   inst->num_cookies = 0;