... | ... |
@@ -422,6 +422,8 @@ int cli_scanxar(cli_ctx *ctx) |
422 | 422 |
xmlTextReaderPtr reader = NULL; |
423 | 423 |
int a_hash, e_hash; |
424 | 424 |
unsigned char *a_cksum = NULL, *e_cksum = NULL; |
425 |
+ void *a_hash_ctx = NULL, *e_hash_ctx = NULL; |
|
426 |
+ char result[SHA1_HASH_SIZE]; |
|
425 | 427 |
|
426 | 428 |
memset(&strm, 0x00, sizeof(z_stream)); |
427 | 429 |
|
... | ... |
@@ -537,8 +539,6 @@ int cli_scanxar(cli_ctx *ctx) |
537 | 537 |
unsigned char * blockp; |
538 | 538 |
void *a_sc, *e_sc; |
539 | 539 |
void *a_mc, *e_mc; |
540 |
- void *a_hash_ctx, *e_hash_ctx; |
|
541 |
- char result[SHA1_HASH_SIZE]; |
|
542 | 540 |
char * expected; |
543 | 541 |
|
544 | 542 |
/* clean up temp file from previous loop iteration */ |
... | ... |
@@ -561,7 +561,11 @@ 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; |
|
564 | 566 |
e_hash_ctx = xar_hash_init(e_hash, &e_sc, &e_mc); |
567 |
+ if (e_hash_ctx == NULL) |
|
568 |
+ goto exit_tmpfile; |
|
565 | 569 |
|
566 | 570 |
switch (encoding) { |
567 | 571 |
case CL_TYPE_GZ: |
... | ... |
@@ -779,6 +783,7 @@ int cli_scanxar(cli_ctx *ctx) |
779 | 779 |
|
780 | 780 |
if (rc == CL_SUCCESS) { |
781 | 781 |
xar_hash_final(a_hash_ctx, result, a_hash); |
782 |
+ a_hash_ctx = NULL; |
|
782 | 783 |
if (a_cksum != NULL) { |
783 | 784 |
expected = cli_hex2str((char *)a_cksum); |
784 | 785 |
if (xar_hash_check(a_hash, result, expected) != 0) { |
... | ... |
@@ -789,9 +794,10 @@ int cli_scanxar(cli_ctx *ctx) |
789 | 789 |
} |
790 | 790 |
free(expected); |
791 | 791 |
} |
792 |
+ xar_hash_final(e_hash_ctx, result, e_hash); |
|
793 |
+ e_hash_ctx = NULL; |
|
792 | 794 |
if (e_cksum != NULL) { |
793 | 795 |
if (do_extract_cksum) { |
794 |
- xar_hash_final(e_hash_ctx, result, e_hash); |
|
795 | 796 |
expected = cli_hex2str((char *)e_cksum); |
796 | 797 |
if (xar_hash_check(e_hash, result, expected) != 0) { |
797 | 798 |
cli_dbgmsg("cli_scanxar: extracted-checksum missing or mismatch.\n"); |
... | ... |
@@ -828,7 +834,11 @@ int cli_scanxar(cli_ctx *ctx) |
828 | 828 |
|
829 | 829 |
exit_tmpfile: |
830 | 830 |
xar_cleanup_temp_file(ctx, fd, tmpname); |
831 |
- |
|
831 |
+ if (a_hash_ctx != NULL) |
|
832 |
+ xar_hash_final(a_hash_ctx, result, a_hash); |
|
833 |
+ if (e_hash_ctx != NULL) |
|
834 |
+ xar_hash_final(e_hash_ctx, result, e_hash); |
|
835 |
+ |
|
832 | 836 |
exit_reader: |
833 | 837 |
if (a_cksum != NULL) |
834 | 838 |
xmlFree(a_cksum); |