Skip to content

Commit

Permalink
Fix resource leak in lnx_eth_init_socket
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviojs committed Mar 10, 2024
1 parent 5792be8 commit 74c13f2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/linux_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ int lnx_eth_init_socket(char *device)

if (bind(sck,(struct sockaddr *)&sa,sizeof(struct sockaddr_ll)) == -1) {
fprintf(stderr,"eth_init_socket: bind: %s\n",strerror(errno));
close(sck);
return(-1);
}

if (setsockopt(sck,SOL_PACKET,PACKET_ADD_MEMBERSHIP,
&mreq,sizeof(mreq)) == -1)
{
fprintf(stderr,"eth_init_socket: setsockopt: %s\n",strerror(errno));
close(sck);
return(-1);
}

Expand Down

0 comments on commit 74c13f2

Please sign in to comment.