Skip to content

Commit

Permalink
Clean-up.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Nov 30, 2023
1 parent c608e85 commit 427c077
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ int hostent_shm_cpy(struct hostent *dst, struct hostent* src)
int i;
char *p;

len = strlen(src->h_name)+1;
dst->h_name = (char*)shm_malloc(sizeof(char) * len);
if (dst->h_name) strncpy(dst->h_name, src->h_name, len);
else return -1;
len = strlen(src->h_name) + 1;
dst->h_name = (char *)shm_malloc(len);
if (dst->h_name == NULL)
return -1;

for( i=0 ; src->h_addr_list[i] ; i++ );

Expand All @@ -75,6 +75,8 @@ int hostent_shm_cpy(struct hostent *dst, struct hostent* src)
return -1;
}

memcpy(dst->h_name, src->h_name, len);

p = ((char*)dst->h_addr_list) + (i+1)*sizeof(char*);
dst->h_addr_list[i] = 0;

Expand Down

0 comments on commit 427c077

Please sign in to comment.