aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/external.h
diff options
context:
space:
mode:
authorJayson Vantuyl <[email protected]>2010-01-05 17:37:18 -0800
committerBjörn Gustavsson <[email protected]>2010-01-08 14:37:12 +0100
commit77ce185291b73438b7987587c0871041e5a66d83 (patch)
tree7022044d901cde9f9dce1e4d056566df226a559e /erts/emulator/beam/external.h
parentfbdeb03d3919b096e039302801e2e865267a6943 (diff)
downloadotp-77ce185291b73438b7987587c0871041e5a66d83.tar.gz
otp-77ce185291b73438b7987587c0871041e5a66d83.tar.bz2
otp-77ce185291b73438b7987587c0871041e5a66d83.zip
add options to binary_to_term
term_to_binary and binary_to_term are powerful tools that can be used easily in lieu of a custom binary network protocol. Unfortunately, carefully crafted data can be used to exhaust the memory in an Erlang node by merely attempting to decode binaries. This makes it unsafe to receive data from untrusted sources. This is possible because binary_to_term/1 will allocate new atoms and new external function references. These data structures are not garbage collected. This patch implements the new form of binary_to_term that takes a list of options, and a simple option called 'safe'. If specified, this option will cause decoding to fail with a badarg error if an atom or external function reference would be allocated. In the general case, it will happily decode any Erlang term other than those containing new atoms or new external function references. However, fun, pid, and ref data types can embed atoms. They might fail to decode if one of these embedded atoms is new to the node. This may be an issue if encoded binaries are transferred between nodes or persisted between invocations of Erlang.
Diffstat (limited to 'erts/emulator/beam/external.h')
-rw-r--r--erts/emulator/beam/external.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/erts/emulator/beam/external.h b/erts/emulator/beam/external.h
index f308680f89..aa124f5197 100644
--- a/erts/emulator/beam/external.h
+++ b/erts/emulator/beam/external.h
@@ -100,7 +100,8 @@ typedef struct {
#define ERTS_DIST_EXT_DFLAG_HDR (((Uint32) 1) << 31)
#define ERTS_DIST_EXT_ATOM_TRANS_TAB (((Uint32) 1) << 30)
-#define ERTS_DIST_EXT_CON_ID_MASK ((Uint32) 0x3fffffff)
+#define ERTS_DIST_EXT_BTT_SAFE (((Uint32) 1) << 29)
+#define ERTS_DIST_EXT_CON_ID_MASK ((Uint32) 0x1fffffff)
#define ERTS_DIST_EXT_CON_ID(DIST_EXTP) \
((DIST_EXTP)->flags & ERTS_DIST_EXT_CON_ID_MASK)