basho/riak_kv — pull request #569 by Vagabond (2013-05-30 16:46:04+00:00)
Title: Make sure client supplied N <= bucket N

Arbitrary, non-validated N values are scary, and you can probably DOS the cluster with them.

```
(riak@127.0.0.1)1> {ok, RC} = riak:local_client().
{ok,{riak_client,'riak@127.0.0.1',undefined}}
(riak@127.0.0.1)2> RC:get(<<"bucket">>, <<"key">>, [{n_val, 60}]).
{error,{n_val_violation,60}}
(riak@127.0.0.1)3> RC:put(riak_object:new(<<"bucket">>, <<"key">>, <<"value">>) , [{n_val, 60}]).
{error,{n_val_violation,60}}
(riak@127.0.0.1)4> RC:put(riak_object:new(<<"bucket">>, <<"key">>, <<"value">>) , [{n_val, 1}]).
ok
(riak@127.0.0.1)5> RC:get(<<"bucket">>, <<"key">>, [{n_val, 3}]).
{error,notfound}
(riak@127.0.0.1)6> RC:get(<<"bucket">>, <<"key">>, [{n_val, 3}, {notfound_ok, true}]).
{ok,{r_object,<<"bucket">>,<<"key">>,
[{r_content,{dict,3,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],...}}},
<<"value">>}],
[{<<"#\tþùQ§~\r">>,{1,63537151143}}],
{dict,1,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],[],...}}},
undefined}}
(riak@127.0.0.1)7>
```

Without this patch, a user would be able to write 60 replicas of data in a bucket that says it only has 3 replicas.

cc @slfritchie and @jtuple