subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1654981 - /subversion/trunk/subversion/libsvn_subr/checksum.c
Date Tue, 27 Jan 2015 06:42:19 GMT
Author: stefan2
Date: Tue Jan 27 06:42:18 2015
New Revision: 1654981

URL: http://svn.apache.org/r1654981
Log:
Fix segfault in svn_checksum__from_digest_fnv1a_32() and
svn_checksum__from_digest_fnv1a_32x4().

* subversion/libsvn_subr/checksum.c
  (checksum_create): Remove redundant DIGEST_SIZE parameter.
  (svn_checksum__from_digest_md5,
   svn_checksum__from_digest_sha1,
   svn_checksum__from_digest_fnv1a_32,
   svn_checksum__from_digest_fnv1a_32x4,
   svn_checksum_dup,
   svn_checksum_empty_checksum): Update callers.

Found by: hwright

Modified:
    subversion/trunk/subversion/libsvn_subr/checksum.c

Modified: subversion/trunk/subversion/libsvn_subr/checksum.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/checksum.c?rev=1654981&r1=1654980&r2=1654981&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/checksum.c (original)
+++ subversion/trunk/subversion/libsvn_subr/checksum.c Tue Jan 27 06:42:18 2015
@@ -165,12 +165,15 @@ checksum_create_without_digest(svn_check
   return checksum;
 }
 
+/* Return a checksum object, allocated in POOL.  The checksum will be of
+ * type KIND and contain the given DIGEST.
+ */
 static svn_checksum_t *
 checksum_create(svn_checksum_kind_t kind,
-                apr_size_t digest_size,
                 const unsigned char *digest,
                 apr_pool_t *pool)
 {
+  apr_size_t digest_size = DIGESTSIZE(kind);
   svn_checksum_t *checksum = checksum_create_without_digest(kind, digest_size,
                                                             pool);
   memcpy((unsigned char *)checksum->digest, digest, digest_size);
@@ -206,32 +209,28 @@ svn_checksum_t *
 svn_checksum__from_digest_md5(const unsigned char *digest,
                               apr_pool_t *result_pool)
 {
-  return checksum_create(svn_checksum_md5, APR_MD5_DIGESTSIZE, digest,
-                         result_pool);
+  return checksum_create(svn_checksum_md5, digest, result_pool);
 }
 
 svn_checksum_t *
 svn_checksum__from_digest_sha1(const unsigned char *digest,
                                apr_pool_t *result_pool)
 {
-  return checksum_create(svn_checksum_sha1, APR_SHA1_DIGESTSIZE, digest,
-                         result_pool);
+  return checksum_create(svn_checksum_sha1, digest, result_pool);
 }
 
 svn_checksum_t *
 svn_checksum__from_digest_fnv1a_32(const unsigned char *digest,
                                    apr_pool_t *result_pool)
 {
-  return checksum_create(svn_checksum_fnv1a_32, sizeof(digest), digest,
-                         result_pool);
+  return checksum_create(svn_checksum_fnv1a_32, digest, result_pool);
 }
 
 svn_checksum_t *
 svn_checksum__from_digest_fnv1a_32x4(const unsigned char *digest,
                                      apr_pool_t *result_pool)
 {
-  return checksum_create(svn_checksum_fnv1a_32x4, sizeof(digest), digest,
-                         result_pool);
+  return checksum_create(svn_checksum_fnv1a_32x4, digest, result_pool);
 }
 
 svn_error_t *
@@ -428,10 +427,7 @@ svn_checksum_dup(const svn_checksum_t *c
       case svn_checksum_sha1:
       case svn_checksum_fnv1a_32:
       case svn_checksum_fnv1a_32x4:
-        return checksum_create(checksum->kind,
-                               digest_sizes[checksum->kind],
-                               checksum->digest,
-                               pool);
+        return checksum_create(checksum->kind, checksum->digest, pool);
 
       default:
         SVN_ERR_MALFUNCTION_NO_RETURN();
@@ -492,10 +488,7 @@ svn_checksum_empty_checksum(svn_checksum
       case svn_checksum_sha1:
       case svn_checksum_fnv1a_32:
       case svn_checksum_fnv1a_32x4:
-        return checksum_create(kind,
-                               digest_sizes[kind],
-                               empty_string_digests[kind],
-                               pool);
+        return checksum_create(kind, empty_string_digests[kind], pool);
 
       default:
         /* We really shouldn't get here, but if we do... */



Mime
View raw message