summaryrefslogtreecommitdiff
path: root/subversion/libsvn_fs_fs
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2018-10-08 08:34:55 +0000
committerPeter Wemm <peter@FreeBSD.org>2018-10-08 08:34:55 +0000
commitf3520a04ffc9f2c22dc693226fd2a480a4192da1 (patch)
tree19339c70c87a08c32b01175500d4284f409925ee /subversion/libsvn_fs_fs
parent3faf8d6bffc5d0fb2525ba37bb504c53366caf9d (diff)
Notes
Diffstat (limited to 'subversion/libsvn_fs_fs')
-rw-r--r--subversion/libsvn_fs_fs/cached_data.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/subversion/libsvn_fs_fs/cached_data.c b/subversion/libsvn_fs_fs/cached_data.c
index f8fa2d05bfd6..1bd82481daa6 100644
--- a/subversion/libsvn_fs_fs/cached_data.c
+++ b/subversion/libsvn_fs_fs/cached_data.c
@@ -2103,13 +2103,14 @@ skip_contents(struct rep_read_baton *baton,
/* BATON is of type `rep_read_baton'; read the next *LEN bytes of the
representation and store them in *BUF. Sum as we read and verify
- the MD5 sum at the end. */
+ the MD5 sum at the end. This is a READ_FULL_FN for svn_stream_t. */
static svn_error_t *
rep_read_contents(void *baton,
char *buf,
apr_size_t *len)
{
struct rep_read_baton *rb = baton;
+ apr_size_t len_requested = *len;
/* Get data from the fulltext cache for as long as we can. */
if (rb->fulltext_cache)
@@ -2150,6 +2151,28 @@ rep_read_contents(void *baton,
if (rb->current_fulltext)
svn_stringbuf_appendbytes(rb->current_fulltext, buf, *len);
+ /* This is a FULL_READ_FN so a short read implies EOF and we can
+ verify the length. */
+ rb->off += *len;
+ if (*len < len_requested && rb->off != rb->len)
+ {
+ /* A warning rather than an error to allow the data to be
+ retrieved when the length is wrong but the data is
+ present, i.e. if repository corruption has stored the wrong
+ expanded length. */
+ svn_error_t *err = svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
+ _("Length mismatch while reading representation:"
+ " expected %s,"
+ " got %s"),
+ apr_psprintf(rb->pool, "%" SVN_FILESIZE_T_FMT,
+ rb->len),
+ apr_psprintf(rb->pool, "%" SVN_FILESIZE_T_FMT,
+ rb->off));
+
+ rb->fs->warning(rb->fs->warning_baton, err);
+ svn_error_clear(err);
+ }
+
/* Perform checksumming. We want to check the checksum as soon as
the last byte of data is read, in case the caller never performs
a short read, but we don't want to finalize the MD5 context
@@ -2157,7 +2180,6 @@ rep_read_contents(void *baton,
if (!rb->checksum_finalized)
{
SVN_ERR(svn_checksum_update(rb->md5_checksum_ctx, buf, *len));
- rb->off += *len;
if (rb->off == rb->len)
{
svn_checksum_t *md5_checksum;