FreeBSD/contrib/subversion/subversion/libsvn_fs_x/noderevs.c
/* Allocate a svn_fs_x__representation_t array in POOL and return it in
 * REPS_P.  Deserialize the data in REP_STREAM and DIGEST_STREAM and store
 * the resulting representations into the *REPS_P.
 */
Allocate a svn_fs_x__representation_t array in POOL and return it in
REPS_P.  Deserialize the data in REP_STREAM and DIGEST_STREAM and store
the resulting representations into the *REPS_P.
Allocate a svn_fs_x__representation_t array in POOL and return it in REPS_P . Deserialize the data in REP_STREAM and DIGEST_STREAM and store the resulting representations into the * REPS_P .
static svn_error_t *
read_reps(apr_array_header_t **reps_p,
          svn_packed__int_stream_t *rep_stream,
          svn_packed__byte_stream_t *digest_stream,
          apr_pool_t *pool)
{
  apr_size_t i;
  apr_size_t len;
  const char *bytes;
  apr_size_t count
    = svn_packed__int_count(svn_packed__first_int_substream(rep_stream));
  apr_array_header_t *reps
    = apr_array_make(pool, (int)count, sizeof(svn_fs_x__representation_t));
  for (i = 0; i < count; ++i)
    {
      svn_fs_x__representation_t rep;
      rep.has_sha1 = (svn_boolean_t)svn_packed__get_uint(rep_stream);
      rep.id.change_set = (svn_revnum_t)svn_packed__get_uint(rep_stream);
      rep.id.number = svn_packed__get_uint(rep_stream);
      rep.size = svn_packed__get_uint(rep_stream);
      rep.expanded_size = svn_packed__get_uint(rep_stream);
      bytes = svn_packed__get_bytes(digest_stream, &len);
      if (len != sizeof(rep.md5_digest))
        return svn_error_createf(SVN_ERR_FS_CONTAINER_INDEX, NULL,
                                 apr_psprintf(pool,
                                              _("Unexpected MD5"
                                                " digest size %%%s"),
                                              APR_SIZE_T_FMT),
                                 len);
      memcpy(rep.md5_digest, bytes, sizeof(rep.md5_digest));
      if (rep.has_sha1)
        {
          bytes = svn_packed__get_bytes(digest_stream, &len);
          if (len != sizeof(rep.sha1_digest))
            return svn_error_createf(SVN_ERR_FS_CONTAINER_INDEX, NULL,
                                     apr_psprintf(pool,
                                                  _("Unexpected SHA1"
                                                    " digest size %%%s"),
                                                  APR_SIZE_T_FMT),
                                     len);
          memcpy(rep.sha1_digest, bytes, sizeof(rep.sha1_digest));
        }
      APR_ARRAY_PUSH(reps, svn_fs_x__representation_t) = rep;
    }
  *reps_p = reps;
  return SVN_NO_ERROR;
}
static svn_error_t * read_reps ( apr_array_header_t * * reps_p , svn_packed__int_stream_t * rep_stream , svn_packed__byte_stream_t * digest_stream , apr_pool_t * pool ) { apr_size_t i ; apr_size_t len ; const char * bytes ; apr_size_t count = svn_packed__int_count ( svn_packed__first_int_substream ( rep_stream ) ) ; apr_array_header_t * reps = apr_array_make ( pool , ( int ) count , sizeof ( svn_fs_x__representation_t ) ) ; for ( i = 0 ; i < count ; ++ i ) { svn_fs_x__representation_t rep ; rep . has_sha1 = ( svn_boolean_t ) svn_packed__get_uint ( rep_stream ) ; rep . id . change_set = ( svn_revnum_t ) svn_packed__get_uint ( rep_stream ) ; rep . id . number = svn_packed__get_uint ( rep_stream ) ; rep . size = svn_packed__get_uint ( rep_stream ) ; rep . expanded_size = svn_packed__get_uint ( rep_stream ) ; bytes = svn_packed__get_bytes ( digest_stream , & len ) ; if ( len != sizeof ( rep . md5_digest ) ) return svn_error_createf ( SVN_ERR_FS_CONTAINER_INDEX , NULL , apr_psprintf ( pool , _ ( " " " " ) , APR_SIZE_T_FMT ) , len ) ; memcpy ( rep . md5_digest , bytes , sizeof ( rep . md5_digest ) ) ; if ( rep . has_sha1 ) { bytes = svn_packed__get_bytes ( digest_stream , & len ) ; if ( len != sizeof ( rep . sha1_digest ) ) return svn_error_createf ( SVN_ERR_FS_CONTAINER_INDEX , NULL , apr_psprintf ( pool , _ ( " " " " ) , APR_SIZE_T_FMT ) , len ) ; memcpy ( rep . sha1_digest , bytes , sizeof ( rep . sha1_digest ) ) ; } APR_ARRAY_PUSH ( reps , svn_fs_x__representation_t ) = rep ; } * reps_p = reps ; return SVN_NO_ERROR ; }
Allocate a svn_fs_x__representation_t array in POOL and return it in
 REPS_P.
Allocate a svn_fs_x__representation_t array in POOL and return it in REPS_P .
/* when extracting the checksums, beware of buffer under/overflows
         caused by disk data corruption. */