Index: base/shared_memory_posix.cc |
=================================================================== |
--- base/shared_memory_posix.cc (revision 175576) |
+++ base/shared_memory_posix.cc (working copy) |
@@ -98,7 +98,7 @@ |
DPLOG(ERROR) << "close"; |
} |
-bool SharedMemory::CreateAndMapAnonymous(uint32 size) { |
+bool SharedMemory::CreateAndMapAnonymous(size_t size) { |
return CreateAnonymous(size) && Map(size); |
} |
@@ -113,6 +113,9 @@ |
DCHECK_EQ(-1, mapped_file_); |
if (options.size == 0) return false; |
+ if (options.size > static_cast<size_t>(std::numeric_limits<int>::max())) |
+ return false; |
+ |
// This function theoretically can block on the disk, but realistically |
// the temporary files we create will just go into the buffer cache |
// and be deleted before they ever make it out to disk. |
@@ -153,7 +156,7 @@ |
file_util::CloseFile(fp); |
return false; |
} |
- const uint32 current_size = stat.st_size; |
+ const size_t current_size = stat.st_size; |
if (current_size != options.size) { |
if (HANDLE_EINTR(ftruncate(fileno(fp), options.size)) != 0) { |
file_util::CloseFile(fp); |
@@ -216,10 +219,13 @@ |
#endif // !defined(OS_ANDROID) |
-bool SharedMemory::Map(uint32 bytes) { |
+bool SharedMemory::Map(size_t bytes) { |
if (mapped_file_ == -1) |
return false; |
+ if (bytes > static_cast<size_t>(std::numeric_limits<int>::max())) |
+ return false; |
+ |
#if defined(OS_ANDROID) |
if (bytes == 0) { |
int ashmem_bytes = ashmem_get_size_region(mapped_file_); |