Fix some clatd cloexec and file descriptor leaking via missing close()
Not terribly important since clatd doesn't exec anything,
but was muddying the waters while I was searching for other
fd-survives-across-exec leakage in netd. While at it also
fix another leaked fd which we forgot to close().
Test: builds and boots
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iceb7d4052dc9be29db5c7bb3fe2ee27da7864379
diff --git a/ring.c b/ring.c
index 61d40d2..e836a55 100644
--- a/ring.c
+++ b/ring.c
@@ -30,7 +30,7 @@
#include "tun.h"
int ring_create(struct tun_data *tunnel) {
- int packetsock = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6));
+ int packetsock = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, htons(ETH_P_IPV6));
if (packetsock < 0) {
logmsg(ANDROID_LOG_FATAL, "packet socket failed: %s", strerror(errno));
return -1;