Avoid potential integer overflow and underflow in svn_fs_base__next_key().

* subversion/libsvn_fs_base/key-gen.c
  (svn_fs_base__next_key): Use the same type for the index as we received the
    length as to avoid integer overflow.  Avoid using a signed index since that
    further reduces our range.  Don't decrement until we're sure we can't
    underflow.  Rewrite the loop to avoid requiring a signed loop control
    variable, using kfogel's favorite constant (BDB code is a blast from the
    past).


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1570701 13f79535-47bb-0310-9956-ffa450edef68