]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Deal with complaints about len parameter of fr_udp_checksum (CIDs below) (#4712)
authorJames Jones <jejones3141@gmail.com>
Mon, 12 Sep 2022 23:41:25 +0000 (18:41 -0500)
committerGitHub <noreply@github.com>
Mon, 12 Sep 2022 23:41:25 +0000 (19:41 -0400)
15040681503957, 150468: use the value l4_len directly so it's not
                          fed through two byte swaps and hence tainted.

src/lib/util/net.c
src/protocols/dhcpv4/pcap.c
src/protocols/dhcpv4/raw.c

index 585ac9d9bcc3b33123d724b6c93fc06efc398c19..ca36d6f5561acffd7dcc6a504e271475a1e5f74b 100644 (file)
@@ -89,7 +89,7 @@ size_t fr_net_af_table_len = NUM_ELEMENTS(fr_net_af_table);
                return -1;
        }
 
-       expected = fr_udp_checksum((uint8_t const *) udp, ntohs(udp->len), udp->checksum,
+       expected = fr_udp_checksum((uint8_t const *) udp, udp_len, udp->checksum,
                                   ip->ip_src, ip->ip_dst);
        if (udp->checksum != expected) {
                fr_strerror_printf("UDP checksum invalid, packet: 0x%04hx calculated: 0x%04hx",
index 46a08e77e43846cfb5e5a36747dea6a1009a0fb7..41b74ab33a673175354cb67da2ed2d8389770804 100644 (file)
@@ -90,7 +90,7 @@ int fr_dhcpv4_pcap_send(fr_pcap_t *pcap, uint8_t *dst_ether_addr, fr_radius_pack
        memcpy(dhcp, packet->data, packet->data_len);
 
        /* UDP checksum is done here */
-       udp_hdr->checksum = fr_udp_checksum((uint8_t const *)udp_hdr, ntohs(udp_hdr->len), udp_hdr->checksum,
+       udp_hdr->checksum = fr_udp_checksum((uint8_t const *)udp_hdr, l4_len, udp_hdr->checksum,
                                            packet->socket.inet.src_ipaddr.addr.v4,
                                            packet->socket.inet.dst_ipaddr.addr.v4);
 
index 78f4df87f4edc7265b6c5ce8fe5835b573da3355..a92fddba9c17f3c30651867ccb6cab95e9298ee8 100644 (file)
@@ -153,7 +153,7 @@ int fr_dhcpv4_raw_packet_send(int sockfd, struct sockaddr_ll *link_layer,
 
        /* UDP checksum is done here */
        udp_hdr->checksum = fr_udp_checksum((uint8_t const *)(dhcp_packet + ETH_HDR_SIZE + IP_HDR_SIZE),
-                                           ntohs(udp_hdr->len), udp_hdr->checksum,
+                                           l4_len, udp_hdr->checksum,
                                            packet->socket.inet.src_ipaddr.addr.v4, packet->socket.inet.dst_ipaddr.addr.v4);
 
        return sendto(sockfd, dhcp_packet, (ETH_HDR_SIZE + IP_HDR_SIZE + UDP_HDR_SIZE + packet->data_len),