OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/utility/media_galleries/pmp_column_reader.h" | 5 #include "chrome/utility/media_galleries/pmp_column_reader.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <cstring> | 9 #include <cstring> |
| 10 #include <limits> |
8 | 11 |
9 #include "base/files/file.h" | 12 #include "base/files/file.h" |
10 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
11 #include "base/logging.h" | 14 #include "base/logging.h" |
12 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
13 | 16 |
14 namespace picasa { | 17 namespace picasa { |
15 | 18 |
16 namespace { | 19 namespace { |
17 | 20 |
(...skipping 22 matching lines...) Expand all Loading... |
40 return false; | 43 return false; |
41 length_ = info.size; | 44 length_ = info.size; |
42 | 45 |
43 if (length_ < kPmpHeaderSize || length_ > kPmpMaxFilesize) | 46 if (length_ < kPmpHeaderSize || length_ > kPmpMaxFilesize) |
44 return false; | 47 return false; |
45 | 48 |
46 data_.reset(new uint8[length_]); | 49 data_.reset(new uint8[length_]); |
47 | 50 |
48 char* data_begin = reinterpret_cast<char*>(data_.get()); | 51 char* data_begin = reinterpret_cast<char*>(data_.get()); |
49 | 52 |
50 DCHECK(length_ < kint32max); // ReadFile expects an int. | 53 DCHECK(length_ < |
| 54 std::numeric_limits<int32_t>::max()); // ReadFile expects an int. |
51 | 55 |
52 bool success = file->Read(0, data_begin, length_) && | 56 bool success = file->Read(0, data_begin, length_) && |
53 ParseData(expected_type); | 57 ParseData(expected_type); |
54 | 58 |
55 // If any of the reading or parsing fails, prevent Read* calls. | 59 // If any of the reading or parsing fails, prevent Read* calls. |
56 if (!success) | 60 if (!success) |
57 rows_read_ = 0; | 61 rows_read_ = 0; |
58 | 62 |
59 return success; | 63 return success; |
60 } | 64 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 200 |
197 strings_.push_back(reinterpret_cast<const char*>(data_cursor)); | 201 strings_.push_back(reinterpret_cast<const char*>(data_cursor)); |
198 data_cursor += length_in_bytes; | 202 data_cursor += length_in_bytes; |
199 bytes_parsed += length_in_bytes; | 203 bytes_parsed += length_in_bytes; |
200 } | 204 } |
201 | 205 |
202 return bytes_parsed - kPmpHeaderSize; | 206 return bytes_parsed - kPmpHeaderSize; |
203 } | 207 } |
204 | 208 |
205 } // namespace picasa | 209 } // namespace picasa |
OLD | NEW |