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

Side by Side Diff: chrome/browser/safe_browsing/protocol_parser.cc

Issue 39206: NO CODE CHANGE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // Parse the data returned from the SafeBrowsing v2.1 protocol response. 5 // Parse the data returned from the SafeBrowsing v2.1 protocol response.
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <Winsock2.h> 10 #include <Winsock2.h>
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 289
290 const int chunk_len = atoi(cmd_parts[3].c_str()); 290 const int chunk_len = atoi(cmd_parts[3].c_str());
291 chunk_data += line_len; 291 chunk_data += line_len;
292 remaining -= line_len; 292 remaining -= line_len;
293 293
294 chunks->push_back(SBChunk()); 294 chunks->push_back(SBChunk());
295 chunks->back().chunk_number = chunk_number; 295 chunks->back().chunk_number = chunk_number;
296 296
297 if (cmd_parts[0] == "a") { 297 if (cmd_parts[0] == "a") {
298 chunks->back().is_add = true; 298 chunks->back().is_add = true;
299 if (!ParseAddChunk(chunk_data, chunk_len, hash_len, &chunks->back().hosts) ) 299 if (!ParseAddChunk(chunk_data, chunk_len, hash_len,
300 &chunks->back().hosts))
300 return false; // Parse error. 301 return false; // Parse error.
301 } else if (cmd_parts[0] == "s") { 302 } else if (cmd_parts[0] == "s") {
302 chunks->back().is_add = false; 303 chunks->back().is_add = false;
303 if (!ParseSubChunk(chunk_data, chunk_len, hash_len, &chunks->back().hosts) ) 304 if (!ParseSubChunk(chunk_data, chunk_len, hash_len,
305 &chunks->back().hosts))
304 return false; // Parse error. 306 return false; // Parse error.
305 } else { 307 } else {
306 NOTREACHED(); 308 NOTREACHED();
307 return false; 309 return false;
308 } 310 }
309 311
310 chunk_data += chunk_len; 312 chunk_data += chunk_len;
311 remaining -= chunk_len; 313 remaining -= chunk_len;
312 if (remaining < 0) 314 if (remaining < 0)
313 return false; // Parse error. 315 return false; // Parse error.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 entry = hosts->back().entry->Enlarge(prefix_count); 349 entry = hosts->back().entry->Enlarge(prefix_count);
348 hosts->back().entry = entry; 350 hosts->back().entry = entry;
349 } else { 351 } else {
350 entry = SBEntry::Create(type, prefix_count); 352 entry = SBEntry::Create(type, prefix_count);
351 SBChunkHost chunk_host; 353 SBChunkHost chunk_host;
352 chunk_host.host = host; 354 chunk_host.host = host;
353 chunk_host.entry = entry; 355 chunk_host.entry = entry;
354 hosts->push_back(chunk_host); 356 hosts->push_back(chunk_host);
355 } 357 }
356 358
357 if (!ReadPrefixes(&chunk_data, &remaining, entry, prefix_count, index_start) ) 359 if (!ReadPrefixes(&chunk_data, &remaining, entry, prefix_count,
360 index_start))
358 return false; 361 return false;
359 } 362 }
360 363
361 return remaining == 0; 364 return remaining == 0;
362 } 365 }
363 366
364 bool SafeBrowsingProtocolParser::ParseSubChunk( 367 bool SafeBrowsingProtocolParser::ParseSubChunk(
365 const char* data, int data_len, int hash_len, 368 const char* data, int data_len, int hash_len,
366 std::deque<SBChunkHost>* hosts) { 369 std::deque<SBChunkHost>* hosts) {
367 370
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 482
480 data += line.size() + 1; 483 data += line.size() + 1;
481 remaining -= static_cast<int>(line.size()) + 1; 484 remaining -= static_cast<int>(line.size()) + 1;
482 } 485 }
483 486
484 if (client_key->empty() || wrapped_key->empty()) 487 if (client_key->empty() || wrapped_key->empty())
485 return false; 488 return false;
486 489
487 return true; 490 return true;
488 } 491 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/protocol_manager_unittest.cc ('k') | chrome/browser/safe_browsing/protocol_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698