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

Side by Side Diff: net/http/http_stream_parser_fuzzer.cc

Issue 1920463003: Fix HttpStreamParser fuzzer (again) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "net/http/http_stream_parser.h" 5 #include "net/http/http_stream_parser.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 int result = 58 int result =
59 parser.SendRequest("GET / HTTP/1.1\r\n", net::HttpRequestHeaders(), 59 parser.SendRequest("GET / HTTP/1.1\r\n", net::HttpRequestHeaders(),
60 &response_info, callback.callback()); 60 &response_info, callback.callback());
61 result = callback.GetResult(result); 61 result = callback.GetResult(result);
62 if (net::OK != result) 62 if (net::OK != result)
63 return 0; 63 return 0;
64 64
65 result = parser.ReadResponseHeaders(callback.callback()); 65 result = parser.ReadResponseHeaders(callback.callback());
66 result = callback.GetResult(result); 66 result = callback.GetResult(result);
67 67
68 while (result > 0) { 68 if (result < 0)
69 return 0;
70
71 while (true) {
69 scoped_refptr<net::IOBufferWithSize> io_buffer( 72 scoped_refptr<net::IOBufferWithSize> io_buffer(
70 new net::IOBufferWithSize(64)); 73 new net::IOBufferWithSize(64));
71 result = parser.ReadResponseBody(io_buffer.get(), io_buffer->size(), 74 result = parser.ReadResponseBody(io_buffer.get(), io_buffer->size(),
72 callback.callback()); 75 callback.callback());
73 76
74 // Releasing the pointer to IOBuffer immediately is more likely to lead to a 77 // Releasing the pointer to IOBuffer immediately is more likely to lead to a
75 // use-after-free. 78 // use-after-free.
76 io_buffer = nullptr; 79 io_buffer = nullptr;
77 80 if (callback.GetResult(result) <= 0)
78 result = callback.GetResult(result); 81 break;
79 } 82 }
80 83
81 return 0; 84 return 0;
82 } 85 }
OLDNEW
« 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