]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
it helps to decode the coa packets before looking at attributes in them
authorAlan T. DeKok <aland@freeradius.org>
Wed, 13 Mar 2024 02:15:45 +0000 (22:15 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 13 Mar 2024 02:16:40 +0000 (22:16 -0400)
src/bin/radclient.c

index aa43e81e96f21c82bbbb4cf1880eb8f61e30e87b..dab897613a6ea7d9da15f3513815dc8fd780abd9 100644 (file)
@@ -1114,7 +1114,8 @@ static int recv_coa_packet(fr_time_delta_t wait_time)
        fd_set                  set;
        fr_time_delta_t         our_wait_time;
        rc_request_t            *request, *parent;
-       fr_packet_t     *packet;
+       fr_packet_t             *packet;
+       fr_pair_list_t          pairs;
 
 #ifdef STATIC_ANALYZER
        if (!secret) fr_exit_now(1);
@@ -1148,6 +1149,20 @@ static int recv_coa_packet(fr_time_delta_t wait_time)
                return 0;
        }
 
+       fr_pair_list_init(&pairs);
+
+       /*
+        *      Decode the packet before looking up the parent, so that we can compare the pairs.
+        */
+       if (fr_radius_decode_simple(packet, &pairs,
+                                   packet->data, packet->data_len,
+                                   NULL, secret) < 0) {
+               DEBUG("Failed decoding CoA packet");
+               return 0;
+       }
+
+       fr_packet_log(&default_log, packet, &pairs, true);
+
        /*
         *      Find a Access-Request which has the same User-Name / etc. as this CoA packet.
         */
@@ -1155,7 +1170,8 @@ static int recv_coa_packet(fr_time_delta_t wait_time)
                        .packet = packet,
                });
        if (!parent) {
-               DEBUG("No matching request packet");
+               DEBUG("No matching request packet for CoA packet %u %u", packet->data[0], packet->data[1]);
+               talloc_free(packet);
                return 0;
        }
        assert(parent->coa);
@@ -1163,17 +1179,8 @@ static int recv_coa_packet(fr_time_delta_t wait_time)
        request = parent->coa;
        request->packet = talloc_steal(request, packet);
 
-       /*
-        *      Decode the packet
-        */
-       if (fr_radius_decode_simple(request, &request->request_pairs,
-                                   request->packet->data, request->packet->data_len,
-                                   NULL, secret) < 0) {
-               REDEBUG("Failed decoding CoA packet");
-               return 0;
-       }
-
-       fr_packet_log(&default_log, request->packet, &request->request_pairs, true);
+       fr_pair_list_steal(request, &pairs);
+       fr_pair_list_append(&request->request_pairs, &pairs);
 
        /*
         *      If we had an expected response code, check to see if the