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

Unified Diff: base/pickle.h

Issue 1345353004: Resize IPC input buffer to fit the next message. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests and address comments Created 5 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 | base/pickle.cc » ('j') | ipc/ipc_channel_reader.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/pickle.h
diff --git a/base/pickle.h b/base/pickle.h
index b6ec116ebf68361fd4b3ab9e2f9110508e291bc2..22b8055cbae869a2d9549a385fbdc42363d6d0b3 100644
--- a/base/pickle.h
+++ b/base/pickle.h
@@ -271,6 +271,18 @@ class BASE_EXPORT Pickle {
const char* range_start,
const char* range_end);
+ // Parse pickle header and return total size of the pickle. Data range
+ // doesn't need to contain entire pickle.
+ // Returns true if pickle header was found and parsed. Callers must check
+ // returned |pickle_size| for sanity (against maximum message size, etc).
+ // NOTE: when function successfully parses a header, but encounters an
+ // overflow during pickle size calculation, it sets |pickle_size| to the
+ // maximum size_t value and returns true.
+ static bool PeekNext(size_t header_size,
+ const char* range_start,
+ const char* range_end,
+ size_t* pickle_size);
+
// The allocation granularity of the payload.
static const int kPayloadUnit;
@@ -298,6 +310,8 @@ class BASE_EXPORT Pickle {
FRIEND_TEST_ALL_PREFIXES(PickleTest, DeepCopyResize);
FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize);
+ FRIEND_TEST_ALL_PREFIXES(PickleTest, PeekNext);
+ FRIEND_TEST_ALL_PREFIXES(PickleTest, PeekNextOverflow);
FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext);
FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader);
FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextOverflow);
« no previous file with comments | « no previous file | base/pickle.cc » ('j') | ipc/ipc_channel_reader.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698