Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2166)

Unified Diff: net/udp/udp_socket_posix.cc

Issue 2104533002: Ensure native library isn't actually loaded, and no IO on net thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: redo with dlopen directly Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/udp/udp_socket_posix.cc
diff --git a/net/udp/udp_socket_posix.cc b/net/udp/udp_socket_posix.cc
index 401158289a7a730886f59ad5035f132b82114275..20c2a991f38a354a29126f483734d0d025a8a324 100644
--- a/net/udp/udp_socket_posix.cc
+++ b/net/udp/udp_socket_posix.cc
@@ -4,6 +4,7 @@
#include "net/udp/udp_socket_posix.h"
+#include <dlfcn.h>
xunjieli 2016/06/29 13:35:09 Should this header be in the #if defined(OS_ANDROI
pauljensen 2016/06/29 13:45:49 Done.
#include <errno.h>
#include <fcntl.h>
#include <net/if.h>
@@ -35,6 +36,8 @@
#include "base/android/build_info.h"
#include "base/native_library.h"
#include "base/strings/utf_string_conversions.h"
+// This was added in Lollipop to dlfcn.h
+#define RTLD_NOLOAD 4
#endif
namespace net {
@@ -351,11 +354,11 @@ int UDPSocketPosix::BindToNetwork(
// shouldn't matter.
if (!setNetworkForSocket) {
// Android's netd client library should always be loaded in our address
- // space as it shims libc functions like connect().
+ // space as it shims socket() which was used to create |socket_|.
base::FilePath file(base::GetNativeLibraryName("netd_client"));
- base::NativeLibrary lib = base::LoadNativeLibrary(file, nullptr);
- setNetworkForSocket = reinterpret_cast<SetNetworkForSocket>(
- base::GetFunctionPointerFromNativeLibrary(lib, "setNetworkForSocket"));
+ void* dl = dlopen(file.value().c_str(), RTLD_NOW | RTLD_NOLOAD);
xunjieli 2016/06/29 13:35:09 Could add a brief comment on the flags (RTLD_NOW |
pauljensen 2016/06/29 13:45:50 Done.
+ setNetworkForSocket =
+ reinterpret_cast<SetNetworkForSocket>(dlsym(dl, "setNetworkForSocket"));
}
if (!setNetworkForSocket)
return ERR_NOT_IMPLEMENTED;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698