Browse code

more friendly extract-checksum verification for unknown or usupported compression formats.

Steve Morgan authored on 2013/09/24 07:04:09
Showing 1 changed files
... ...
@@ -525,6 +525,7 @@ int cli_scanxar(cli_ctx *ctx)
525 525
     tmpname = NULL;
526 526
     while (CL_SUCCESS == (rc = xar_get_toc_data_values(reader, &length, &offset, &size, &encoding,
527 527
                                                        &a_cksum, &a_hash, &e_cksum, &e_hash))) {
528
+        int do_extract_cksum = 1;
528 529
         char * blockp;
529 530
         SHA1Context a_sc, e_sc;
530 531
         cli_md5_ctx a_mc, e_mc;
... ...
@@ -727,9 +728,10 @@ int cli_scanxar(cli_ctx *ctx)
727 727
                 __lzma_wrap_free(NULL, buff);
728 728
             }
729 729
             break; 
730
+        case CL_TYPE_ANY:
730 731
         default:
731 732
         case CL_TYPE_BZ:
732
-        case CL_TYPE_ANY:
733
+            do_extract_cksum = 0;
733 734
             {
734 735
                 /* for uncompressed, bzip2, and unknown, just pull the file, cli_magic_scandesc does the rest */
735 736
                 unsigned long write_len;
... ...
@@ -747,7 +749,6 @@ int cli_scanxar(cli_ctx *ctx)
747 747
                 }
748 748
                 
749 749
                 xar_hash_update(a_hash_ctx, blockp, length, a_hash);
750
-                xar_hash_update(e_hash_ctx, blockp, length, e_hash);
751 750
                 
752 751
                 if (cli_writen(fd, blockp, write_len) < 0) {
753 752
                     cli_dbgmsg("cli_scanxar: cli_writen error %li bytes @ %li.\n", length, at);
... ...
@@ -772,15 +773,17 @@ int cli_scanxar(cli_ctx *ctx)
772 772
             a_cksum = NULL;
773 773
         }
774 774
         if (e_cksum != NULL) {
775
-            xar_hash_final(e_hash_ctx, result, e_hash);
776
-            expected = cli_hex2str(e_cksum);
777
-            if (xar_hash_check(e_hash, result, expected) != 0) {
778
-                cli_dbgmsg("cli_scanxar: extracted-checksum missing or mismatch.\n");
779
-                cksum_fails++;
780
-            } else {
781
-                cli_dbgmsg("cli_scanxar: extracted-checksum matched.\n");                
775
+            if (do_extract_cksum) {
776
+                xar_hash_final(e_hash_ctx, result, e_hash);
777
+                expected = cli_hex2str(e_cksum);
778
+                if (xar_hash_check(e_hash, result, expected) != 0) {
779
+                    cli_dbgmsg("cli_scanxar: extracted-checksum missing or mismatch.\n");
780
+                    cksum_fails++;
781
+                } else {
782
+                    cli_dbgmsg("cli_scanxar: extracted-checksum matched.\n");                
783
+                }
784
+                free(expected);
782 785
             }
783
-            free(expected);
784 786
             xmlFree(e_cksum);
785 787
             e_cksum = NULL;
786 788
         }