Skip to content

Commit

Permalink
[#426] Fix a problem in pgagroal_bind
Browse files Browse the repository at this point in the history
If the configuration `host` is set to `*`, meaning all the interfaces,
the `pgagroal_bind` function was always returning a true value even if
no available bind addresses were left.
In order to fix this, the commit tests if the `star_length` variable
has been set to something non-zero, otherwise no more sockets are
available (bound) and the function returns a `1` to indicate an error.

Close #426
  • Loading branch information
fluca1978 authored and jesperpedersen committed Apr 4, 2024
1 parent 5dcfb89 commit 438db2e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libpgagroal/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,17 @@ pgagroal_bind(const char* hostname, int port, int** fds, int* length, bool non_b
}
}

freeifaddrs(ifaddr);

if (star_length == 0)
{
// cannot bind to anything!
return 1;
}

*fds = star_fds;
*length = star_length;

freeifaddrs(ifaddr);
return 0;
}

Expand Down

0 comments on commit 438db2e

Please sign in to comment.