summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_message_macros.h
diff options
context:
space:
mode:
authortsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-04 07:20:32 +0000
committertsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-04 07:20:32 +0000
commitdedd0a9e00390f585c41f065d1bff0731bd4a2d8 (patch)
tree114983c99c00a83ceaceb8ec128d29718dbb7bcd /ipc/ipc_message_macros.h
parentd966f777e418fbae4fef451a104bb1f7f326e434 (diff)
downloadchromium_src-dedd0a9e00390f585c41f065d1bff0731bd4a2d8.zip
chromium_src-dedd0a9e00390f585c41f065d1bff0731bd4a2d8.tar.gz
chromium_src-dedd0a9e00390f585c41f065d1bff0731bd4a2d8.tar.bz2
Implement off-the-wire validation scheme for emum types.
This CL adds explicit IPC macros that can be used to ensure that the values being read off the wire are legitimate for the enum type. BUG=176110 R=jam@chromium.org Review URL: https://chromiumcodereview.appspot.com/15841011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203892 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_message_macros.h')
-rw-r--r--ipc/ipc_message_macros.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/ipc/ipc_message_macros.h b/ipc/ipc_message_macros.h
index 2993014..cd03680 100644
--- a/ipc/ipc_message_macros.h
+++ b/ipc/ipc_message_macros.h
@@ -130,7 +130,9 @@
// to proclaim equivalent struct declarations for use by callers, as well
// as later registering the type with the message generation. Note that
// IPC_STRUCT_MEMBER() is only permitted inside matching calls to
-// IPC_STRUCT_BEGIN() / IPC_STRUCT_END().
+// IPC_STRUCT_BEGIN() / IPC_STRUCT_END(). There is also an
+// IPC_STRUCT_BEGIN_WITH_PARENT(), which behaves like IPC_STRUCT_BEGIN(),
+// but also accomodates structs that inherit from other structs.
//
// Externally-defined structs are registered with IPC_STRUCT_TRAITS_BEGIN(),
// IPC_STRUCT_TRAITS_MEMBER(), and IPC_STRUCT_TRAITS_END() macros. These
@@ -141,8 +143,16 @@
// inside matching calls to IPC_STRUCT_TRAITS_BEGIN() /
// IPC_STRUCT_TRAITS_END().
//
-// Enum types are registered with a single IPC_ENUM_TRAITS() macro. There
-// is no need to enumerate each value to the IPC mechanism.
+// Enum types are registered with a single IPC_ENUM_TRAITS_VALIDATE() macro.
+// There is no need to enumerate each value to the IPC mechanism. Instead,
+// pass an expression in terms of the parameter |value| to provide
+// range-checking. For convenience, the IPC_ENUM_TRAITS() is provided which
+// performs no checking, passing everything including out-of-range values.
+// Its use is discouraged. The IPC_ENUM_TRAITS_MAX_VALUE() macro can be used
+// for the typical case where the enum must be in the range 0..maxvalue
+// inclusive. The IPC_ENUM_TRAITS_MIN_MAX_VALUE() macro can be used for the
+// less typical case where the enum must be in the range minvalue..maxvalue
+// inclusive.
//
// Do not place semicolons following these IPC_ macro invocations. There
// is no reason to expect that their expansion corresponds one-to-one with
@@ -192,9 +202,12 @@
#include "ipc/ipc_message_utils_impl.h"
#endif
-// Macros for defining structs. May be subsequently redefined.
+// Convenience macro for defining structs without inheritence. Should not need
+// to be subsequently redefined.
#define IPC_STRUCT_BEGIN(struct_name) \
IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, IPC::NoParams)
+
+// Macros for defining structs. Will be subsequently redefined.
#define IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, parent) \
struct struct_name; \
IPC_STRUCT_TRAITS_BEGIN(struct_name) \