Skip to content

Commit

Permalink
Merge pull request #14801 from FRRouting/mergify/bp/stable/9.1/pr-14796
Browse files Browse the repository at this point in the history
lib: Prevent infinite loop in ospf (backport #14796)
  • Loading branch information
ton31337 authored Nov 15, 2023
2 parents b3bf380 + 77fe290 commit 612f1f5
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 @@ -24,9 +24,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 @@ -38,9 +41,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 612f1f5

Please sign in to comment.