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

Side by Side Diff: tools/ipc_fuzzer/fuzzer/fuzzer.cc

Issue 2881673002: Avoid heap allocations in IPAddress (Closed)
Patch Set: New constructor Created 3 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 unified diff | Download patch
« no previous file with comments | « remoting/host/ipc_host_event_logger.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <iostream> 5 #include <iostream>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 #include <tuple> 8 #include <tuple>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 return false; 1284 return false;
1285 p->set_host(host); 1285 p->set_host(host);
1286 p->set_port(port); 1286 p->set_port(port);
1287 return true; 1287 return true;
1288 } 1288 }
1289 }; 1289 };
1290 1290
1291 template <> 1291 template <>
1292 struct FuzzTraits<net::IPAddress> { 1292 struct FuzzTraits<net::IPAddress> {
1293 static bool Fuzz(net::IPAddress* p, Fuzzer* fuzzer) { 1293 static bool Fuzz(net::IPAddress* p, Fuzzer* fuzzer) {
1294 std::vector<uint8_t> bytes = p->bytes(); 1294 std::vector<uint8_t> bytes = p->CopyBytesToVector();
1295 if (!FuzzParam(&bytes, fuzzer)) 1295 if (!FuzzParam(&bytes, fuzzer))
1296 return false; 1296 return false;
1297 net::IPAddress ip_address(bytes); 1297 net::IPAddress ip_address(bytes.data(), bytes.size());
1298 *p = ip_address; 1298 *p = ip_address;
1299 return true; 1299 return true;
1300 } 1300 }
1301 }; 1301 };
1302 1302
1303 template <> 1303 template <>
1304 struct FuzzTraits<net::IPEndPoint> { 1304 struct FuzzTraits<net::IPEndPoint> {
1305 static bool Fuzz(net::IPEndPoint* p, Fuzzer* fuzzer) { 1305 static bool Fuzz(net::IPEndPoint* p, Fuzzer* fuzzer) {
1306 net::IPAddress ip_address = p->address(); 1306 net::IPAddress ip_address = p->address();
1307 int port = p->port(); 1307 int port = p->port();
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 #include "tools/ipc_fuzzer/message_lib/all_message_null_macros.h" 1825 #include "tools/ipc_fuzzer/message_lib/all_message_null_macros.h"
1826 #undef IPC_MESSAGE_DECL 1826 #undef IPC_MESSAGE_DECL
1827 #define IPC_MESSAGE_DECL(name, ...) \ 1827 #define IPC_MESSAGE_DECL(name, ...) \
1828 (*map)[static_cast<uint32_t>(name::ID)] = FuzzerHelper<name>::Fuzz; 1828 (*map)[static_cast<uint32_t>(name::ID)] = FuzzerHelper<name>::Fuzz;
1829 1829
1830 void PopulateFuzzerFunctionMap(FuzzerFunctionMap* map) { 1830 void PopulateFuzzerFunctionMap(FuzzerFunctionMap* map) {
1831 #include "tools/ipc_fuzzer/message_lib/all_messages.h" 1831 #include "tools/ipc_fuzzer/message_lib/all_messages.h"
1832 } 1832 }
1833 1833
1834 } // namespace ipc_fuzzer 1834 } // namespace ipc_fuzzer
OLDNEW
« no previous file with comments | « remoting/host/ipc_host_event_logger.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698