]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
More ctx fixes (dhcpv4)
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 20 Jan 2021 13:30:52 +0000 (13:30 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 20 Jan 2021 13:30:52 +0000 (13:30 +0000)
src/modules/proto_dhcpv4/proto_dhcpv4.c
src/modules/proto_dhcpv4/proto_dhcpv4_process.c
src/protocols/dhcpv4/base.c
src/protocols/dhcpv4/dhcpv4.h
src/protocols/dhcpv4/packet.c

index 9980ed97834d3813da7bf4b27f21f6f858b9c17d..61164dc8a93b7672490c7d8b128cb63acc833393 100644 (file)
@@ -217,7 +217,7 @@ static int mod_decode(void const *instance, request_t *request, uint8_t *const d
         *      transport, via a call to fr_dhcpv4_ok().
         */
        fr_cursor_init(&cursor, &request->request_pairs);
-       if (fr_dhcpv4_decode(packet, packet->data, packet->data_len, &cursor, &packet->code) < 0) {
+       if (fr_dhcpv4_decode(request->request_ctx, packet->data, packet->data_len, &cursor, &packet->code) < 0) {
                RPEDEBUG("Failed decoding packet");
                return -1;
        }
index 267831e816d1fa7ab488765a3968e15fdbaee2dd..5ada8ce92b9446d698dc469512b14e96e55cb1fd 100644 (file)
@@ -56,7 +56,7 @@ fr_dict_attr_autoload_t proto_dhcpv4_process_dict_attr[] = {
  */
 static void dhcpv4_packet_debug(request_t *request, fr_radius_packet_t *packet, fr_pair_list_t *list, bool received)
 {
-       int i;
+       size_t i;
 #ifdef WITH_IFINDEX_NAME_RESOLUTION
        char if_name[IFNAMSIZ];
 #endif
@@ -91,7 +91,7 @@ static void dhcpv4_packet_debug(request_t *request, fr_radius_packet_t *packet,
         *      Print the fields in the header, too.
         */
        RINDENT();
-       for (i = 0; dhcp_header_attrs[i] != NULL; i++) {
+       for (i = 0; i < dhcp_header_attrs_len; i++) {
                fr_pair_t *vp;
 
                if (!*dhcp_header_attrs[i]) continue;
index 5dc3480250bcdb63737265e2a05b6b11b365c975..43b9175ffca328b6c827cab45543fd9c28425b85 100644 (file)
@@ -119,8 +119,8 @@ fr_dict_attr_t const **dhcp_header_attrs[] = {
        &attr_dhcp_client_hardware_address,
        &attr_dhcp_server_host_name,
        &attr_dhcp_boot_filename,
-       NULL
 };
+size_t dhcp_header_attrs_len = NUM_ELEMENTS(dhcp_header_attrs);
 
 char const *dhcp_message_types[] = {
        "invalid",
index 589b9dd3c2f445f1580a7e0819a78c2539ed6c3a..1b17e8b9550a3ad7c5747dfe9e6b6a7dc57f4c77 100644 (file)
@@ -113,6 +113,7 @@ typedef struct {
 #endif
 
 extern fr_dict_attr_t const    **dhcp_header_attrs[];
+extern size_t dhcp_header_attrs_len;
 extern char const              *dhcp_message_types[];
 extern int                     dhcp_header_sizes[];
 extern uint8_t                 eth_bcast[ETH_ADDR_LEN];
index 3bed0455b3d85c29b02ac3a46656dbe26870cb47..68a5506a466c3811cf8044af55ff8f463eae567d 100644 (file)
@@ -123,7 +123,7 @@ int fr_dhcpv4_decode(TALLOC_CTX *ctx, uint8_t const *data, size_t data_len, fr_c
        /*
         *      Decode the header.
         */
-       for (i = 0; i < 14; i++) {
+       for (i = 0; i < dhcp_header_attrs_len; i++) {
                vp = fr_pair_afrom_da(ctx, *dhcp_header_attrs[i]);
                if (!vp) {
                        fr_strerror_const_push("Cannot decode packet due to internal error");