mirror of
https://github.com/yrutschle/sslh.git
synced 2026-10-22 18:12:10 +03:00
start_listen_sockets: exit if no addresses
Do not allocate a 0 byte buffer if no addresses are available:
common.c:122:14: warning: Call to 'malloc' has an allocation size of 0 bytes
*sockfd = malloc(num_addr * sizeof(*sockfd[0]));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
1 parent
552723cc5f
commit
c179d9a57b
1 file changed
+5
@@ -116,6 +116,11 @@ int start_listen_sockets(int *sockfd[], struct addrinfo *addr_list)
|
||||
for (addr = addr_list; addr; addr = addr->ai_next)
|
||||
num_addr++;
|
||||
|
||||
if (num_addr == 0) {
|
||||
fprintf(stderr, "FATAL: No available addresses.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr, "listening to %d addresses\n", num_addr);
|
||||
|
||||
|
||||
Reference in new issue
Block a user