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

Unified Diff: ipc/ipc_message_utils.h

Issue 1619363002: Add compile time checks against longs being used in IPC structs on 32 bit Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more per Dmitry Created 4 years, 11 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
Index: ipc/ipc_message_utils.h
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index 69ea7cb6d8a08e68815c393fa099d60ce0e3bc62..7f0036876c96e98ba475baa684b2feda8922b20f 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -192,7 +192,12 @@ template <>
struct ParamTraits<long> {
typedef long param_type;
static void Write(Message* m, const param_type& p) {
- m->WriteLongUsingDangerousNonPortableLessPersistableForm(p);
+ // To ensure compatibility between 32-bit and 64-bit processes, send as
+ // 64 bit size. We can't check on the writing side if reading may overflow
+ // if sending from 64-bit process and reading from 32-bit process, since we
+ // don't know if this IPC parameter is 64 bit always (i.e. from an int64_t
+ // typedef) or if it's from a size_t.
+ m->WriteLong(p);
}
static bool Read(const Message* m,
base::PickleIterator* iter,
@@ -206,7 +211,8 @@ template <>
struct ParamTraits<unsigned long> {
typedef unsigned long param_type;
static void Write(Message* m, const param_type& p) {
- m->WriteLongUsingDangerousNonPortableLessPersistableForm(p);
+ // See comment in ParamTraits<long>::Write.
+ m->WriteLong(p);
}
static bool Read(const Message* m,
base::PickleIterator* iter,

Powered by Google App Engine
This is Rietveld 408576698