Make handleOverlappedFiles() honor rpmfi digest algorithm
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 29 May 2008 12:48:40 +0000 (15:48 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 2 Jun 2008 06:50:48 +0000 (09:50 +0300)
lib/transaction.c

index 1efc871..9ae5b8f 100644 (file)
@@ -566,12 +566,16 @@ assert(otherFi != NULL);
            }
                
            /* Here is a pre-existing modified config file that needs saving. */
-           {   unsigned char md5sum[50];
-               const unsigned char * MD5 = rpmfiMD5(fi);
-               if (!rpmDoDigest(PGPHASHALGO_MD5, fn, 0, md5sum, NULL) &&
-                   memcmp(MD5, md5sum, 16)) {
-                   fi->actions[i] = FA_BACKUP;
-                   break;
+           {   pgpHashAlgo algo = 0;
+               size_t diglen = 0;
+               const unsigned char *digest;
+               if ((digest = rpmfiDigest(fi, &algo, &diglen))) {
+                   unsigned char fdigest[diglen];
+                   if (!rpmDoDigest(algo, fn, 0, fdigest, NULL) &&
+                       memcmp(digest, fdigest, diglen)) {
+                       fi->actions[i] = FA_BACKUP;
+                       break;
+                   }
                }
            }
            fi->actions[i] = FA_ERASE;