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

Unified Diff: mojo/edk/system/channel_win.cc

Issue 1985523002: [mojo-edk] Better validation of untrusted message data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « mojo/edk/system/channel_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/channel_win.cc
diff --git a/mojo/edk/system/channel_win.cc b/mojo/edk/system/channel_win.cc
index 816c849411938cb91f1ce71a13b69cb88744c463..be862f999bb593f87c41eb830cacca7f8b718342 100644
--- a/mojo/edk/system/channel_win.cc
+++ b/mojo/edk/system/channel_win.cc
@@ -9,6 +9,7 @@
#include <algorithm>
#include <deque>
+#include <limits>
#include <memory>
#include "base/bind.h"
@@ -114,18 +115,20 @@ class ChannelWin : public Channel,
}
}
- ScopedPlatformHandleVectorPtr GetReadPlatformHandles(
+ bool GetReadPlatformHandles(
size_t num_handles,
const void* extra_header,
- size_t extra_header_size) override {
+ size_t extra_header_size,
+ ScopedPlatformHandleVectorPtr* handles) override {
+ if (num_handles > std::numeric_limits<uint16_t>::max())
+ return false;
size_t handles_size = sizeof(PlatformHandle) * num_handles;
if (handles_size > extra_header_size)
- return nullptr;
-
- ScopedPlatformHandleVectorPtr handles(
- new PlatformHandleVector(num_handles));
- memcpy(handles->data(), extra_header, handles_size);
- return handles;
+ return false;
+ DCHECK(extra_header);
+ handles->reset(new PlatformHandleVector(num_handles));
+ memcpy((*handles)->data(), extra_header, handles_size);
+ return true;
}
private:
« no previous file with comments | « mojo/edk/system/channel_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698