Skip to content

Commit 50ff9bf

Browse files
committed
hostent2su: copy hostnames into sockaddr_union_struct
1 parent 26b5c29 commit 50ff9bf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ip_addr.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,11 @@ static inline int hostent2su( union sockaddr_union* su,
374374
unsigned short port )
375375
{
376376
memset(su, 0, sizeof(union sockaddr_union)); /*needed on freebsd*/
377+
378+
/* copy the hostname into the sockaddr_union */
379+
strncpy(su->h.hostname, he->h_name, sizeof(su->h.hostname)-1);
380+
su->h.hostname[sizeof(su->h.hostname)-1] = 0;
381+
377382
su->s.sa_family=he->h_addrtype;
378383
switch(he->h_addrtype){
379384
case AF_INET6:

0 commit comments

Comments
 (0)