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

Side by Side Diff: net/spdy/fuzzing/hpack_fuzz_wrapper.cc

Issue 296513013: Cleanup: Use base::CommandLine in net/ (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/fuzzing/hpack_fuzz_mutator.cc ('k') | net/test/python_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "net/spdy/fuzzing/hpack_fuzz_util.h" 8 #include "net/spdy/fuzzing/hpack_fuzz_util.h"
9 9
10 namespace { 10 namespace {
11 11
12 // Specifies a file having HPACK header sets. 12 // Specifies a file having HPACK header sets.
13 const char kFileToParse[] = "file-to-parse"; 13 const char kFileToParse[] = "file-to-parse";
14 14
15 } // namespace 15 } // namespace
16 16
17 using base::StringPiece; 17 using base::StringPiece;
18 using net::HpackFuzzUtil; 18 using net::HpackFuzzUtil;
19 using std::string; 19 using std::string;
20 20
21 // Sequentially runs each given length-prefixed header block through 21 // Sequentially runs each given length-prefixed header block through
22 // decoding and encoding fuzzing stages (using HpackFuzzUtil). 22 // decoding and encoding fuzzing stages (using HpackFuzzUtil).
23 int main(int argc, char** argv) { 23 int main(int argc, char** argv) {
24 base::AtExitManager exit_manager; 24 base::AtExitManager exit_manager;
25 25
26 CommandLine::Init(argc, argv); 26 base::CommandLine::Init(argc, argv);
27 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 27 const base::CommandLine& command_line =
28 *base::CommandLine::ForCurrentProcess();
28 29
29 if (!command_line.HasSwitch(kFileToParse)) { 30 if (!command_line.HasSwitch(kFileToParse)) {
30 LOG(ERROR) << "Usage: " << argv[0] 31 LOG(ERROR) << "Usage: " << argv[0]
31 << " --" << kFileToParse << "=/path/to/file.in"; 32 << " --" << kFileToParse << "=/path/to/file.in";
32 return -1; 33 return -1;
33 } 34 }
34 string file_to_parse = command_line.GetSwitchValueASCII(kFileToParse); 35 string file_to_parse = command_line.GetSwitchValueASCII(kFileToParse);
35 36
36 // ClusterFuzz may invoke as --file-to-parse="". Don't crash in this case. 37 // ClusterFuzz may invoke as --file-to-parse="". Don't crash in this case.
37 if (file_to_parse.empty()) { 38 if (file_to_parse.empty()) {
(...skipping 11 matching lines...) Expand all
49 50
50 size_t block_count = 0; 51 size_t block_count = 0;
51 StringPiece block; 52 StringPiece block;
52 while (HpackFuzzUtil::NextHeaderBlock(&input, &block)) { 53 while (HpackFuzzUtil::NextHeaderBlock(&input, &block)) {
53 HpackFuzzUtil::RunHeaderBlockThroughFuzzerStages(&context, block); 54 HpackFuzzUtil::RunHeaderBlockThroughFuzzerStages(&context, block);
54 ++block_count; 55 ++block_count;
55 } 56 }
56 DVLOG(1) << "Fuzzed " << block_count << " blocks."; 57 DVLOG(1) << "Fuzzed " << block_count << " blocks.";
57 return 0; 58 return 0;
58 } 59 }
OLDNEW
« no previous file with comments | « net/spdy/fuzzing/hpack_fuzz_mutator.cc ('k') | net/test/python_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698