fr_strerror_printf("Failed allocating packet");
return NULL;
}
- memset(packet, 0, sizeof(packet));
+ memset(packet, 0, sizeof(*packet));
packet->data = malloc(MAX_PACKET_SIZE);
if (!packet->data) {
if (packet->data_len < MIN_PACKET_SIZE) {
fr_strerror_printf("DHCP packet is too small (%d < %d)",
- packet->data_len, MIN_PACKET_SIZE);
+ packet->data_len, MIN_PACKET_SIZE);
rad_free(&packet);
return NULL;
}
/*
* This should never fail...
*/
- getsockname(sockfd, (struct sockaddr *) &dst, &sizeof_dst);
+ if (getsockname(sockfd, (struct sockaddr *) &dst, &sizeof_dst) < 0) {
+ fr_strerror_printf("getsockname failed: %s", strerror(errno));
+ rad_free(&packet);
+ return NULL;
+ }
#endif
fr_sockaddr2ipaddr(&dst, sizeof_dst, &packet->dst_ipaddr, &port);
* Assume that the packet is encoded before sending it.
*/
return sendto(packet->sockfd, packet->data, packet->data_len, 0,
- (struct sockaddr *)&dst, sizeof_dst);
+ (struct sockaddr *)&dst, sizeof_dst);
#else
return sendfromto(packet->sockfd, packet->data, packet->data_len, 0,
- (struct sockaddr *)&src, sizeof_src,
- (struct sockaddr *)&dst, sizeof_dst);
+ (struct sockaddr *)&src, sizeof_src,
+ (struct sockaddr *)&dst, sizeof_dst);
#endif
}
case PW_TYPE_IPADDR:
if (alen != 4) goto raw;
- memcpy(&vp->vp_ipaddr, p , 4); /* Keep value in Network Order!!! */
+ /*
+ * Keep value in Network Order!
+ */
+ memcpy(&vp->vp_ipaddr, p , 4);
vp->length = 4;
break;
*/
/*
- * Nothing uses tail after this call, if it does in the future
- * it'll need to find the new tail...
+ * Nothing uses tail after this call, if it does in the future
+ * it'll need to find the new tail...
* FIXME: This should also check sname && file fields.
* See the dhcp_get_option() function above.
*/
}
/*
- * Jump over DHCP magic number, response, etc.
+ * Jump over DHCP magic number, response, etc.
*/
p = pp;
}