From a2a86dadc648dda68b5221a7c1d83b9238be1e25 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Fri, 12 Feb 2016 18:52:20 +0100 Subject: erts: Improve enif_binary_to_term * Accept a raw data buffer instead of ErlNifBinary * Accept option ERL_NIF_BIN2TERM_SAFE * Return number of read bytes --- erts/doc/src/erl_nif.xml | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'erts/doc/src/erl_nif.xml') diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml index 81b6eed24a..7a8325c200 100644 --- a/erts/doc/src/erl_nif.xml +++ b/erts/doc/src/erl_nif.xml @@ -524,6 +524,18 @@ typedef struct {

Note that ErlNifBinary is a semi-opaque type and you are only allowed to read fields size and data.

+ + ErlNifBinaryToTerm + +

An enumeration of the options that can be given to + enif_binary_to_term. + For default behavior, use the value 0.

+ + ERL_NIF_BIN2TERM_SAFE +

Use this option when receiving data from untrusted sources.

+
+
+ ErlNifPid

ErlNifPid is a process identifier (pid). In contrast to @@ -655,16 +667,23 @@ typedef enum { have been allocated with enif_alloc_env.

- intenif_binary_to_term(ErlNifEnv *env, ErlNifBinary *bin, ERL_NIF_TERM *term) - Convert a term from the external format + size_tenif_binary_to_term(ErlNifEnv *env, const unsigned char* data, size_t size, ERL_NIF_TERM *term, ErlNifBinaryToTerm opts) + Create a term from the external format -

Returns a term that is the result of decoding bin - according to the Erlang external term format.

-

See also:

- - erlang:binary_to_term/1 - enif_term_to_binary - +

Create a term that is the result of decoding the binary data + at data, which must be encoded according to the Erlang external term format. + No more than size bytes are read from data. Argument opts + correspond to the second argument to + erlang:binary_to_term/2, and must be either 0 or + ERL_NIF_BIN2TERM_SAFE.

+

On success, store the resulting term at *term and return + the actual number of bytes read. Return zero if decoding fails or if opts + is invalid.

+

See also: + ErlNifBinaryToTerm, + erlang:binary_to_term/2 and + enif_term_to_binary. +

intenif_compare(ERL_NIF_TERM lhs, ERL_NIF_TERM rhs) -- cgit v1.2.3