mirror of
https://github.com/yrutschle/sslh.git
synced 2026-11-18 02:42:23 +03:00
echosrv: fix undersized realloc in start_listen_sockets()
sizeof(*sockfd) is the size of a pointer, not of struct listen_endpoint, so the second listen address overflows the buffer and corrupts the heap. This makes echosrv segfault on armhf and the test suite fail.
This commit is contained in:
1 parent
39d164f5a8
commit
e722274b63
1 file changed
+1
-1
@@ -318,7 +318,7 @@ int start_listen_sockets(struct listen_endpoint *sockfd[])
|
||||
|
||||
for (addr = start_addr; addr; addr = addr->ai_next) {
|
||||
num_addr++;
|
||||
*sockfd = realloc(*sockfd, num_addr * sizeof(*sockfd));
|
||||
*sockfd = realloc(*sockfd, num_addr * sizeof(**sockfd));
|
||||
(*sockfd)[num_addr-1].socketfd = listen_single_addr(addr, keepalive, udp);
|
||||
(*sockfd)[num_addr-1].type = udp ? SOCK_DGRAM : SOCK_STREAM;
|
||||
fprintf(stderr, "%d:\t%s\n", (*sockfd)[num_addr-1].socketfd, sprintaddr(buf, sizeof(buf), addr));
|
||||
|
||||
Reference in new issue
Block a user