Skip to content

Commit

Permalink
Merge pull request #433 from visuve/master
Browse files Browse the repository at this point in the history
Close socket when setsockopt fails
  • Loading branch information
mfontanini authored Mar 6, 2021
2 parents cd40b23 + 468159e commit b447c66
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/packet_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ void PacketSender::open_l3_socket(SocketType type) {
#endif
const int level = (is_v6) ? IPPROTO_IPV6 : IPPROTO_IP;
if (setsockopt(sockfd, level, IP_HDRINCL, (option_ptr)&on, sizeof(on)) != 0) {
#ifndef _WIN32
::close(sockfd);
#else
::closesocket(sockfd);
#endif
throw socket_open_error(make_error_string());
}

Expand Down

0 comments on commit b447c66

Please # to comment.