subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1759686 - /subversion/trunk/subversion/libsvn_fs_fs/low_level.c
Date Wed, 07 Sep 2016 20:02:08 GMT
Author: stefan2
Date: Wed Sep  7 20:02:08 2016
New Revision: 1759686

URL: http://svn.apache.org/viewvc?rev=1759686&view=rev
Log:
Don't crash in FSFS upon all-zero MD5 or SHA1.

Subversion basically ignores / forgets all-0 checksums.  This is due to
svn_checksum_parse_hex treating them equivalent to 'not given' at various
API levels.

The 1.9 did not account for this quirky behavior and would crash.  With
this patch, those checksums are correctly represented as all-0 internally.

* subversion/libsvn_fs_fs/low_level.c
  (svn_fs_fs__parse_representation): Don't attempt to copy from a checksum
                                     object that does not exist.

Reported by: danielsh

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/low_level.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/low_level.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/low_level.c?rev=1759686&r1=1759685&r2=1759686&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/low_level.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/low_level.c Wed Sep  7 20:02:08 2016
@@ -800,7 +800,11 @@ svn_fs_fs__parse_representation(represen
 
   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);
@@ -814,8 +818,16 @@ svn_fs_fs__parse_representation(represen
 
   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);



Mime
View raw message