Browse code

xar checksum fixes

Steve Morgan authored on 2013/09/24 05:18:54
Showing 1 changed files
... ...
@@ -100,9 +100,9 @@ static void xar_get_checksum_values(xmlTextReaderPtr reader, char ** cksum, int
100 100
                    "for checksum element\n");
101 101
     } else {
102 102
         cli_dbgmsg("cli_scanxar: checksum algorithm is %s.\n", style);        
103
-        if (xmlStrEqual(style, (const xmlChar *)"sha1")) {
103
+        if (0 == xmlStrcasecmp(style, (const xmlChar *)"sha1")) {
104 104
             *hash = XAR_CKSUM_SHA1;
105
-        } else if (xmlStrEqual(style, (const xmlChar *)"md5")) {
105
+        } else if (0 == xmlStrcasecmp(style, (const xmlChar *)"md5")) {
106 106
             *hash = XAR_CKSUM_MD5;
107 107
         } else {
108 108
             cli_dbgmsg("cli_scanxar: checksum algorithm %s is unsupported.\n", style);
... ...
@@ -565,20 +565,19 @@ int cli_scanxar(cli_ctx *ctx)
565 565
             }
566 566
             
567 567
             while (at < map->len && at < offset+hdr.toc_length_compressed+hdr.size+length) {
568
+                unsigned long avail_in;
569
+                void * next_in;
568 570
                 unsigned int bytes = MIN(map->len - at, map->pgsz);
569 571
                 bytes = MIN(length, bytes);
570 572
                 cli_dbgmsg("cli_scanxar: fmap %u bytes\n", bytes);
571
-                if(!(strm.next_in = (void*)fmap_need_off_once(map, at, bytes))) {
573
+                if(!(strm.next_in = next_in = (void*)fmap_need_off_once(map, at, bytes))) {
572 574
                     cli_dbgmsg("cli_scanxar: Can't read %u bytes @ %lu.\n", bytes, (long unsigned)at);
573 575
                     inflateEnd(&strm);
574 576
                     rc = CL_EREAD;
575 577
                     goto exit_tmpfile;
576 578
                 }
577
-
578
-                xar_hash_update(a_hash_ctx, strm.next_in, bytes, a_hash);
579
-
580 579
                 at += bytes;
581
-                strm.avail_in = bytes;
580
+                strm.avail_in = avail_in = bytes;
582 581
                 do {
583 582
                     int inf, outsize = 0;
584 583
                     unsigned char buff[FILEBUFF];
... ...
@@ -611,6 +610,9 @@ int cli_scanxar(cli_ctx *ctx)
611 611
                         break;
612 612
                     }
613 613
                 } while (strm.avail_out == 0);
614
+
615
+                avail_in -= strm.avail_in;
616
+                xar_hash_update(a_hash_ctx, next_in, avail_in, a_hash);
614 617
             }
615 618
             
616 619
             inflateEnd(&strm);
... ...
@@ -816,7 +818,7 @@ int cli_scanxar(cli_ctx *ctx)
816 816
     cli_dbgmsg("cli_scanxar: can't scan xar files, need libxml2.\n");
817 817
 #endif
818 818
     if (cksum_fails != 0)
819
-        cli_warnmsg("cli_scanxar: %u checksums missing/mismatched- use --debug for more info.\n", cksum_fails);
819
+        cli_warnmsg("cli_scanxar: %u checksums missing, mismatched, or unsupported - use --debug for more info.\n", cksum_fails);
820 820
 
821 821
     return rc;
822 822
 }