FreeBSD/contrib/subversion/subversion/libsvn_fs_x/revprops.c
/* Extract the generation number from the text BUFFER of LEN bytes and
 * verify it against the checksum in the same BUFFER.  If they match, return
 * the generation in *NUMBER.  Otherwise, return an error.
 * BUFFER does not need to be NUL-terminated.
 */
Extract the generation number from the text BUFFER of LEN bytes and
verify it against the checksum in the same BUFFER.  If they match, return
the generation in *NUMBER.  Otherwise, return an error.
BUFFER does not need to be NUL-terminated.
Extract the generation number from the text BUFFER of LEN bytes and verify it against the checksum in the same BUFFER . If they match return the generation in * NUMBER . Otherwise return an error . BUFFER does not need to be NUL - terminated .
static svn_error_t *
verify_extract_number(apr_int64_t *number,
                      const char *buffer,
                      apr_size_t len,
                      apr_pool_t *scratch_pool)
{
  const char *digest_end = strchr(buffer, ' ');
  if (digest_end != NULL)
    {
      svn_checksum_t *expected;
      svn_checksum_t *actual;
      SVN_ERR(svn_checksum_parse_hex(&expected, svn_checksum_md5, buffer,
                                     scratch_pool));
      SVN_ERR(svn_checksum(&actual, svn_checksum_md5, digest_end + 1,
                           (buffer + len) - (digest_end + 1), scratch_pool));
      if (svn_checksum_match(expected, actual))
        return svn_error_trace(svn_cstring_atoi64(number, digest_end + 1));
    }
  return svn_error_create(SVN_ERR_FS_INVALID_GENERATION, NULL,
                          _("Invalid generation number data."));
}
static svn_error_t * verify_extract_number ( apr_int64_t * number , const char * buffer , apr_size_t len , apr_pool_t * scratch_pool ) { const char * digest_end = strchr ( buffer , ' ' ) ; if ( digest_end != NULL ) { svn_checksum_t * expected ; svn_checksum_t * actual ; SVN_ERR ( svn_checksum_parse_hex ( & expected , svn_checksum_md5 , buffer , scratch_pool ) ) ; SVN_ERR ( svn_checksum ( & actual , svn_checksum_md5 , digest_end + 1 , ( buffer + len ) - ( digest_end + 1 ) , scratch_pool ) ) ; if ( svn_checksum_match ( expected , actual ) ) return svn_error_trace ( svn_cstring_atoi64 ( number , digest_end + 1 ) ) ; } return svn_error_create ( SVN_ERR_FS_INVALID_GENERATION , NULL , _ ( " " ) ) ; }
Extract the generation number from the text BUFFER of LEN bytes and
 verify it against the checksum in the same BUFFER.
Extract the generation number from the text BUFFER of LEN bytes and verify it against the checksum in the same BUFFER .
/* Does the buffer even contain checksum _and_ number? */ /* Incomplete buffer or not a match. */