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

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: update Created 4 years, 10 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 | « base/pickle_unittest.cc ('k') | ipc/ipc_message_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_message_utils.h
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index 9ae39c20e17809d2b08c28e3840915038e14ad30..ef32e0bd61c4e078649c685d84ab870a65c6a81d 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -182,14 +182,26 @@ struct ParamTraits<unsigned int> {
IPC_EXPORT static void Log(const param_type& p, std::string* l);
};
+// long isn't safe to send over IPC because it's 4 bytes on 32 bit builds but
+// 8 bytes on 64 bit builds. So if a 32 bit and 64 bit process have a channel
+// that would cause problem.
+// We need to keep this on for a few configs:
+// 1) Windows because DWORD is typedef'd to it, which is fine because we have
+// very few IPCs that cross this boundary.
+// 2) We also need to keep it for Linux for two reasons: int64_t is typedef'd
+// to long, and gfx::PluginWindow is long and is used in one GPU IPC.
+// 3) Android 64 bit also has int64_t typedef'd to long.
+// Since we want to support Android 32<>64 bit IPC, as long as we don't have
+// these traits for 32 bit ARM then that'll catch any errors.
+#if defined(OS_WIN) || defined(OS_LINUX) || defined(ARCH_CPU_ARM64)
Tom Sepez 2016/02/10 18:00:07 nit: you might want to define a IPC_ALLOW_LONG her
jam 2016/02/10 18:19:41 i think in practice this won't really change. if i
template <>
struct ParamTraits<long> {
typedef long param_type;
static void GetSize(base::PickleSizer* sizer, const param_type& p) {
- sizer->AddLongUsingDangerousNonPortableLessPersistableForm();
+ sizer->AddLong();
}
static void Write(base::Pickle* m, const param_type& p) {
- m->WriteLongUsingDangerousNonPortableLessPersistableForm(p);
+ m->WriteLong(p);
}
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -203,10 +215,10 @@ template <>
struct ParamTraits<unsigned long> {
typedef unsigned long param_type;
static void GetSize(base::PickleSizer* sizer, const param_type& p) {
- sizer->AddLongUsingDangerousNonPortableLessPersistableForm();
+ sizer->AddLong();
}
static void Write(base::Pickle* m, const param_type& p) {
- m->WriteLongUsingDangerousNonPortableLessPersistableForm(p);
+ m->WriteLong(p);
}
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -215,6 +227,7 @@ struct ParamTraits<unsigned long> {
}
IPC_EXPORT static void Log(const param_type& p, std::string* l);
};
+#endif
template <>
struct ParamTraits<long long> {
« no previous file with comments | « base/pickle_unittest.cc ('k') | ipc/ipc_message_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698