resolve some compiler warnings.

remotes/push_mirror/0.98.1
Steve Morgan 12 years ago
parent 46acb3b40d
commit 5a5d38e4f5
  1. 7
      libclamav/scanners.c
  2. 23
      libclamav/xar.c
  3. 18
      libclamav/xz_iface.c

@ -706,13 +706,13 @@ static int cli_scanxz(cli_ctx *ctx)
int ret = CL_CLEAN, fd, rc;
unsigned long int size = 0;
char *tmpname;
struct CLI_XZ strm = {0};
struct CLI_XZ strm = {{0}};
size_t off = 0;
size_t avail;
char * buf = cli_malloc(CLI_XZ_OBUF_SIZE);
unsigned char * buf = cli_malloc(CLI_XZ_OBUF_SIZE);
if (buf == NULL) {
cli_errmsg("cli_scanxz: DecompressInit failed: %i\n", rc);
cli_errmsg("cli_scanxz: nomemory for decompress buffer.\n");
return CL_EMEM;
}
strm.next_out = buf;
@ -2399,7 +2399,6 @@ static int magic_scandesc(cli_ctx *ctx, cli_file_t type)
bitset_t *old_hook_lsig_matches;
const char *filetype;
int cache_clean = 0, res;
unsigned int viruses_found = 0;
if(!ctx->engine) {
cli_errmsg("CRITICAL: engine == NULL\n");

@ -94,10 +94,10 @@ static int xar_get_numeric_from_xml_element(xmlTextReaderPtr reader, long * valu
hash - pointer to int for returning checksum algorithm.
returns - void
*/
static void xar_get_checksum_values(xmlTextReaderPtr reader, char ** cksum, int * hash)
static void xar_get_checksum_values(xmlTextReaderPtr reader, unsigned char ** cksum, int * hash)
{
xmlChar * style = xmlTextReaderGetAttribute(reader, (const xmlChar *)"style");
const char * xmlval;
const xmlChar * xmlval;
*hash = XAR_CKSUM_NONE;
if (style == NULL) {
@ -116,7 +116,7 @@ static void xar_get_checksum_values(xmlTextReaderPtr reader, char ** cksum, int
}
if (xmlTextReaderRead(reader) == 1 && xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT) {
xmlval = (const char *)xmlTextReaderConstValue(reader);
xmlval = xmlTextReaderConstValue(reader);
if (xmlval) {
*cksum = xmlStrdup(xmlval);
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
returns - CL_FORMAT, CL_SUCCESS, CL_BREAK. CL_BREAK indicates no more <data>/<ea> element.
*/
static int xar_get_toc_data_values(xmlTextReaderPtr reader, long *length, long *offset, long *size, int *encoding,
char ** a_cksum, int * a_hash, char ** e_cksum, int * e_hash)
unsigned char ** a_cksum, int * a_hash, unsigned char ** e_cksum, int * e_hash)
{
const xmlChar *name;
int indata = 0, inea = 0;
@ -291,7 +291,7 @@ static int xar_scan_subdocuments(xmlTextReaderPtr reader, cli_ctx *ctx)
subdoc_len = xmlStrlen(subdoc);
cli_dbgmsg("cli_scanxar: in-memory scan of xml subdocument, len %i.\n", subdoc_len);
rc = cli_mem_scandesc(subdoc, subdoc_len, ctx);
if (rc = CL_VIRUS && SCAN_ALL)
if (rc == CL_VIRUS && SCAN_ALL)
rc = CL_SUCCESS;
/* make a file to leave if --leave-temps in effect */
@ -419,7 +419,7 @@ int cli_scanxar(cli_ctx *ctx)
char *toc, *tmpname;
xmlTextReaderPtr reader = NULL;
int a_hash, e_hash;
char *a_cksum = NULL, *e_cksum = NULL;
unsigned char *a_cksum = NULL, *e_cksum = NULL;
/* retrieve xar header */
if (fmap_readn(*ctx->fmap, &hdr, 0, sizeof(hdr)) != sizeof(hdr)) {
@ -530,7 +530,7 @@ int cli_scanxar(cli_ctx *ctx)
while (CL_SUCCESS == (rc = xar_get_toc_data_values(reader, &length, &offset, &size, &encoding,
&a_cksum, &a_hash, &e_cksum, &e_hash))) {
int do_extract_cksum = 1;
char * blockp;
unsigned char * blockp;
SHA1Context a_sc, e_sc;
cli_md5_ctx a_mc, e_mc;
void *a_hash_ctx, *e_hash_ctx;
@ -627,11 +627,12 @@ int cli_scanxar(cli_ctx *ctx)
#define CLI_LZMA_HDR_SIZE LZMA_PROPS_SIZE+8
#define CLI_LZMA_IBUF_SIZE CLI_LZMA_OBUF_SIZE>>2 /* estimated compression ratio 25% */
{
struct CLI_LZMA lz = {0};
struct CLI_LZMA lz;
unsigned long in_remaining = length;
unsigned long out_size = 0;
char * buff = __lzma_wrap_alloc(NULL, CLI_LZMA_OBUF_SIZE);
unsigned char * buff = __lzma_wrap_alloc(NULL, CLI_LZMA_OBUF_SIZE);
memset(&lz, 0, sizeof(lz));
if (buff == NULL) {
cli_errmsg("cli_scanxar: memory request for lzma decompression buffer fails.\n");
rc = CL_EMEM;
@ -766,7 +767,7 @@ int cli_scanxar(cli_ctx *ctx)
xar_hash_final(a_hash_ctx, result, a_hash);
if (a_cksum != NULL) {
expected = cli_hex2str(a_cksum);
expected = cli_hex2str((char *)a_cksum);
if (xar_hash_check(a_hash, result, expected) != 0) {
cli_dbgmsg("cli_scanxar: archived-checksum missing or mismatch.\n");
cksum_fails++;
@ -780,7 +781,7 @@ int cli_scanxar(cli_ctx *ctx)
if (e_cksum != NULL) {
if (do_extract_cksum) {
xar_hash_final(e_hash_ctx, result, e_hash);
expected = cli_hex2str(e_cksum);
expected = cli_hex2str((char *)e_cksum);
if (xar_hash_check(e_hash, result, expected) != 0) {
cli_dbgmsg("cli_scanxar: extracted-checksum missing or mismatch.\n");
cksum_fails++;

@ -23,7 +23,6 @@
#endif
#include "7z/Sha256.h"
#include "7z/LzmaDec.h"
#include "7z/XzCrc64.h"
#include "xz_iface.h"
@ -44,19 +43,6 @@ void __xz_wrap_free(void *unused, void *freeme) {
}
static ISzAlloc g_Alloc = { __xz_wrap_alloc, __xz_wrap_free };
static unsigned char xz_getbyte(struct CLI_XZ *L, int *fail) {
unsigned char c;
if (!L->next_in || !L->avail_in) {
*fail = 1;
return 0;
}
*fail = 0;
c = L->next_in[0];
L->next_in++;
L->avail_in--;
return c;
}
int cli_XzInit(struct CLI_XZ *XZ) {
if (SZ_OK != XzUnpacker_Create(&XZ->state, &g_Alloc))
@ -77,12 +63,12 @@ int cli_XzDecode(struct CLI_XZ *XZ) {
inbytes = XZ->avail_in;
outbytes = XZ->avail_out;
res = XzUnpacker_Code(&XZ->state, XZ->next_out, &outbytes,
XZ->next_in, &inbytes, LZMA_FINISH_ANY, &XZ->status);
XZ->next_in, &inbytes, CODER_FINISH_ANY, &XZ->status);
XZ->avail_in -= inbytes;
XZ->next_in += inbytes;
XZ->avail_out -= outbytes;
XZ->next_out += outbytes;
if (XZ->status == LZMA_STATUS_FINISHED_WITH_MARK || XzUnpacker_IsStreamWasFinished(&XZ->state))
if (XZ->status == CODER_STATUS_FINISHED_WITH_MARK || XzUnpacker_IsStreamWasFinished(&XZ->state))
return XZ_STREAM_END;
if (XZ->status == CODER_STATUS_NOT_FINISHED && XZ->avail_out == 0)
return XZ_RESULT_OK;

Loading…
Cancel
Save