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

Side by Side Diff: chrome/browser/policy/preg_parser_win.cc

Issue 23961004: Avoid a write to NULL in ReadFieldBinary (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 3 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 | « 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/browser/policy/preg_parser_win.h" 5 #include "chrome/browser/policy/preg_parser_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 int result = **cursor | (*(*cursor + 1) << 8); 59 int result = **cursor | (*(*cursor + 1) << 8);
60 *cursor += sizeof(char16); 60 *cursor += sizeof(char16);
61 return result; 61 return result;
62 } 62 }
63 63
64 // Reads a fixed-size field from a PReg file. 64 // Reads a fixed-size field from a PReg file.
65 bool ReadFieldBinary(const uint8** cursor, 65 bool ReadFieldBinary(const uint8** cursor,
66 const uint8* end, 66 const uint8* end,
67 int size, 67 int size,
68 uint8* data) { 68 uint8* data) {
69 if (!size)
70 return false;
69 const uint8* field_end = *cursor + size; 71 const uint8* field_end = *cursor + size;
70 if (field_end > end) 72 if (field_end > end)
71 return false; 73 return false;
72 std::copy(*cursor, field_end, data); 74 std::copy(*cursor, field_end, data);
73 *cursor = field_end; 75 *cursor = field_end;
74 return true; 76 return true;
75 } 77 }
76 78
77 bool ReadField32(const uint8** cursor, const uint8* end, uint32* data) { 79 bool ReadField32(const uint8** cursor, const uint8* end, uint32* data) {
78 uint32 value = 0; 80 uint32 value = 0;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 296 }
295 297
296 LOG(ERROR) << "Error parsing " << file_path.value() << " at offset " 298 LOG(ERROR) << "Error parsing " << file_path.value() << " at offset "
297 << reinterpret_cast<const uint8*>(cursor - 1) - mapped_file.data(); 299 << reinterpret_cast<const uint8*>(cursor - 1) - mapped_file.data();
298 status->Add(POLICY_LOAD_STATUS_PARSE_ERROR); 300 status->Add(POLICY_LOAD_STATUS_PARSE_ERROR);
299 return false; 301 return false;
300 } 302 }
301 303
302 } // namespace preg_parser 304 } // namespace preg_parser
303 } // namespace policy 305 } // namespace policy
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