static void
save_pkt(char *name, struct nwho_pkt *pkt)
{
- int len = sizeof(pkt) - (MAX_USERS - ntohl(pkt->num_users))*sizeof(struct userinfo);
+ int len = nwho_pkt_size(pkt);
int fd = open(name, O_WRONLY | O_CREAT, 0666);
if (fd < 0)
{
if (r < n ||
pkt.magic != htonl(NWHO_MAGIC) ||
ntohl(pkt.num_users) > MAX_USERS ||
- r != n + ntohl(pkt.num_users)*sizeof(struct userinfo))
+ r < nwho_pkt_size(&pkt))
{
syslog(LOG_WARNING, "Malformed packet from %s", inet_ntoa(sa.sin_addr));
return;