* Too little data is available, discard the packet.
*/
if (data_len < 4) {
+ fr_strerror_printf("Expected at least 4 bytes of header data, got %zu bytes", data_len);
rad_recv_discard(sockfd);
return 1;
* a RADIUS header length: discard it.
*/
if (packet_len < RADIUS_HDR_LEN) {
+ fr_strerror_printf("Expected at least " STRINGIFY(RADIUS_HDR_LEN) " bytes of packet "
+ "data, got %zu bytes", packet_len);
rad_recv_discard(sockfd);
return 1;
* Anything after 4k will be discarded.
*/
} else if (packet_len > MAX_PACKET_LEN) {
+ fr_strerror_printf("Length field value too large, expected maximum of "
+ STRINGIFY(MAX_PACKET_LEN) " bytes, got %zu bytes", packet_len);
rad_recv_discard(sockfd);
return 1;
* Convert AF. If unknown, discard packet.
*/
if (!fr_sockaddr2ipaddr(&src, sizeof_src, src_ipaddr, src_port)) {
+ fr_strerror_printf("Unkown address family");
rad_recv_discard(sockfd);
return 1;
FR_STATS_INC(auth, total_requests);
if (rcode < 20) { /* RADIUS_HDR_LEN */
+ RATE_LIMIT(ERROR("Received malformed packet: %s", fr_strerror()));
FR_STATS_INC(auth, total_malformed_requests);
return 0;
}