...
|
...
|
@@ -186,7 +186,8 @@ static int xar_get_toc_data_values(xmlTextReaderPtr reader, long *length, long *
|
186
|
186
|
cli_dbgmsg("cli_scanxar: <archived-checksum>:\n");
|
187
|
187
|
xar_get_checksum_values(reader, a_cksum, a_hash);
|
188
|
188
|
|
189
|
|
- } else if (xmlStrEqual(name, (const xmlChar *)"extracted-checksum") &&
|
|
189
|
+ } else if ((xmlStrEqual(name, (const xmlChar *)"extracted-checksum") ||
|
|
190
|
+ xmlStrEqual(name, (const xmlChar *)"unarchived-checksum")) &&
|
190
|
191
|
xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {
|
191
|
192
|
cli_dbgmsg("cli_scanxar: <extracted-checksum>:\n");
|
192
|
193
|
xar_get_checksum_values(reader, e_cksum, e_hash);
|
...
|
...
|
@@ -561,11 +562,7 @@ int cli_scanxar(cli_ctx *ctx)
|
561
|
561
|
|
562
|
562
|
|
563
|
563
|
a_hash_ctx = xar_hash_init(a_hash, &a_sc, &a_mc);
|
564
|
|
- if (a_hash_ctx == NULL)
|
565
|
|
- goto exit_tmpfile;
|
566
|
564
|
e_hash_ctx = xar_hash_init(e_hash, &e_sc, &e_mc);
|
567
|
|
- if (e_hash_ctx == NULL)
|
568
|
|
- goto exit_tmpfile;
|
569
|
565
|
|
570
|
566
|
switch (encoding) {
|
571
|
567
|
case CL_TYPE_GZ:
|
...
|
...
|
@@ -606,7 +603,8 @@ int cli_scanxar(cli_ctx *ctx)
|
606
|
606
|
|
607
|
607
|
bytes = sizeof(buff) - strm.avail_out;
|
608
|
608
|
|
609
|
|
- xar_hash_update(e_hash_ctx, buff, bytes, e_hash);
|
|
609
|
+ if (e_hash_ctx != NULL)
|
|
610
|
+ xar_hash_update(e_hash_ctx, buff, bytes, e_hash);
|
610
|
611
|
|
611
|
612
|
if (cli_writen(fd, buff, bytes) < 0) {
|
612
|
613
|
cli_dbgmsg("cli_scanxar: cli_writen error file %s.\n", tmpname);
|
...
|
...
|
@@ -627,7 +625,8 @@ int cli_scanxar(cli_ctx *ctx)
|
627
|
627
|
break;
|
628
|
628
|
|
629
|
629
|
avail_in -= strm.avail_in;
|
630
|
|
- xar_hash_update(a_hash_ctx, next_in, avail_in, a_hash);
|
|
630
|
+ if (a_hash_ctx != NULL)
|
|
631
|
+ xar_hash_update(a_hash_ctx, next_in, avail_in, a_hash);
|
631
|
632
|
}
|
632
|
633
|
|
633
|
634
|
inflateEnd(&strm);
|
...
|
...
|
@@ -665,7 +664,8 @@ int cli_scanxar(cli_ctx *ctx)
|
665
|
665
|
lz.next_in = blockp;
|
666
|
666
|
lz.avail_in = CLI_LZMA_HDR_SIZE;
|
667
|
667
|
|
668
|
|
- xar_hash_update(a_hash_ctx, blockp, CLI_LZMA_HDR_SIZE, a_hash);
|
|
668
|
+ if (a_hash_ctx != NULL)
|
|
669
|
+ xar_hash_update(a_hash_ctx, blockp, CLI_LZMA_HDR_SIZE, a_hash);
|
669
|
670
|
|
670
|
671
|
lret = cli_LzmaInit(&lz, 0);
|
671
|
672
|
if (lret != LZMA_RESULT_OK) {
|
...
|
...
|
@@ -716,8 +716,10 @@ int cli_scanxar(cli_ctx *ctx)
|
716
|
716
|
cli_dbgmsg("cli_scanxar: cli_LzmaDecode() produces no output for "
|
717
|
717
|
"avail_in %lu, avail_out %lu.\n", avail_in, avail_out);
|
718
|
718
|
|
719
|
|
- xar_hash_update(a_hash_ctx, next_in, in_consumed, a_hash);
|
720
|
|
- xar_hash_update(e_hash_ctx, buff, avail_out, e_hash);
|
|
719
|
+ if (a_hash_ctx != NULL)
|
|
720
|
+ xar_hash_update(a_hash_ctx, next_in, in_consumed, a_hash);
|
|
721
|
+ if (e_hash_ctx != NULL)
|
|
722
|
+ xar_hash_update(e_hash_ctx, buff, avail_out, e_hash);
|
721
|
723
|
|
722
|
724
|
/* Write a decompressed block. */
|
723
|
725
|
/* cli_dbgmsg("Writing %li bytes to LZMA decompress temp file, " */
|
...
|
...
|
@@ -770,7 +772,8 @@ int cli_scanxar(cli_ctx *ctx)
|
770
|
770
|
goto exit_tmpfile;
|
771
|
771
|
}
|
772
|
772
|
|
773
|
|
- xar_hash_update(a_hash_ctx, blockp, length, a_hash);
|
|
773
|
+ if (a_hash_ctx != NULL)
|
|
774
|
+ xar_hash_update(a_hash_ctx, blockp, length, a_hash);
|
774
|
775
|
|
775
|
776
|
if (cli_writen(fd, blockp, write_len) < 0) {
|
776
|
777
|
cli_dbgmsg("cli_scanxar: cli_writen error %li bytes @ %li.\n", length, at);
|
...
|
...
|
@@ -782,25 +785,36 @@ int cli_scanxar(cli_ctx *ctx)
|
782
|
782
|
}
|
783
|
783
|
|
784
|
784
|
if (rc == CL_SUCCESS) {
|
785
|
|
- xar_hash_final(a_hash_ctx, result, a_hash);
|
786
|
|
- a_hash_ctx = NULL;
|
|
785
|
+ if (a_hash_ctx != NULL) {
|
|
786
|
+ xar_hash_final(a_hash_ctx, result, a_hash);
|
|
787
|
+ a_hash_ctx = NULL;
|
|
788
|
+ } else {
|
|
789
|
+ cli_dbgmsg("cli_scanxar: archived-checksum missing.\n");
|
|
790
|
+ cksum_fails++;
|
|
791
|
+ }
|
787
|
792
|
if (a_cksum != NULL) {
|
788
|
793
|
expected = cli_hex2str((char *)a_cksum);
|
789
|
794
|
if (xar_hash_check(a_hash, result, expected) != 0) {
|
790
|
|
- cli_dbgmsg("cli_scanxar: archived-checksum missing or mismatch.\n");
|
|
795
|
+ cli_dbgmsg("cli_scanxar: archived-checksum mismatch.\n");
|
791
|
796
|
cksum_fails++;
|
792
|
797
|
} else {
|
793
|
798
|
cli_dbgmsg("cli_scanxar: archived-checksum matched.\n");
|
794
|
799
|
}
|
795
|
800
|
free(expected);
|
796
|
801
|
}
|
797
|
|
- xar_hash_final(e_hash_ctx, result, e_hash);
|
798
|
|
- e_hash_ctx = NULL;
|
|
802
|
+
|
|
803
|
+ if (e_hash_ctx != NULL) {
|
|
804
|
+ xar_hash_final(e_hash_ctx, result, e_hash);
|
|
805
|
+ e_hash_ctx = NULL;
|
|
806
|
+ } else {
|
|
807
|
+ cli_dbgmsg("cli_scanxar: extracted-checksum(unarchived-checksum) missing.\n");
|
|
808
|
+ cksum_fails++;
|
|
809
|
+ }
|
799
|
810
|
if (e_cksum != NULL) {
|
800
|
811
|
if (do_extract_cksum) {
|
801
|
812
|
expected = cli_hex2str((char *)e_cksum);
|
802
|
813
|
if (xar_hash_check(e_hash, result, expected) != 0) {
|
803
|
|
- cli_dbgmsg("cli_scanxar: extracted-checksum missing or mismatch.\n");
|
|
814
|
+ cli_dbgmsg("cli_scanxar: extracted-checksum mismatch.\n");
|
804
|
815
|
cksum_fails++;
|
805
|
816
|
} else {
|
806
|
817
|
cli_dbgmsg("cli_scanxar: extracted-checksum matched.\n");
|