Browse code

resolve some compiler warnings.

Steve Morgan authored on 2013/10/12 01:04:29
Showing 3 changed files
... ...
@@ -706,13 +706,13 @@ static int cli_scanxz(cli_ctx *ctx)
706 706
     int ret = CL_CLEAN, fd, rc;
707 707
     unsigned long int size = 0;
708 708
     char *tmpname;
709
-    struct CLI_XZ strm = {0};
709
+    struct CLI_XZ strm = {{0}};
710 710
     size_t off = 0;
711 711
     size_t avail;
712
-    char * buf = cli_malloc(CLI_XZ_OBUF_SIZE);
712
+    unsigned char * buf = cli_malloc(CLI_XZ_OBUF_SIZE);
713 713
 
714 714
     if (buf == NULL) {
715
-	cli_errmsg("cli_scanxz: DecompressInit failed: %i\n", rc);
715
+	cli_errmsg("cli_scanxz: nomemory for decompress buffer.\n");
716 716
         return CL_EMEM;
717 717
     }
718 718
     strm.next_out = buf;
... ...
@@ -2399,7 +2399,6 @@ static int magic_scandesc(cli_ctx *ctx, cli_file_t type)
2399 2399
 	bitset_t *old_hook_lsig_matches;
2400 2400
 	const char *filetype;
2401 2401
 	int cache_clean = 0, res;
2402
-	unsigned int viruses_found = 0;
2403 2402
 
2404 2403
     if(!ctx->engine) {
2405 2404
 	cli_errmsg("CRITICAL: engine == NULL\n");
... ...
@@ -94,10 +94,10 @@ static int xar_get_numeric_from_xml_element(xmlTextReaderPtr reader, long * valu
94 94
     hash - pointer to int for returning checksum algorithm.
95 95
   returns - void
96 96
  */
97
-static void xar_get_checksum_values(xmlTextReaderPtr reader, char ** cksum, int * hash)
97
+static void xar_get_checksum_values(xmlTextReaderPtr reader, unsigned char ** cksum, int * hash)
98 98
 {
99 99
     xmlChar * style = xmlTextReaderGetAttribute(reader, (const xmlChar *)"style");
100
-    const char * xmlval;
100
+    const xmlChar * xmlval;
101 101
 
102 102
     *hash = XAR_CKSUM_NONE;
103 103
     if (style == NULL) {
... ...
@@ -116,7 +116,7 @@ static void xar_get_checksum_values(xmlTextReaderPtr reader, char ** cksum, int
116 116
     }
117 117
 
118 118
     if (xmlTextReaderRead(reader) == 1 && xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT) {
119
-        xmlval = (const char *)xmlTextReaderConstValue(reader);
119
+        xmlval = xmlTextReaderConstValue(reader);
120 120
         if (xmlval) {
121 121
             *cksum = xmlStrdup(xmlval); 
122 122
             cli_dbgmsg("cli_scanxar: checksum value is %s.\n", *cksum);
... ...
@@ -145,7 +145,7 @@ static void xar_get_checksum_values(xmlTextReaderPtr reader, char ** cksum, int
145 145
    returns - CL_FORMAT, CL_SUCCESS, CL_BREAK. CL_BREAK indicates no more <data>/<ea> element.
146 146
  */
147 147
 static int xar_get_toc_data_values(xmlTextReaderPtr reader, long *length, long *offset, long *size, int *encoding,
148
-                                   char ** a_cksum, int * a_hash, char ** e_cksum, int * e_hash)
148
+                                   unsigned char ** a_cksum, int * a_hash, unsigned char ** e_cksum, int * e_hash)
149 149
 {
150 150
     const xmlChar *name;
151 151
     int indata = 0, inea = 0;
... ...
@@ -291,7 +291,7 @@ static int xar_scan_subdocuments(xmlTextReaderPtr reader, cli_ctx *ctx)
291 291
             subdoc_len = xmlStrlen(subdoc);
292 292
             cli_dbgmsg("cli_scanxar: in-memory scan of xml subdocument, len %i.\n", subdoc_len);
293 293
             rc = cli_mem_scandesc(subdoc, subdoc_len, ctx);
294
-            if (rc = CL_VIRUS && SCAN_ALL)
294
+            if (rc == CL_VIRUS && SCAN_ALL)
295 295
                 rc = CL_SUCCESS;
296 296
             
297 297
             /* make a file to leave if --leave-temps in effect */
... ...
@@ -419,7 +419,7 @@ int cli_scanxar(cli_ctx *ctx)
419 419
     char *toc, *tmpname;
420 420
     xmlTextReaderPtr reader = NULL;
421 421
     int a_hash, e_hash;
422
-    char *a_cksum = NULL, *e_cksum = NULL;
422
+    unsigned char *a_cksum = NULL, *e_cksum = NULL;
423 423
 
424 424
     /* retrieve xar header */
425 425
     if (fmap_readn(*ctx->fmap, &hdr, 0, sizeof(hdr)) != sizeof(hdr)) {
... ...
@@ -530,7 +530,7 @@ int cli_scanxar(cli_ctx *ctx)
530 530
     while (CL_SUCCESS == (rc = xar_get_toc_data_values(reader, &length, &offset, &size, &encoding,
531 531
                                                        &a_cksum, &a_hash, &e_cksum, &e_hash))) {
532 532
         int do_extract_cksum = 1;
533
-        char * blockp;
533
+        unsigned char * blockp;
534 534
         SHA1Context a_sc, e_sc;
535 535
         cli_md5_ctx a_mc, e_mc;
536 536
         void *a_hash_ctx, *e_hash_ctx;
... ...
@@ -627,11 +627,12 @@ int cli_scanxar(cli_ctx *ctx)
627 627
 #define CLI_LZMA_HDR_SIZE LZMA_PROPS_SIZE+8
628 628
 #define CLI_LZMA_IBUF_SIZE CLI_LZMA_OBUF_SIZE>>2 /* estimated compression ratio 25% */
629 629
             {
630
-                struct CLI_LZMA lz = {0};
630
+                struct CLI_LZMA lz;
631 631
                 unsigned long in_remaining = length;
632 632
                 unsigned long out_size = 0;
633
-                char * buff = __lzma_wrap_alloc(NULL, CLI_LZMA_OBUF_SIZE);
633
+                unsigned char * buff = __lzma_wrap_alloc(NULL, CLI_LZMA_OBUF_SIZE);
634 634
                 
635
+                memset(&lz, 0, sizeof(lz));
635 636
                 if (buff == NULL) {
636 637
                     cli_errmsg("cli_scanxar: memory request for lzma decompression buffer fails.\n");
637 638
                     rc = CL_EMEM;
... ...
@@ -766,7 +767,7 @@ int cli_scanxar(cli_ctx *ctx)
766 766
 
767 767
         xar_hash_final(a_hash_ctx, result, a_hash);
768 768
         if (a_cksum != NULL) {
769
-            expected = cli_hex2str(a_cksum);
769
+            expected = cli_hex2str((char *)a_cksum);
770 770
             if (xar_hash_check(a_hash, result, expected) != 0) {
771 771
                 cli_dbgmsg("cli_scanxar: archived-checksum missing or mismatch.\n");
772 772
                 cksum_fails++;
... ...
@@ -780,7 +781,7 @@ int cli_scanxar(cli_ctx *ctx)
780 780
         if (e_cksum != NULL) {
781 781
             if (do_extract_cksum) {
782 782
                 xar_hash_final(e_hash_ctx, result, e_hash);
783
-                expected = cli_hex2str(e_cksum);
783
+                expected = cli_hex2str((char *)e_cksum);
784 784
                 if (xar_hash_check(e_hash, result, expected) != 0) {
785 785
                     cli_dbgmsg("cli_scanxar: extracted-checksum missing or mismatch.\n");
786 786
                     cksum_fails++;
... ...
@@ -23,7 +23,6 @@
23 23
 #endif
24 24
 
25 25
 #include "7z/Sha256.h"
26
-#include "7z/LzmaDec.h"
27 26
 #include "7z/XzCrc64.h"
28 27
 #include "xz_iface.h"
29 28
 
... ...
@@ -44,19 +43,6 @@ void __xz_wrap_free(void *unused, void *freeme) {
44 44
 }
45 45
 
46 46
 static ISzAlloc g_Alloc = { __xz_wrap_alloc, __xz_wrap_free };
47
-
48
-static unsigned char xz_getbyte(struct CLI_XZ *L, int *fail) {
49
-    unsigned char c;
50
-    if (!L->next_in || !L->avail_in) {
51
-	*fail = 1;
52
-	return 0;
53
-    }
54
-    *fail = 0;
55
-    c = L->next_in[0];
56
-    L->next_in++;
57
-    L->avail_in--;
58
-    return c;
59
-}
60 47
     
61 48
 int cli_XzInit(struct CLI_XZ *XZ) {
62 49
     if (SZ_OK != XzUnpacker_Create(&XZ->state, &g_Alloc))
... ...
@@ -77,12 +63,12 @@ int cli_XzDecode(struct CLI_XZ *XZ) {
77 77
     inbytes = XZ->avail_in;
78 78
     outbytes = XZ->avail_out;
79 79
     res = XzUnpacker_Code(&XZ->state, XZ->next_out, &outbytes, 
80
-                          XZ->next_in, &inbytes, LZMA_FINISH_ANY, &XZ->status);
80
+                          XZ->next_in, &inbytes, CODER_FINISH_ANY, &XZ->status);
81 81
     XZ->avail_in -= inbytes;
82 82
     XZ->next_in += inbytes;
83 83
     XZ->avail_out -= outbytes;
84 84
     XZ->next_out += outbytes;
85
-    if (XZ->status == LZMA_STATUS_FINISHED_WITH_MARK || XzUnpacker_IsStreamWasFinished(&XZ->state))
85
+    if (XZ->status == CODER_STATUS_FINISHED_WITH_MARK || XzUnpacker_IsStreamWasFinished(&XZ->state))
86 86
         return XZ_STREAM_END;
87 87
     if (XZ->status == CODER_STATUS_NOT_FINISHED && XZ->avail_out == 0)
88 88
         return XZ_RESULT_OK;