Skip to content

Commit

Permalink
Merge pull request FRRouting#14796 from donaldsharp/ospf_bsd_double_w…
Browse files Browse the repository at this point in the history
…hammy_no_whammy

lib: Prevent infinite loop in ospf
  • Loading branch information
ton31337 authored Nov 15, 2023
2 parents 858cc75 + 1c0f3b6 commit 3a109ef
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/sockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ void setsockopt_so_recvbuf(int sock, int size)
{
int orig_req = size;

while (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size))
== -1)
while (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)) ==
-1) {
if (size == 0)
break;
size /= 2;
}

if (size != orig_req)
flog_err(EC_LIB_SOCKET,
Expand All @@ -37,9 +40,12 @@ void setsockopt_so_sendbuf(const int sock, int size)
{
int orig_req = size;

while (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size))
== -1)
while (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) ==
-1) {
if (size == 0)
break;
size /= 2;
}

if (size != orig_req)
flog_err(EC_LIB_SOCKET,
Expand Down

0 comments on commit 3a109ef

Please sign in to comment.