]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
check length of tracking structure, too
authorAlan T. DeKok <aland@freeradius.org>
Tue, 21 Jul 2020 13:37:34 +0000 (09:37 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 21 Jul 2020 13:37:34 +0000 (09:37 -0400)
and ignore duplicates while the client is pending

src/lib/io/master.c

index c5c4275662a52c14fef93e8ff6bc81d3fc2c31f5..09a358b79dec3fe3764c96ac89c6d5b9be87227c 100644 (file)
@@ -818,6 +818,7 @@ static fr_io_track_t *fr_io_track_add(fr_io_client_t *client,
                                      uint8_t const *packet, size_t packet_len,
                                      fr_time_t recv_time, bool *is_dup)
 {
+       size_t len;
        fr_io_track_t *track, *old;
 
        /*
@@ -879,7 +880,19 @@ static fr_io_track_t *fr_io_track_add(fr_io_client_t *client,
         *      If there's a cached reply, the caller will take care
         *      of sending it to the network layer.
         */
-       if (memcmp(old->packet, track->packet, talloc_array_length(old->packet)) == 0) {
+       len = talloc_array_length(old->packet);
+       if ((len == talloc_array_length(track->packet)) &&
+           (memcmp(old->packet, track->packet, len) == 0)) {
+               /*
+                *      Ignore duplicates while the client is
+                *      still pending.
+                */
+               if (client->state == PR_CLIENT_PENDING) {
+                       DEBUG("Ignoring duplicate packet while client %s is still pending dynamic definition",
+                             client->radclient->shortname);
+                       return NULL;
+               }
+
                *is_dup = true;
                old->packets++;
                track_free(track);