libnetd_client: support hooking sendto/sendmsg/sendmmsg too.
Samsung has asked for this for KNOX.
Test: treehugger
Change-Id: Iffaace9f8cb265ce8c911472989c9829cbf91a42
diff --git a/libc/bionic/NetdClient.cpp b/libc/bionic/NetdClient.cpp
index 87eec27..d9debbf 100644
--- a/libc/bionic/NetdClient.cpp
+++ b/libc/bionic/NetdClient.cpp
@@ -31,7 +31,7 @@
static void netdClientInitFunction(void* handle, const char* symbol, FunctionType* function) {
typedef void (*InitFunctionType)(FunctionType*);
InitFunctionType initFunction = reinterpret_cast<InitFunctionType>(dlsym(handle, symbol));
- if (initFunction != NULL) {
+ if (initFunction != nullptr) {
initFunction(function);
}
}
@@ -45,20 +45,23 @@
return;
}
- void* netdClientHandle = dlopen("libnetd_client.so", RTLD_NOW);
- if (netdClientHandle == NULL) {
+ void* handle = dlopen("libnetd_client.so", RTLD_NOW);
+ if (handle == nullptr) {
// If the library is not available, it's not an error. We'll just use
// default implementations of functions that it would've overridden.
return;
}
- netdClientInitFunction(netdClientHandle, "netdClientInitAccept4",
- &__netdClientDispatch.accept4);
- netdClientInitFunction(netdClientHandle, "netdClientInitConnect",
- &__netdClientDispatch.connect);
- netdClientInitFunction(netdClientHandle, "netdClientInitNetIdForResolv",
+
+ netdClientInitFunction(handle, "netdClientInitAccept4", &__netdClientDispatch.accept4);
+ netdClientInitFunction(handle, "netdClientInitConnect", &__netdClientDispatch.connect);
+ netdClientInitFunction(handle, "netdClientInitSendmmsg", &__netdClientDispatch.sendmmsg);
+ netdClientInitFunction(handle, "netdClientInitSendmsg", &__netdClientDispatch.sendmsg);
+ netdClientInitFunction(handle, "netdClientInitSendto", &__netdClientDispatch.sendto);
+ netdClientInitFunction(handle, "netdClientInitSocket", &__netdClientDispatch.socket);
+
+ netdClientInitFunction(handle, "netdClientInitNetIdForResolv",
&__netdClientDispatch.netIdForResolv);
- netdClientInitFunction(netdClientHandle, "netdClientInitSocket", &__netdClientDispatch.socket);
- netdClientInitFunction(netdClientHandle, "netdClientInitDnsOpenProxy",
+ netdClientInitFunction(handle, "netdClientInitDnsOpenProxy",
&__netdClientDispatch.dnsOpenProxy);
}