MB-7629: Add more sanity checks for reduction/value/key decode

This is mostly to deal with some rare/corner cases where the buffer length is too
small.

Change-Id: Icd390d2348922a22e3732b1cf18688f7a81f3e59
Reviewed-on: http://review.couchbase.org/25676
Tested-by: Fulu Li <fulu@couchbase.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>