]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Some dhcpv6 fixes (#5071)
authorJorge Pereira <jpereira@users.noreply.github.com>
Tue, 20 Jun 2023 04:43:51 +0000 (01:43 -0300)
committerGitHub <noreply@github.com>
Tue, 20 Jun 2023 04:43:51 +0000 (00:43 -0400)
* dhcpv6: Fix potential memory leak

* dhcpv6: Fix typo in default virtual server

* dhcpv6: Don't crash if 'interface' is empty.

It fixes:

Mon Jun 19 23:40:31 2023: Bootstrapping proto_dhcpv4 "dhcp.dhcpv4"
Mon Jun 19 23:40:31 2023: Bootstrapping proto_dhcpv6 "dhcpv6.all_dhcp_servers_and_relays"
Process 73144 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001a68c853c libsystem_platform.dylib`_platform_strcmp + 12
libsystem_platform.dylib`:
->  0x1a68c853c <+12>: ldrb   w5, [x1], #0x1
    0x1a68c8540 <+16>: subs   x3, x4, x5
    0x1a68c8544 <+20>: ccmp   w4, #0x0, #0x4, eq
    0x1a68c8548 <+24>: b.ne   0x1a68c8530               ; <+0>
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00000001a68c853c libsystem_platform.dylib`_platform_strcmp + 12
    frame #1: 0x0000000100368d60 libfreeradius-util.dylib`fr_interface_to_ethernet(interface=0x0000000000000000, ethernet=0x0000600003e041b0) at inet.c:1570:7
    frame #2: 0x0000000100ed7c7c proto_dhcpv6_udp.dylib`mod_bootstrap(mctx=0x000000016fdfdd60) at proto_dhcpv6_udp.c:564:9
    frame #3: 0x00000001002aecbc libfreeradius-io.dylib`mod_bootstrap(mctx=0x000000016fdfe100) at master.c:2610:41
    frame #4: 0x0000000100b85260 proto_dhcpv6.dylib`mod_bootstrap(mctx=0x000000016fdfe890) at proto_dhcpv6.c:470:9
    frame #5: 0x0000000100619bd8 libfreeradius-server.dylib`module_bootstrap(mi=0x0000000102214890) at module.c:778:7
    frame #6: 0x0000000100619d0c libfreeradius-server.dylib`modules_bootstrap(ml=0x0000600002fa85e0) at module.c:811:7
    frame #7: 0x000000010066c9b0 libfreeradius-server.dylib`virtual_servers_bootstrap(config=0x0000000100ff2c30) at virtual_servers.c:1301:6
    frame #8: 0x00000001005ce87c libfreeradius-server.dylib`server_init(cs=0x0000000100ff2c30) at base.c:68:6
    frame #9: 0x00000001000043a0 radiusd`main(argc=7, argv=0x000000016fdfecb8) at radiusd.c:788:6

src/listen/dhcpv6/proto_dhcpv6.c
src/listen/dhcpv6/proto_dhcpv6_udp.c
src/protocols/dhcpv6/base.c

index 608596081f3ae82c22ce210096b02a0ec75668f9..45d716f5cf90f17fc28a1f18a4e4ba491ee5c02d 100644 (file)
@@ -430,7 +430,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        /*
         *      Ensure that the server CONF_SECTION is always set.
         */
-       inst->io.server_cs = cf_item_to_section(cf_parent(mctx->inst->data));
+       inst->io.server_cs = cf_item_to_section(cf_parent(mctx->inst->conf));
 
        fr_assert(dict_dhcpv6 != NULL);
        fr_assert(attr_packet_type != NULL);
index c1ae787fac9f633ea483de9d5203a26cd000bef4..5bf7683fa63efdbd62f2edb8896778fb34cfeb09 100644 (file)
@@ -561,7 +561,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
         *      Get the MAC address associated with this interface.
         *      It can be used to create a server ID.
         */
-       (void) fr_interface_to_ethernet(inst->interface, &inst->ethernet);
+       if (inst->interface) fr_interface_to_ethernet(inst->interface, &inst->ethernet);
 
        if (inst->recv_buff_is_set) {
                FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
index a079ec2290cecca28a5ef47771e68ac209ab7341..b20681ab4355b9769e5ab7864ea6ac6854c17f15 100644 (file)
@@ -583,8 +583,6 @@ ssize_t     fr_dhcpv6_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *pa
        fr_pair_t               *vp;
        fr_pair_list_t          tmp;
 
-       fr_pair_list_init(&tmp);
-
        if (packet_len < DHCPV6_HDR_LEN) return 0; /* protect access to packet[0] */
 
        /*
@@ -593,6 +591,7 @@ ssize_t     fr_dhcpv6_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *pa
        vp = fr_pair_afrom_da(ctx, attr_packet_type);
        if (!vp) return -1;
 
+       fr_pair_list_init(&tmp);
        vp->vp_uint32 = packet[0];
        fr_pair_append(&tmp, vp);