Skip to content

Commit

Permalink
Add safe flag on binary_to_term calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
varnerac committed Mar 10, 2021
1 parent 5c9e2f6 commit c6d3d99
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Checks for a PR

on:
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
container:
image: erlang:23-slim
steps:
- run: chmod u+x rebar3
- run: ./rebar3 do upgrade, compile, xref, eunit, ct
2 changes: 1 addition & 1 deletion src/hashtree.erl
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ get_disk_bucket(Level, Bucket, #state{id=Id, ref=Ref}) ->
HKey = encode_bucket(Id, Level, Bucket),
case eleveldb:get(Ref, HKey, []) of
{ok, Bin} ->
binary_to_term(Bin);
binary_to_term(Bin, [safe]);
_ ->
orddict:new()
end.
Expand Down
2 changes: 1 addition & 1 deletion src/hashtree_tree.erl
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ to_parent_key(NodeName) ->

%% @private
from_parent_key(NodeKey) ->
binary_to_term(NodeKey).
binary_to_term(NodeKey, [safe]).

%% @private
valid_prefixes(NodeName, #hashtree_tree{num_levels=NumLevels}) ->
Expand Down
2 changes: 1 addition & 1 deletion src/plumtree_metadata_exchange_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ repair_other(remote, Peer, PKey, Obj) ->

%% @private
repair_keys(Peer, PrefixList, {_Type, KeyBin}) ->
Key = binary_to_term(KeyBin),
Key = binary_to_term(KeyBin, [safe]),
Prefix = list_to_tuple(PrefixList),
PKey = {Prefix, Key},
LocalObj = plumtree_metadata_manager:get(PKey),
Expand Down
2 changes: 1 addition & 1 deletion src/plumtree_metadata_leveldb_instance.erl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ init([InstanceId, Opts]) ->
handle_call({get, Key}, _From, #state{read_opts=ReadOpts, ref=Ref} = State) ->
case eleveldb:get(Ref, sext:encode(Key), ReadOpts) of
{ok, Value} ->
{reply, {ok, binary_to_term(Value)}, State};
{reply, {ok, binary_to_term(Value, [safe])}, State};
not_found ->
{reply, {error, not_found}, State};
{error, Reason} ->
Expand Down
2 changes: 1 addition & 1 deletion src/plumtree_metadata_leveldb_iterator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ iterate(OkVal, Instances, FullPrefix, KeyMatch, KeysOnly) when element(1, OkVal)
{{PrefixedKey, self()}, Instances};
true ->
BVal = element(3, OkVal),
{{{PrefixedKey, binary_to_term(BVal)}, self()}, Instances};
{{{PrefixedKey, binary_to_term(BVal, [safe])}, self()}, Instances};
false ->
iterate(Instances, FullPrefix, KeyMatch, KeysOnly)
end;
Expand Down

0 comments on commit c6d3d99

Please sign in to comment.