OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "mojo/system/memory.h" |
| 6 |
| 7 #include <limits> |
| 8 |
| 9 #include "base/logging.h" |
| 10 |
| 11 namespace mojo { |
| 12 namespace system { |
| 13 |
| 14 bool VerifyUserPointer(const void* pointer, size_t count, size_t size_each) { |
| 15 DCHECK_GT(size_each, 0u); |
| 16 if (count > std::numeric_limits<size_t>::max() / size_each) |
| 17 return false; |
| 18 |
| 19 // TODO(vtl): If running in kernel mode, do a full verification. For now, just |
| 20 // check that it's non-null if |size| is nonzero. (A faster user mode |
| 21 // implementation is also possible if this check is skipped.) |
| 22 return count == 0 || !!pointer; |
| 23 } |
| 24 |
| 25 } // namespace system |
| 26 } // namespace mojo |
OLD | NEW |