diff options
author | Peter Wemm <peter@FreeBSD.org> | 2016-12-01 07:45:05 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 2016-12-01 07:45:05 +0000 |
commit | 608944fa5a78d7f517c9c73a7ded6c130cc97b83 (patch) | |
tree | 9dce7c56ce4cbd36bb5457661d50b23d30c3533c /subversion/libsvn_fs_fs/low_level.c | |
parent | c94cceea9c2262c5b2ad5f215bb9a8ae48b02764 (diff) |
Diffstat (limited to 'subversion/libsvn_fs_fs/low_level.c')
-rw-r--r-- | subversion/libsvn_fs_fs/low_level.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/subversion/libsvn_fs_fs/low_level.c b/subversion/libsvn_fs_fs/low_level.c index a27bbcc35b878..d21e312faa2e7 100644 --- a/subversion/libsvn_fs_fs/low_level.c +++ b/subversion/libsvn_fs_fs/low_level.c @@ -764,7 +764,11 @@ svn_fs_fs__parse_representation(representation_t **rep_p, SVN_ERR(svn_checksum_parse_hex(&checksum, svn_checksum_md5, str, scratch_pool)); - memcpy(rep->md5_digest, checksum->digest, sizeof(rep->md5_digest)); + + /* If STR is a all-zero checksum, CHECKSUM will be NULL and REP already + contains the correct value. */ + if (checksum) + memcpy(rep->md5_digest, checksum->digest, sizeof(rep->md5_digest)); /* The remaining fields are only used for formats >= 4, so check that. */ str = svn_cstring_tokenize(" ", &string); @@ -778,8 +782,16 @@ svn_fs_fs__parse_representation(representation_t **rep_p, SVN_ERR(svn_checksum_parse_hex(&checksum, svn_checksum_sha1, str, scratch_pool)); + + /* We do have a valid SHA1 but it might be all 0. + We cannot be sure where that came from (Alas! legacy), so let's not + claim we know the SHA1 in that case. */ rep->has_sha1 = checksum != NULL; - memcpy(rep->sha1_digest, checksum->digest, sizeof(rep->sha1_digest)); + + /* If STR is a all-zero checksum, CHECKSUM will be NULL and REP already + contains the correct value. */ + if (checksum) + memcpy(rep->sha1_digest, checksum->digest, sizeof(rep->sha1_digest)); /* Read the uniquifier. */ str = svn_cstring_tokenize("/", &string); |