Add some simple fuzzying tests to FSFS.  These tests take a while and
must be executed manually.  Without the upcomming fixes, those tests
will crash SVN by segfaults and OOM.

The basic idea is to flip a single byte in an otherwise valid revision
file and check that we detect the corruption without crashing.  We flip
all bytes individually and use 4 different strategies for them.

In the first test, we invert all bits in the byte, the next two tests
increment / decrement it and the last test sets the value to 0.

* build.conf
  (fs-fs-fuzzy-test): Declare new build target.
  (__ALL_TESTS__): Add new target as dependency.

* subversion/tests/libsvn_fs_fs/fs-fs-fuzzy-test.c
  (): New test file implementing simple fuzzying tests.

git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622926 13f79535-47bb-0310-9956-ffa450edef68
Harden FSFS's revision number parsing.  Replace the combination
of tokenizing and SVN_STR_TO_REV with a strict parsing function.

* subversion/libsvn_fs_fs/low_level.c
  (parse_revnum): New revnum parsing function.  It detects invalid
                  values, overflows and invalid terminators.
  (read_change,
   svn_fs_fs__parse_representation,
   svn_fs_fs__read_noderev,
   svn_fs_fs__read_rep_header): Use the new function to parse revnums.

git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622931 13f79535-47bb-0310-9956-ffa450edef68
Harden FSFS's low-level path parsers against data corruption.

* subversion/libsvn_fs_fs/low_level.c
  (read_change
   svn_fs_fs__read_noderev): All paths must be canonical and start with '/'

git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622937 13f79535-47bb-0310-9956-ffa450edef68
Harden FSFS parsers against corrupted ID strings. 

Currently, we would simply return a NULL ID in case of invalid input.
That leads to NULL struct members in other places - which is a bad idea.
Make the ID parser follow the usual svn_error_t * return pattern.

* subversion/include/svn_error_codes.h
  (SVN_ERR_FS_MALFORMED_NODEREV_ID): Declare a new error code.

* subversion/libsvn_fs_fs/id.h
  (svn_fs_fs__id_copy): Change signature to return svn_error_t *.

* subversion/libsvn_fs_fs/id.c
  (svn_fs_fs__id_parse): Rename to ...
  (id_parse): ... this and make it static.
  (svn_fs_fs__id_parse): New, error generating wrapper.

* subversion/libsvn_fs_fs/cached_data.c
  (read_dir_entries): Update caller.

* subversion/libsvn_fs_fs/fs_fs.c
  (svn_fs_fs__get_node_origin): Same.

* subversion/libsvn_fs_fs/low_level.c
  (read_change,
   svn_fs_fs__read_noderev): Same.

* subversion/libsvn_fs_fs/recovery.c
  (recover_find_max_ids): Same.

git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622942 13f79535-47bb-0310-9956-ffa450edef68
Docstring fixes. No functional change.

* subversion/tests/libsvn_fs_fs/fs-fs-pack-test.c
  (): Fix file docstring.

* subversion/tests/libsvn_fs_x/fs-x-pack-test.c
  (): Same.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622943 13f79535-47bb-0310-9956-ffa450edef68
Fix a segfault in our replay logic when presented with corrupted changed
path lists that try to add root nodes. 

* subversion/libsvn_repos/replay.c
  (path_driver_cb_func): We can never add a directory or file at "/".

git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622944 13f79535-47bb-0310-9956-ffa450edef68
Plug a hole in the svn_fs_fs__revision_file_t open logic.

* subversion/libsvn_fs_fs/rev_file.c
  (open_pack_or_rev_file): If we retry due to a potential background
                           pack, we should update the rev / pack file
                           base revision as well.

git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622946 13f79535-47bb-0310-9956-ffa450edef68
By default, we abort / malfunction if some cache access function returned
an error such like out-of-range.  Usually, the server would plug its own
logging callback here.

During verification, however, there is no such server callback.  Moreover,
we want all errors to be reported nicely instead of aborting the process.

* subversion/libsvn_fs/fs-loader.c
  (verify_fs_warning_func):  New, empty warning callback
  (svn_fs_verify):  Let all errors be reported through the svn_error_t*
                    return value mechanism.

git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622955 13f79535-47bb-0310-9956-ffa450edef68
Harden FSFS f7 index reader against corruption.  The idea is to compare
header information to rev / pack file sizes etc. and error out when
they don't match.  This e.g. prevents OOM due to corrupt table sizes.

* subversion/libsvn_fs_fs/index.c
  (get_l2p_header_body,
   get_p2l_header): Add lots of data checking code.

git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622959 13f79535-47bb-0310-9956-ffa450edef68
* subversion/libsvn_fs_fs/pack.c
  (copy_reps_from_temp):  Remove unused array.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622960 13f79535-47bb-0310-9956-ffa450edef68
Restrict the FSFS L2P index page size to powers of two.  That's easier
to verify and consistent with all the other settings we have.

* subversion/libsvn_fs_fs/fs_fs.c
  (write_config): Update and clean up fsfs.conf docstring.

* subversion/libsvn_fs_fs/index.c
  (get_l2p_header_body): Verify that the L2P page size is 2^N.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622963 13f79535-47bb-0310-9956-ffa450edef68
Follow-up to r1622926.  Say "fuzzing" when we mean it.

* subversion/tests/libsvn_fs_fs/fs-fs-fuzzy-test.c
  (currying_1_byte_test,
   currying_invert_byte_test,
   currying_increment_byte_test,
   currying_decrement_byte_test,
   currying_null_byte_test): Rename these to ...
  (fuzzing_1_byte_test,
   fuzzing_invert_byte_test,
   fuzzing_increment_byte_test,
   fuzzing_decrement_byte_test,
   fuzzing_null_byte_test): ... these. Update function calls.
  (test_funcs): Update.

git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622965 13f79535-47bb-0310-9956-ffa450edef68
Follow up to r1622926: Use the correct canonicalization check for FS paths.

* subversion/libsvn_fs_fs/low_level.c
  (read_change, svn_fs_fs__read_noderev): Use svn_fspath__is_canonical
   instead of the (incorrect, platform-specific) svn_dirent_is_canonical.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622987 13f79535-47bb-0310-9956-ffa450edef68
Fix a new warning on trunk.

* subversion/tests/libsvn_fs_fs/fs-fs-fuzzy-test.c
  (fuzzing_1_byte_test): Use correct printf formats.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1622988 13f79535-47bb-0310-9956-ffa450edef68
* subversion/libsvn_fs_fs/rev_file.c
  (init_revision_file): Add missing docstring. No functional change.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1623007 13f79535-47bb-0310-9956-ffa450edef68
* subversion/tests/libsvn_fs_fs/fs-fs-fuzzy-test.c
  (fuzzing_1_byte_test): Fix / complete commentary. No functional change.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1623008 13f79535-47bb-0310-9956-ffa450edef68
Report transaction name rather than revision number in error message from 'pget'
if it was run with -t option.

Obvious fix.

* subversion/svnlook/svnlook.c
  (do_pget): Report c->txn_name if the revision number is invalid.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1623317 13f79535-47bb-0310-9956-ffa450edef68
Minor FSFS refactoring: move a common code sequence to util.*

* subversion/libsvn_fs_fs/util.h
  (svn_fs_fs__packed_base_rev): Declare new internal API.

* subversion/libsvn_fs_fs/util.c
  (svn_fs_fs__packed_base_rev): Implement it with code taken from rev_file.c.

* subversion/libsvn_fs_fs/rev_file.c
  (init_revision_file,
   open_pack_or_rev_file): Call the new function.

* subversion/libsvn_fs_fs/verify.c
  (packed_base_rev): Remove local function.
  (verify_index_consistency): Call the new one.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1623368 13f79535-47bb-0310-9956-ffa450edef68
Reduce peak memory consumption of the new fs-fs-fuzzy-test.

* subversion/tests/libsvn_fs_fs/fs-fs-fuzzy-test.c
  (fuzzing_1_byte_test): Re-open the repos in every operation.
                         That's ~10% runtime overhead but gives
                         flat memory usage.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1623369 13f79535-47bb-0310-9956-ffa450edef68
Add entry type checking to the P2L index reader to early detect
further cases external corruption.

* subversion/libsvn_fs_fs/index.c
  (read_entry): Verify that P2L index entries follow type restrictions.

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