From: Alan T. DeKok Date: Mon, 1 Apr 2019 15:00:33 +0000 (-0400) Subject: check for min packet size here, too X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9ecdbb2e9affe75916df6a49d37a6df44eb2d73;p=thirdparty%2Ffreeradius-server.git check for min packet size here, too --- diff --git a/src/modules/proto_dhcpv4/proto_dhcpv4.c b/src/modules/proto_dhcpv4/proto_dhcpv4.c index 6055f4390bd..096a7e82734 100644 --- a/src/modules/proto_dhcpv4/proto_dhcpv4.c +++ b/src/modules/proto_dhcpv4/proto_dhcpv4.c @@ -369,7 +369,12 @@ static ssize_t mod_encode(void const *instance, REQUEST *request, uint8_t *buffe return sizeof(new_client); } - memset(reply, 0, sizeof(*reply)); + if (buffer_len < MIN_PACKET_SIZE) { + REDEBUG("Output buffer is too small to hold a DHCPv4 packet."); + return -1; + } + + memset(buffer, 0, buffer_len); /* * Initialize the output packet from the input packet.