Reputation: 37
EDIT: Removed code/explanation because this project has been given again and students can easily find the solution via this post.
To clarify what happened, I simply passed the wrong length/size in my recvfrom() call.
Upvotes: 1
Views: 959
Reputation: 239011
In this line:
if(recvfrom( temp->sockfd, sendHostIP, BUFFER_LEN, 0, (struct sockaddr *)&recvAddr, &recvLen) < 0)
errorMsg("recvfrom");
You pass BUFFER_LEN
as the length (256), but sendHostIP
is only of length MAXHOSTNAMELEN
(64).
This causes recvfrom()
to overflow that buffer. The same problem occurs when you read in to localHostIP
.
Upvotes: 1