summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vatamaniuc <vatamane@apache.org>2019-10-24 14:30:01 -0400
committerNick Vatamaniuc <nickva@users.noreply.github.com>2019-10-24 14:38:28 -0400
commit3ded0e5a0b503289937bb9db7a40fd18f0810d3d (patch)
tree46abd90a3d3044975ab379684b67c1cc063ea583
parent5334997ab5bf4282b2a560caa61fcf44ff784043 (diff)
downloadcouchdb-3ded0e5a0b503289937bb9db7a40fd18f0810d3d.tar.gz
Add a special error for an invalid legacy local doc revsion
Since we are dealing with upgrades and both versions start out as binaries, make sure we add extra belts and suspenders to surface any issues with encoding errors.
-rw-r--r--src/fabric/src/fabric2_fdb.erl9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index dc803115f..c59346ebd 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -532,8 +532,13 @@ get_local_doc_rev(_Db0, <<?LOCAL_DOC_PREFIX, _/binary>> = DocId, Val) ->
case Val of
<<131, _/binary>> ->
% Compatibility clause for an older encoding format
- {Rev, _} = binary_to_term(Val, [safe]),
- Rev;
+ try binary_to_term(Val, [safe]) of
+ {Rev, _} -> Rev;
+ _ -> erlang:error({invalid_local_doc_rev, DocId, Val})
+ catch
+ error:badarg ->
+ erlang:error({invalid_local_doc_rev, DocId, Val})
+ end;
<<_/binary>> ->
try binary_to_integer(Val) of
IntVal when IntVal >= 0 ->