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

Unified Diff: ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc

Issue 2302053003: ozone: Validate the memory buffer used. (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
diff --git a/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc b/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
index 9f9288d56fa316de1bebba9ad6bcafed84844d01..9d35d0ac3f83e0c77c5706e2b507c009e59dacdf 100644
--- a/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
+++ b/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
@@ -69,12 +69,13 @@ ClientNativePixmapDmaBuf::ClientNativePixmapDmaBuf(int dmabuf_fd,
int stride)
: dmabuf_fd_(dmabuf_fd), size_(size), stride_(stride) {
TRACE_EVENT0("drm", "ClientNativePixmapDmaBuf");
- size_t map_size = stride_ * size_.height();
- data_ = mmap(nullptr, map_size, (PROT_READ | PROT_WRITE), MAP_SHARED,
- dmabuf_fd, 0);
+ base::CheckedNumeric<size_t> map_size = stride_;
+ map_size *= size_.height();
+ data_ = mmap(nullptr, map_size.ValueOrDie(), (PROT_READ | PROT_WRITE),
rjkroege 2016/09/01 20:45:05 Won't this will kill the caller if the value is in
sadrul 2016/09/02 03:00:19 As discussed offline, I have changed this code to
+ MAP_SHARED, dmabuf_fd, 0);
if (data_ == MAP_FAILED) {
PLOG(ERROR) << "Failed mmap().";
- base::TerminateBecauseOutOfMemory(map_size);
+ base::TerminateBecauseOutOfMemory(map_size.ValueOrDie());
}
}
« 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