Skip to content

Commit

Permalink
developer checks that the code we write isn't broken
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Nov 27, 2015
1 parent aa6d415 commit 01b130a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/lib/radius.c
Expand Up @@ -1057,11 +1057,24 @@ RADIUS_PACKET *rad_recv(TALLOC_CTX *ctx, int fd, int flags)
data_len = rad_recvfrom(fd, packet, UDP_FLAGS_NONE);
if (data_len < 0) {
FR_DEBUG_STRERROR_PRINTF("Error receiving packet: %s", fr_syserror(errno));
/* packet->data is NULL */
rad_free(&packet);
return NULL;
}

#ifdef WITH_VERIFY_PTR
/*
* Double-check that the fields we want are filled in.
*/
if ((packet->src_ipaddr.af == AF_UNSPEC) ||
(packet->src_port == 0) ||
(packet->dst_ipaddr.af == AF_UNSPEC) ||
(packet->dst_port == 0)) {
FR_DEBUG_STRERROR_PRINTF("Error receiving packet: %s", fr_syserror(errno));
rad_free(&packet);
return NULL;
}
#endif

packet->data_len = data_len; /* unsigned vs signed */

/*
Expand All @@ -1071,7 +1084,6 @@ RADIUS_PACKET *rad_recv(TALLOC_CTX *ctx, int fd, int flags)
*/
if (packet->data_len > MAX_PACKET_LEN) {
FR_DEBUG_STRERROR_PRINTF("Discarding packet: Larger than RFC limitation of 4096 bytes");
/* packet->data is NULL */
rad_free(&packet);
return NULL;
}
Expand Down

0 comments on commit 01b130a

Please sign in to comment.