summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2012-06-04 05:28:19 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2012-06-04 05:32:51 +0200
commit31bc47b8280fd9824c8ba914ea6bdba6e2a50986 (patch)
treeddbf754dc050609a800d08a30d6c470d3418d872
parentProperly convert ipv6 mapped ipv4 addresses. (diff)
downloadtelnet-password-honeypot-31bc47b8280fd9824c8ba914ea6bdba6e2a50986.tar.xz
telnet-password-honeypot-31bc47b8280fd9824c8ba914ea6bdba6e2a50986.zip
Close fds in parent process.
-rw-r--r--honeypot.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/honeypot.c b/honeypot.c
index 8bff054..b42c776 100644
--- a/honeypot.c
+++ b/honeypot.c
@@ -500,6 +500,8 @@ int main(int argc, char *argv[])
if (!child) {
char ipaddr[INET6_ADDRSTRLEN];
struct in6_addr *v6;
+
+ close(listen_fd);
memset(ipaddr, 0, sizeof(ipaddr));
if (connection_addr.ss_family == AF_INET6) {
v6 = &(((struct sockaddr_in6 *)&connection_addr)->sin6_addr);
@@ -511,7 +513,8 @@ int main(int argc, char *argv[])
inet_ntop(AF_INET, &(((struct sockaddr_in *)&connection_addr)->sin_addr), ipaddr, INET_ADDRSTRLEN);
printf("Forked process %d for connection %s.\n", getpid(), ipaddr);
handle_connection(connection_fd, ipaddr);
- }
+ } else
+ close(connection_fd);
}
fclose(logfile);
return 0;