OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/external_ipc_fuzzer.h" | 5 #include "chrome/common/external_ipc_fuzzer.h" |
6 | 6 |
7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
9 #endif | |
10 | 9 |
11 typedef IPC::ChannelProxy::OutgoingMessageFilter *(*GetFuzzerFunction)(); | 10 typedef IPC::ChannelProxy::OutgoingMessageFilter *(*GetFuzzerFunction)(); |
12 const char kFuzzLibraryName[] = "libipcfuzz.so"; | 11 const char kFuzzLibraryName[] = "libipcfuzz.so"; |
13 const char kFuzzEntryName[] = "GetFilter"; | 12 const char kFuzzEntryName[] = "GetFilter"; |
| 13 #endif |
14 | 14 |
15 IPC::ChannelProxy::OutgoingMessageFilter* LoadExternalIPCFuzzer() { | 15 IPC::ChannelProxy::OutgoingMessageFilter* LoadExternalIPCFuzzer() { |
16 IPC::ChannelProxy::OutgoingMessageFilter* result = NULL; | 16 IPC::ChannelProxy::OutgoingMessageFilter* result = NULL; |
17 | 17 |
18 #if defined(OS_LINUX) | 18 #if defined(OS_LINUX) |
19 | |
20 // Fuzz is currently linux-only feature | 19 // Fuzz is currently linux-only feature |
21 void *fuzz_library = dlopen(kFuzzLibraryName, RTLD_NOW); | 20 void *fuzz_library = dlopen(kFuzzLibraryName, RTLD_NOW); |
22 if (fuzz_library) { | 21 if (fuzz_library) { |
23 GetFuzzerFunction fuzz_entry_point = | 22 GetFuzzerFunction fuzz_entry_point = |
24 reinterpret_cast<GetFuzzerFunction>( | 23 reinterpret_cast<GetFuzzerFunction>( |
25 dlsym(fuzz_library, kFuzzEntryName)); | 24 dlsym(fuzz_library, kFuzzEntryName)); |
26 | 25 |
27 if (fuzz_entry_point) | 26 if (fuzz_entry_point) |
28 result = fuzz_entry_point(); | 27 result = fuzz_entry_point(); |
29 } | 28 } |
30 | 29 |
31 if (!result) | 30 if (!result) |
32 LOG(WARNING) << dlerror() << "\n"; | 31 LOG(WARNING) << dlerror() << "\n"; |
33 | 32 |
34 #endif // OS_LINUX | 33 #endif // OS_LINUX |
35 | 34 |
36 return result; | 35 return result; |
37 } | 36 } |
38 | 37 |
39 | 38 |
40 | 39 |
OLD | NEW |