cvmfs/cvmfs — pull request #412 by reneme (2014-04-01 13:06:28+00:00)
Title: FIX: Create Intermediate Nested Catalogs

This fixes a severe problem in the `Catalog` respectively `WritableCatalog` classes that prevented the successful creation of nested catalogs between two already present nested catalogs. See [CVM-608](https://sft.its.cern.ch/jira/browse/CVM-608).

The problem was, that the result of `Catalog::ListNestedCatalogs()` was cached inside `Catalog`. A pointer directly to that cache was returned and used in the `WritableCatalogManager`. Creating intermediate nested catalogs caused an update of the internal cache in `Catalog` while the exact same data structure was iterated in the `WritableCatalogManager`. This lead to corrupted data due to an undefined memory state. Fortunately the bug only shows up on the server side, since read-only catalogs in the client fill their cache once but never update it. *You shall never violate encapsulation in your classes!*

I changed the caching logic in a way, that it always returns a copy of the cached list. Since we are caching a database query here, the small efficiency penalty shouldn't be a big deal. However some user code needed to be adapted to the new signature of `Catalog::ListNestedCatalogs()`.

Additionally this contains two regression tests that reproduced the error.