mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2026-05-08 23:56:48 -04:00
Merge remote-tracking branch 'origin/master' into guardrails
This commit is contained in:
@@ -96,7 +96,7 @@ struct cli_asn1 {
|
||||
const void *next;
|
||||
};
|
||||
|
||||
static int map_sha1(fmap_t *map, void *data, unsigned int len, uint8_t sha1[SHA1_HASH_SIZE]) {
|
||||
static int map_sha1(fmap_t *map, const void *data, unsigned int len, uint8_t sha1[SHA1_HASH_SIZE]) {
|
||||
SHA1Context ctx;
|
||||
if(!fmap_need_ptr_once(map, data, len)) {
|
||||
cli_dbgmsg("map_sha1: failed to read hash data\n");
|
||||
@@ -464,7 +464,7 @@ static int asn1_get_x509(fmap_t *map, const void **asn1data, unsigned int *size,
|
||||
unsigned int avail, tbssize, issuersize;
|
||||
cli_crt_hashtype hashtype1, hashtype2;
|
||||
cli_crt x509;
|
||||
uint8_t *tbsdata;
|
||||
const uint8_t *tbsdata;
|
||||
const void *next, *issuer;
|
||||
|
||||
if(cli_crt_init(&x509))
|
||||
@@ -577,7 +577,7 @@ static int asn1_get_x509(fmap_t *map, const void **asn1data, unsigned int *size,
|
||||
exts.size = 1;
|
||||
break;
|
||||
}
|
||||
crit = (uint8_t *)(value.content);
|
||||
crit = ((uint8_t *)(value.content))[0];
|
||||
if(asn1_get_obj(map, value.next, &ext.size, &value)) {
|
||||
exts.size = 1;
|
||||
break;
|
||||
@@ -602,7 +602,7 @@ static int asn1_get_x509(fmap_t *map, const void **asn1data, unsigned int *size,
|
||||
}
|
||||
if(!memcmp("\x55\x1d\x0f", id.content, 3)) {
|
||||
/* KeyUsage 2.5.29.15 */
|
||||
uint8_t *keyusage = value.content;
|
||||
const uint8_t *keyusage = value.content;
|
||||
uint32_t usage;
|
||||
if(value.size < 4 || value.size > 5) {
|
||||
cli_dbgmsg("asn1_get_x509: bad KeyUsage\n");
|
||||
@@ -624,7 +624,7 @@ static int asn1_get_x509(fmap_t *map, const void **asn1data, unsigned int *size,
|
||||
usage |= keyusage[4];
|
||||
}
|
||||
usage >>= keyusage[2];
|
||||
x509.certSign = (usage & (1<<5) != 0);
|
||||
x509.certSign = ((usage & (1<<5)) != 0);
|
||||
continue;
|
||||
}
|
||||
if(!memcmp("\x55\x1d\x25", id.content, 3)) {
|
||||
@@ -724,7 +724,8 @@ static int asn1_get_x509(fmap_t *map, const void **asn1data, unsigned int *size,
|
||||
|
||||
static int asn1_parse_mscat(fmap_t *map, const void *start, unsigned int size, crtmgr *cmgr, int embedded, const void **hashes, unsigned int *hashes_size) {
|
||||
struct cli_asn1 asn1, deep, deeper;
|
||||
uint8_t sha1[SHA1_HASH_SIZE], issuer[SHA1_HASH_SIZE], md[SHA1_HASH_SIZE], *message, *attrs;
|
||||
uint8_t sha1[SHA1_HASH_SIZE], issuer[SHA1_HASH_SIZE], md[SHA1_HASH_SIZE];
|
||||
const uint8_t *message, *attrs;
|
||||
unsigned int dsize, message_size, attrs_size;
|
||||
cli_crt_hashtype hashtype;
|
||||
SHA1Context ctx;
|
||||
|
||||
@@ -176,7 +176,7 @@ static uint32_t getbits(struct UNP *UNP, uint32_t size) {
|
||||
*********************/
|
||||
|
||||
|
||||
static int ea05(cli_ctx *ctx, uint8_t *base, char *tmpd) {
|
||||
static int ea05(cli_ctx *ctx, const uint8_t *base, char *tmpd) {
|
||||
uint8_t b[300], comp;
|
||||
uint32_t s, m4sum=0;
|
||||
int i, ret;
|
||||
@@ -480,7 +480,7 @@ static void LAME_decrypt (uint8_t *cypher, uint32_t size, uint16_t seed) {
|
||||
autoit3 EA06 handler
|
||||
*********************/
|
||||
|
||||
static int ea06(cli_ctx *ctx, uint8_t *base, char *tmpd) {
|
||||
static int ea06(cli_ctx *ctx, const uint8_t *base, char *tmpd) {
|
||||
uint8_t b[600], comp, script, *buf;
|
||||
uint32_t s;
|
||||
int i, ret;
|
||||
@@ -916,7 +916,7 @@ static int ea06(cli_ctx *ctx, uint8_t *base, char *tmpd) {
|
||||
*********************/
|
||||
|
||||
int cli_scanautoit(cli_ctx *ctx, off_t offset) {
|
||||
uint8_t *version;
|
||||
const uint8_t *version;
|
||||
int r;
|
||||
char *tmpd;
|
||||
fmap_t *map = *ctx->fmap;
|
||||
|
||||
@@ -48,7 +48,8 @@ static const uint8_t hqxtbl[] = {
|
||||
|
||||
int cli_binhex(cli_ctx *ctx) {
|
||||
fmap_t *map = *ctx->fmap;
|
||||
uint8_t *encoded, decoded[BUFSIZ], spare_bits, last_byte=0, this_byte, offset=0;
|
||||
const uint8_t *encoded;
|
||||
uint8_t decoded[BUFSIZ], spare_bits, last_byte=0, this_byte, offset=0;
|
||||
size_t enc_done=0, enc_todo=map->len;
|
||||
unsigned int dec_done=0, chunksz = 0, chunkoff=0;
|
||||
uint32_t datalen, reslen;
|
||||
|
||||
@@ -534,7 +534,7 @@ int32_t cli_bcapi_extract_new(struct cli_bc_ctx *ctx, int32_t id)
|
||||
int32_t cli_bcapi_read_number(struct cli_bc_ctx *ctx, uint32_t radix)
|
||||
{
|
||||
unsigned i;
|
||||
char *p;
|
||||
const char *p;
|
||||
int32_t result;
|
||||
|
||||
if ((radix != 10 && radix != 16) || !ctx->fmap)
|
||||
@@ -705,7 +705,7 @@ uint32_t cli_bcapi_buffer_pipe_read_avail(struct cli_bc_ctx *ctx , int32_t id)
|
||||
return ctx->file_size - b->read_cursor;
|
||||
}
|
||||
|
||||
uint8_t* cli_bcapi_buffer_pipe_read_get(struct cli_bc_ctx *ctx , int32_t id, uint32_t size)
|
||||
const uint8_t* cli_bcapi_buffer_pipe_read_get(struct cli_bc_ctx *ctx , int32_t id, uint32_t size)
|
||||
{
|
||||
struct bc_buffer *b = get_buffer(ctx, id);
|
||||
if (!b || size > cli_bcapi_buffer_pipe_read_avail(ctx, id) || !size)
|
||||
@@ -843,7 +843,7 @@ int32_t cli_bcapi_inflate_process(struct cli_bc_ctx *ctx , int32_t id)
|
||||
b->stream.avail_in = avail_in_orig =
|
||||
cli_bcapi_buffer_pipe_read_avail(ctx, b->from);
|
||||
|
||||
b->stream.next_in = cli_bcapi_buffer_pipe_read_get(ctx, b->from,
|
||||
b->stream.next_in = (void*)cli_bcapi_buffer_pipe_read_get(ctx, b->from,
|
||||
b->stream.avail_in);
|
||||
|
||||
b->stream.avail_out = avail_out_orig =
|
||||
@@ -959,7 +959,7 @@ static struct bc_jsnorm *get_jsnorm(struct cli_bc_ctx *ctx, int32_t id)
|
||||
int32_t cli_bcapi_jsnorm_process(struct cli_bc_ctx *ctx, int32_t id)
|
||||
{
|
||||
unsigned avail;
|
||||
unsigned char *in;
|
||||
const unsigned char *in;
|
||||
cli_ctx *cctx = ctx->ctx;
|
||||
struct bc_jsnorm *b = get_jsnorm(ctx, id);
|
||||
if (!b || b->from == -1 || !b->state)
|
||||
@@ -1448,7 +1448,7 @@ uint32_t cli_bcapi_pdf_getobjsize(struct cli_bc_ctx *ctx , int32_t objidx)
|
||||
return ctx->pdf_objs[objidx+1].start - ctx->pdf_objs[objidx].start - 4;
|
||||
}
|
||||
|
||||
uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t objidx, uint32_t amount)
|
||||
const uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t objidx, uint32_t amount)
|
||||
{
|
||||
uint32_t size = cli_bcapi_pdf_getobjsize(ctx, objidx);
|
||||
if (amount > size)
|
||||
|
||||
@@ -65,7 +65,7 @@ int32_t cli_bcapi_hashset_empty(struct cli_bc_ctx *ctx , int32_t);
|
||||
int32_t cli_bcapi_buffer_pipe_new(struct cli_bc_ctx *ctx , uint32_t);
|
||||
int32_t cli_bcapi_buffer_pipe_new_fromfile(struct cli_bc_ctx *ctx , uint32_t);
|
||||
uint32_t cli_bcapi_buffer_pipe_read_avail(struct cli_bc_ctx *ctx , int32_t);
|
||||
uint8_t* cli_bcapi_buffer_pipe_read_get(struct cli_bc_ctx *ctx , int32_t, uint32_t);
|
||||
const uint8_t* cli_bcapi_buffer_pipe_read_get(struct cli_bc_ctx *ctx , int32_t, uint32_t);
|
||||
int32_t cli_bcapi_buffer_pipe_read_stopped(struct cli_bc_ctx *ctx , int32_t, uint32_t);
|
||||
uint32_t cli_bcapi_buffer_pipe_write_avail(struct cli_bc_ctx *ctx , int32_t);
|
||||
uint8_t* cli_bcapi_buffer_pipe_write_get(struct cli_bc_ctx *ctx , int32_t, uint32_t);
|
||||
@@ -114,7 +114,7 @@ int32_t cli_bcapi_pdf_get_flags(struct cli_bc_ctx *ctx );
|
||||
int32_t cli_bcapi_pdf_set_flags(struct cli_bc_ctx *ctx , int32_t);
|
||||
int32_t cli_bcapi_pdf_lookupobj(struct cli_bc_ctx *ctx , uint32_t);
|
||||
uint32_t cli_bcapi_pdf_getobjsize(struct cli_bc_ctx *ctx , int32_t);
|
||||
uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t, uint32_t);
|
||||
const uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t, uint32_t);
|
||||
int32_t cli_bcapi_pdf_getobjid(struct cli_bc_ctx *ctx , int32_t);
|
||||
int32_t cli_bcapi_pdf_getobjflags(struct cli_bc_ctx *ctx , int32_t);
|
||||
int32_t cli_bcapi_pdf_setobjflags(struct cli_bc_ctx *ctx , int32_t, int32_t);
|
||||
|
||||
@@ -63,7 +63,7 @@ int32_t cli_bcapi_hashset_empty(struct cli_bc_ctx *ctx , int32_t);
|
||||
int32_t cli_bcapi_buffer_pipe_new(struct cli_bc_ctx *ctx , uint32_t);
|
||||
int32_t cli_bcapi_buffer_pipe_new_fromfile(struct cli_bc_ctx *ctx , uint32_t);
|
||||
uint32_t cli_bcapi_buffer_pipe_read_avail(struct cli_bc_ctx *ctx , int32_t);
|
||||
uint8_t* cli_bcapi_buffer_pipe_read_get(struct cli_bc_ctx *ctx , int32_t, uint32_t);
|
||||
const uint8_t* cli_bcapi_buffer_pipe_read_get(struct cli_bc_ctx *ctx , int32_t, uint32_t);
|
||||
int32_t cli_bcapi_buffer_pipe_read_stopped(struct cli_bc_ctx *ctx , int32_t, uint32_t);
|
||||
uint32_t cli_bcapi_buffer_pipe_write_avail(struct cli_bc_ctx *ctx , int32_t);
|
||||
uint8_t* cli_bcapi_buffer_pipe_write_get(struct cli_bc_ctx *ctx , int32_t, uint32_t);
|
||||
@@ -112,7 +112,7 @@ int32_t cli_bcapi_pdf_get_flags(struct cli_bc_ctx *ctx );
|
||||
int32_t cli_bcapi_pdf_set_flags(struct cli_bc_ctx *ctx , int32_t);
|
||||
int32_t cli_bcapi_pdf_lookupobj(struct cli_bc_ctx *ctx , uint32_t);
|
||||
uint32_t cli_bcapi_pdf_getobjsize(struct cli_bc_ctx *ctx , int32_t);
|
||||
uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t, uint32_t);
|
||||
const uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t, uint32_t);
|
||||
int32_t cli_bcapi_pdf_getobjid(struct cli_bc_ctx *ctx , int32_t);
|
||||
int32_t cli_bcapi_pdf_getobjflags(struct cli_bc_ctx *ctx , int32_t);
|
||||
int32_t cli_bcapi_pdf_setobjflags(struct cli_bc_ctx *ctx , int32_t, int32_t);
|
||||
|
||||
@@ -95,7 +95,8 @@ struct cab_block_hdr
|
||||
static char *cab_readstr(fmap_t *map, off_t *offset, int *ret)
|
||||
{
|
||||
int i;
|
||||
char *str, *retstr;
|
||||
const char *str;
|
||||
char *retstr;
|
||||
|
||||
if(!(str = fmap_need_offstr(map, *offset, 256))) {
|
||||
*ret = CL_EFORMAT;
|
||||
@@ -181,8 +182,8 @@ int cab_open(fmap_t *map, off_t offset, struct cab_archive *cab)
|
||||
unsigned int i, folders = 0;
|
||||
struct cab_file *file, *lfile = NULL;
|
||||
struct cab_folder *folder, *lfolder = NULL;
|
||||
struct cab_hdr *hdr;
|
||||
struct cab_hdr_opt *hdr_opt;
|
||||
const struct cab_hdr *hdr;
|
||||
const struct cab_hdr_opt *hdr_opt;
|
||||
uint16_t fidx;
|
||||
uint32_t coffFiles;
|
||||
char *pt;
|
||||
@@ -305,7 +306,7 @@ int cab_open(fmap_t *map, off_t offset, struct cab_archive *cab)
|
||||
|
||||
/* folders */
|
||||
for(i = 0; i < cab->nfolders; i++) {
|
||||
struct cab_folder_hdr *folder_hdr;
|
||||
const struct cab_folder_hdr *folder_hdr;
|
||||
|
||||
if(!(folder_hdr = fmap_need_off_once(map, cur_offset, sizeof(*folder_hdr)))) {
|
||||
cli_dbgmsg("cab_open: Can't read header for folder %u\n", i);
|
||||
@@ -360,7 +361,7 @@ int cab_open(fmap_t *map, off_t offset, struct cab_archive *cab)
|
||||
cur_offset = coffFiles;
|
||||
}
|
||||
for(i = 0; i < cab->nfiles; i++) {
|
||||
struct cab_file_hdr *file_hdr;
|
||||
const struct cab_file_hdr *file_hdr;
|
||||
|
||||
if(!(file_hdr = fmap_need_off_once(map, cur_offset, sizeof(*file_hdr)))) {
|
||||
cli_dbgmsg("cab_open: Can't read file %u header\n", i);
|
||||
@@ -379,8 +380,8 @@ int cab_open(fmap_t *map, off_t offset, struct cab_archive *cab)
|
||||
cab->map = map;
|
||||
file->offset = EC32(file_hdr->uoffFolderStart);
|
||||
file->length = EC32(file_hdr->cbFile);
|
||||
file->attribs = EC32(file_hdr->attribs);
|
||||
fidx = EC32(file_hdr->iFolder);
|
||||
file->attribs = EC16(file_hdr->attribs);
|
||||
fidx = EC16(file_hdr->iFolder);
|
||||
file->error = CL_SUCCESS;
|
||||
|
||||
file->name = cab_readstr(map, &cur_offset, &ret);
|
||||
@@ -449,7 +450,7 @@ int cab_open(fmap_t *map, off_t offset, struct cab_archive *cab)
|
||||
|
||||
static int cab_read_block(struct cab_file *file)
|
||||
{
|
||||
struct cab_block_hdr *block_hdr;
|
||||
const struct cab_block_hdr *block_hdr;
|
||||
struct cab_state *state = file->cab->state;
|
||||
|
||||
if(!(block_hdr = fmap_need_off_once(file->cab->map, file->cab->cur_offset, sizeof(*block_hdr)))) {
|
||||
|
||||
@@ -703,7 +703,7 @@ int cache_check(unsigned char *hash, cli_ctx *ctx) {
|
||||
|
||||
cli_md5_init(&md5);
|
||||
while(todo) {
|
||||
void *buf;
|
||||
const void *buf;
|
||||
size_t readme = todo < FILEBUFF ? todo : FILEBUFF;
|
||||
if(!(buf = fmap_need_off_once(map, at, readme)))
|
||||
return CL_VIRUS;
|
||||
|
||||
@@ -105,7 +105,7 @@ typedef struct lzx_content_tag {
|
||||
/* Read in a block of data from either the mmap area or the given fd */
|
||||
static int chm_read_data(fmap_t *map, char *dest, off_t offset, off_t len)
|
||||
{
|
||||
void *src = fmap_need_off_once(map, offset, len);
|
||||
const void *src = fmap_need_off_once(map, offset, len);
|
||||
if(!src) return FALSE;
|
||||
memcpy(dest, src, len);
|
||||
return TRUE;
|
||||
@@ -233,10 +233,10 @@ static int itsp_read_header(chm_metadata_t *metadata, off_t offset)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static uint64_t read_enc_int(char **start, char *end)
|
||||
static uint64_t read_enc_int(const char **start, const char *end)
|
||||
{
|
||||
uint64_t retval=0;
|
||||
char *current;
|
||||
const char *current;
|
||||
|
||||
current = *start;
|
||||
|
||||
@@ -258,7 +258,7 @@ static uint64_t read_enc_int(char **start, char *end)
|
||||
/* Read control entries */
|
||||
static int read_control_entries(chm_metadata_t *metadata)
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
uint64_t name_len, section, offset, length;
|
||||
|
||||
while (metadata->chunk_entries--) {
|
||||
|
||||
@@ -108,9 +108,9 @@ typedef struct chm_metadata_tag {
|
||||
int ofd;
|
||||
uint32_t num_chunks;
|
||||
off_t chunk_offset;
|
||||
char *chunk_data;
|
||||
char *chunk_current;
|
||||
char *chunk_end;
|
||||
const char *chunk_data;
|
||||
const char *chunk_current;
|
||||
const char *chunk_end;
|
||||
fmap_t *map;
|
||||
uint16_t chunk_entries;
|
||||
} chm_metadata_t;
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#include "crtmgr.h"
|
||||
#include "others.h"
|
||||
|
||||
/* TODO split certs into verified and tbs */
|
||||
|
||||
int cli_crt_init(cli_crt *x509) {
|
||||
int ret;
|
||||
if((ret = mp_init_multi(&x509->n, &x509->e, &x509->sig, NULL))) {
|
||||
|
||||
@@ -155,11 +155,12 @@ cli_file_t cli_filetype(const unsigned char *buf, size_t buflen, const struct cl
|
||||
return cli_texttype(buf, buflen);
|
||||
}
|
||||
|
||||
int is_tar(unsigned char *buf, unsigned int nbytes);
|
||||
int is_tar(const unsigned char *buf, unsigned int nbytes);
|
||||
|
||||
cli_file_t cli_filetype2(fmap_t *map, const struct cl_engine *engine)
|
||||
{
|
||||
unsigned char *buff, *decoded;
|
||||
const unsigned char *buff;
|
||||
unsigned char *decoded;
|
||||
int bread = MIN(map->len, MAGIC_BUFFER_SIZE), sret;
|
||||
cli_file_t ret = CL_TYPE_BINARY_DATA;
|
||||
struct cli_matcher *root;
|
||||
|
||||
@@ -107,12 +107,12 @@ static inline size_t fmap_ptr2off(const fmap_t *m, const void *ptr)
|
||||
:(const char*)ptr - (const char*)m - m->hdrsz;
|
||||
}
|
||||
|
||||
static inline const void *fmap_need_ptr(fmap_t *m, void *ptr, size_t len)
|
||||
static inline const void *fmap_need_ptr(fmap_t *m, const void *ptr, size_t len)
|
||||
{
|
||||
return m->need(m, fmap_ptr2off(m, ptr), len, 1);
|
||||
}
|
||||
|
||||
static inline const void *fmap_need_ptr_once(fmap_t *m, void *ptr, size_t len)
|
||||
static inline const void *fmap_need_ptr_once(fmap_t *m, const void *ptr, size_t len)
|
||||
{
|
||||
return m->need(m, fmap_ptr2off(m, ptr), len, 0);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ static inline void fmap_unneed_off(fmap_t *m, size_t at, size_t len)
|
||||
m->unneed_off(m, at, len);
|
||||
}
|
||||
|
||||
static inline void fmap_unneed_ptr(fmap_t *m, void *ptr, size_t len)
|
||||
static inline void fmap_unneed_ptr(fmap_t *m, const void *ptr, size_t len)
|
||||
{
|
||||
fmap_unneed_off(m, fmap_ptr2off(m, ptr), len);
|
||||
}
|
||||
@@ -144,7 +144,7 @@ static inline int fmap_readn(fmap_t *m, void *dst, size_t at, size_t len)
|
||||
return len;
|
||||
}
|
||||
|
||||
static inline const void *fmap_need_str(fmap_t *m, void *ptr, size_t len_hint)
|
||||
static inline const void *fmap_need_str(fmap_t *m, const void *ptr, size_t len_hint)
|
||||
{
|
||||
return m->need_offstr(m, fmap_ptr2off(m, ptr), len_hint);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "packlibs.h"
|
||||
#include "fsg.h"
|
||||
|
||||
int unfsg_200(char *source, char *dest, int ssize, int dsize, uint32_t rva, uint32_t base, uint32_t ep, int file) {
|
||||
int unfsg_200(const char *source, char *dest, int ssize, int dsize, uint32_t rva, uint32_t base, uint32_t ep, int file) {
|
||||
struct cli_exe_section section; /* Yup, just one ;) */
|
||||
|
||||
if ( cli_unfsg(source, dest, ssize, dsize, NULL, NULL) ) return -1;
|
||||
@@ -64,8 +64,9 @@ int unfsg_200(char *source, char *dest, int ssize, int dsize, uint32_t rva, uint
|
||||
}
|
||||
|
||||
|
||||
int unfsg_133(char *source, char *dest, int ssize, int dsize, struct cli_exe_section *sections, int sectcount, uint32_t base, uint32_t ep, int file) {
|
||||
char *tsrc=source, *tdst=dest;
|
||||
int unfsg_133(const char *source, char *dest, int ssize, int dsize, struct cli_exe_section *sections, int sectcount, uint32_t base, uint32_t ep, int file) {
|
||||
const char *tsrc=source;
|
||||
char *tdst=dest;
|
||||
int i, upd=1, offs=0, lastsz=dsize;
|
||||
|
||||
for (i = 0 ; i <= sectcount ; i++) {
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#include "cltypes.h"
|
||||
#include "execs.h"
|
||||
|
||||
int unfsg_200(char *, char *, int, int, uint32_t, uint32_t, uint32_t, int);
|
||||
int unfsg_133(char *, char *, int , int, struct cli_exe_section *, int, uint32_t, uint32_t, int);
|
||||
int unfsg_200(const char *, char *, int, int, uint32_t, uint32_t, uint32_t, int);
|
||||
int unfsg_133(const char *, char *, int , int, struct cli_exe_section *, int, uint32_t, uint32_t, int);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ static int from_oct(int digs, char *where);
|
||||
* 1 for old UNIX tar file,
|
||||
* 2 for Unix Std (POSIX) tar file.
|
||||
*/
|
||||
int is_tar(unsigned char *buf, unsigned int nbytes)
|
||||
int is_tar(const unsigned char *buf, unsigned int nbytes)
|
||||
{
|
||||
union record *header = (union record *)buf;
|
||||
int i;
|
||||
|
||||
@@ -44,4 +44,4 @@ union record {
|
||||
/* The magic field is filled with this if uname and gname are valid. */
|
||||
#define TMAGIC "ustar " /* 7 chars and a null */
|
||||
|
||||
int is_tar(unsigned char *buf, unsigned int nbytes);
|
||||
int is_tar(const unsigned char *buf, unsigned int nbytes);
|
||||
|
||||
@@ -193,7 +193,7 @@ static const uint8_t skey[] = { 0xec, 0xca, 0x79, 0xf8 }; /* ~0x13, ~0x35, ~0x86
|
||||
|
||||
/* Extracts the content of MSI based IS */
|
||||
int cli_scanishield_msi(cli_ctx *ctx, off_t off) {
|
||||
uint8_t *buf;
|
||||
const uint8_t *buf;
|
||||
unsigned int fcount, scanned = 0;
|
||||
int ret;
|
||||
fmap_t *map = *ctx->fmap;
|
||||
@@ -337,7 +337,8 @@ static int is_extract_cab(cli_ctx *ctx, uint64_t off, uint64_t size, uint64_t cs
|
||||
|
||||
/* Extract the content of older (non-MSI) IS */
|
||||
int cli_scanishield(cli_ctx *ctx, off_t off, size_t sz) {
|
||||
char *fname, *path, *version, *strsz, *eostr, *data;
|
||||
const char *fname, *path, *version, *strsz, *data;
|
||||
char *eostr;
|
||||
int ret = CL_CLEAN;
|
||||
long fsize;
|
||||
off_t coff = off;
|
||||
@@ -436,7 +437,8 @@ int cli_scanishield(cli_ctx *ctx, off_t off, size_t sz) {
|
||||
|
||||
/* Utility func to scan a fd @ a given offset and size */
|
||||
static int is_dump_and_scan(cli_ctx *ctx, off_t off, size_t fsize) {
|
||||
char *fname, *buf;
|
||||
char *fname;
|
||||
const char *buf;
|
||||
int ofd, ret = CL_CLEAN;
|
||||
fmap_t *map = *ctx->fmap;
|
||||
|
||||
@@ -486,7 +488,7 @@ static int is_parse_hdr(cli_ctx *ctx, struct IS_CABSTUFF *c) {
|
||||
char hash[33], *hdr;
|
||||
fmap_t *map = *ctx->fmap;
|
||||
|
||||
struct IS_HDR *h1;
|
||||
const struct IS_HDR *h1;
|
||||
struct IS_OBJECTS *objs;
|
||||
/* struct IS_INSTTYPEHDR *typehdr; -- UNUSED */
|
||||
|
||||
@@ -675,7 +677,8 @@ static void md5str(uint8_t *sum) {
|
||||
#define IS_CABBUFSZ 65536
|
||||
|
||||
static int is_extract_cab(cli_ctx *ctx, uint64_t off, uint64_t size, uint64_t csize) {
|
||||
uint8_t *inbuf, *outbuf;
|
||||
const uint8_t *inbuf;
|
||||
uint8_t *outbuf;
|
||||
char *tempfile;
|
||||
int ofd, ret = CL_CLEAN;
|
||||
z_stream z;
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef struct {
|
||||
} iso9660_t;
|
||||
|
||||
|
||||
static void *needblock(const iso9660_t *iso, unsigned int block, int temp) {
|
||||
static const void *needblock(const iso9660_t *iso, unsigned int block, int temp) {
|
||||
cli_ctx *ctx = iso->ctx;
|
||||
size_t loff;
|
||||
unsigned int blocks_per_sect = (2048 / iso->blocksz);
|
||||
@@ -59,7 +59,7 @@ static int iso_scan_file(const iso9660_t *iso, unsigned int block, unsigned int
|
||||
|
||||
cli_dbgmsg("iso_scan_file: dumping to %s\n", tmpf);
|
||||
while(len) {
|
||||
void *buf = needblock(iso, block, 1);
|
||||
const void *buf = needblock(iso, block, 1);
|
||||
unsigned int todo = MIN(len, iso->blocksz);
|
||||
if(cli_writen(fd, buf, todo) != todo) {
|
||||
close(fd);
|
||||
@@ -88,7 +88,7 @@ static int iso_scan_file(const iso9660_t *iso, unsigned int block, unsigned int
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *iso_string(iso9660_t *iso, void *src, unsigned int len) {
|
||||
static char *iso_string(iso9660_t *iso, const void *src, unsigned int len) {
|
||||
if(iso->joliet) {
|
||||
char *utf8;
|
||||
if(len > sizeof(iso->buf))
|
||||
@@ -120,7 +120,7 @@ static int iso_parse_dir(iso9660_t *iso, unsigned int block, unsigned int len) {
|
||||
}
|
||||
|
||||
for(; len && ret == CL_CLEAN; block++, len -= MIN(len, iso->blocksz)) {
|
||||
uint8_t *dir, *dir_orig;
|
||||
const uint8_t *dir, *dir_orig;
|
||||
unsigned int dirsz;
|
||||
|
||||
if(iso->dir_blocks.count > 1024) {
|
||||
@@ -205,7 +205,7 @@ static int iso_parse_dir(iso9660_t *iso, unsigned int block, unsigned int len) {
|
||||
}
|
||||
|
||||
int cli_scaniso(cli_ctx *ctx, size_t offset) {
|
||||
uint8_t *privol, *next;
|
||||
const uint8_t *privol, *next;
|
||||
iso9660_t iso;
|
||||
int i;
|
||||
|
||||
|
||||
@@ -396,7 +396,7 @@ int cli_checkfp(unsigned char *digest, size_t size, cli_ctx *ctx)
|
||||
SHA1Context sha1;
|
||||
SHA256_CTX sha256;
|
||||
fmap_t *map;
|
||||
char *ptr;
|
||||
const char *ptr;
|
||||
uint8_t shash1[SHA1_HASH_SIZE*2+1];
|
||||
uint8_t shash256[SHA256_HASH_SIZE*2+1];
|
||||
int have_sha1, have_sha256;
|
||||
@@ -610,7 +610,7 @@ int cli_lsig_eval(cli_ctx *ctx, struct cli_matcher *root, struct cli_ac_data *ac
|
||||
|
||||
int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli_matched_type **ftoffset, unsigned int acmode, struct cli_ac_result **acres, unsigned char *refhash)
|
||||
{
|
||||
unsigned char *buff;
|
||||
const unsigned char *buff;
|
||||
int ret = CL_CLEAN, type = CL_CLEAN, bytes, compute_hash[CLI_HASH_AVAIL_TYPES];
|
||||
unsigned int i = 0, bm_offmode = 0;
|
||||
uint32_t maxpatlen, offset = 0;
|
||||
@@ -760,7 +760,7 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli
|
||||
}
|
||||
|
||||
if(hdb) {
|
||||
void *data = buff + maxpatlen * (offset!=0);
|
||||
const void *data = buff + maxpatlen * (offset!=0);
|
||||
uint32_t data_len = bytes - maxpatlen * (offset!=0);
|
||||
|
||||
if(compute_hash[CLI_HASH_MD5])
|
||||
|
||||
@@ -656,7 +656,7 @@ parseEmailFile(fmap_t *map, size_t *at, const table_t *rfc821, const char *first
|
||||
bodyIsEmpty = TRUE;
|
||||
} else {
|
||||
char *ptr;
|
||||
char *lookahead;
|
||||
const char *lookahead;
|
||||
|
||||
if(fullline == NULL) {
|
||||
char cmd[RFC2821LENGTH + 1], out[RFC2821LENGTH + 1];
|
||||
@@ -3212,7 +3212,8 @@ usefulHeader(int commandNumber, const char *cmd)
|
||||
static char *
|
||||
getline_from_mbox(char *buffer, size_t buffer_len, fmap_t *map, size_t *at)
|
||||
{
|
||||
char *src, *cursrc, *curbuf;
|
||||
const char *src, *cursrc;
|
||||
char *curbuf;
|
||||
size_t i;
|
||||
size_t input_len = MIN(map->len - *at, buffer_len + 1);
|
||||
src = cursrc = fmap_need_off_once(map, *at, input_len);
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
/* northfox does this shitty way,
|
||||
* this should be done with just a bswap
|
||||
*/
|
||||
static char *lzma_bswap_4861dc(struct lzmastate *p, char *old_edx)
|
||||
static const char *lzma_bswap_4861dc(struct lzmastate *p, const char *old_edx)
|
||||
{
|
||||
/* dumb_dump_start
|
||||
*
|
||||
@@ -99,7 +99,7 @@ static char *lzma_bswap_4861dc(struct lzmastate *p, char *old_edx)
|
||||
return p->p0;
|
||||
}
|
||||
|
||||
static uint32_t lzma_486248 (struct lzmastate *p, char **old_ecx, char *src, uint32_t size)
|
||||
static uint32_t lzma_486248 (struct lzmastate *p,const char **old_ecx, char *src, uint32_t size)
|
||||
{
|
||||
uint32_t loc_esi, loc_edi, loc_eax, loc_ecx, ret;
|
||||
if (!CLI_ISCONTAINED(src, size, *old_ecx, 4) || !CLI_ISCONTAINED(src, size, p->p0, 1))
|
||||
@@ -152,11 +152,11 @@ static uint32_t lzma_486248 (struct lzmastate *p, char **old_ecx, char *src, uin
|
||||
|
||||
}
|
||||
|
||||
static uint32_t lzma_48635C(uint8_t znaczek, char **old_ecx, struct lzmastate *p, uint32_t *retval, char *src, uint32_t size)
|
||||
static uint32_t lzma_48635C(uint8_t znaczek, const char **old_ecx, struct lzmastate *p, uint32_t *retval, char *src, uint32_t size)
|
||||
{
|
||||
uint32_t loc_esi = (znaczek&0xff) >> 7, /* msb */
|
||||
loc_ebx, ret;
|
||||
char *loc_edi;
|
||||
const char *loc_edi;
|
||||
znaczek <<= 1;
|
||||
ret = loc_esi << 9;
|
||||
loc_edi = *old_ecx;
|
||||
@@ -196,10 +196,10 @@ static uint32_t lzma_48635C(uint8_t znaczek, char **old_ecx, struct lzmastate *p
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t lzma_4862e0 (struct lzmastate *p, char **old_ecx, uint32_t *old_edx, uint32_t *retval, char *src, uint32_t size)
|
||||
static uint32_t lzma_4862e0 (struct lzmastate *p, const char **old_ecx, uint32_t *old_edx, uint32_t *retval, char *src, uint32_t size)
|
||||
{
|
||||
uint32_t loc_ebx, loc_esi, stack_ecx, ret;
|
||||
char *loc_edi;
|
||||
const char *loc_edi;
|
||||
|
||||
loc_ebx = *old_edx;
|
||||
ret = 1;
|
||||
@@ -229,10 +229,10 @@ static uint32_t lzma_4862e0 (struct lzmastate *p, char **old_ecx, uint32_t *old_
|
||||
}
|
||||
|
||||
/* old_edx - write only */
|
||||
static uint32_t lzma_4863da (uint32_t var0, struct lzmastate *p, char **old_ecx, uint32_t *old_edx, uint32_t *retval, char *src, uint32_t size)
|
||||
static uint32_t lzma_4863da (uint32_t var0, struct lzmastate *p, const char **old_ecx, uint32_t *old_edx, uint32_t *retval, char *src, uint32_t size)
|
||||
{
|
||||
uint32_t ret;
|
||||
char *loc_esi = *old_ecx;
|
||||
const char *loc_esi = *old_ecx;
|
||||
|
||||
if ((ret = lzma_486248 (p, old_ecx, src, size)) == 0xffffffff)
|
||||
return -1;
|
||||
@@ -274,7 +274,7 @@ static uint32_t lzma_4863da (uint32_t var0, struct lzmastate *p, char **old_ecx
|
||||
static uint32_t lzma_486204 (struct lzmastate *p, uint32_t old_edx, uint32_t *retval, char *src, uint32_t size)
|
||||
{
|
||||
uint32_t loc_esi, loc_edi, loc_ebx, loc_eax;
|
||||
char *loc_edx;
|
||||
const char *loc_edx;
|
||||
loc_esi = p->p1;
|
||||
loc_edi = p->p2;
|
||||
loc_eax = 0;
|
||||
@@ -311,11 +311,11 @@ static uint32_t lzma_486204 (struct lzmastate *p, uint32_t old_edx, uint32_t *re
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t lzma_48631a (struct lzmastate *p, char **old_ecx, uint32_t *old_edx, uint32_t *retval, char *src, uint32_t size)
|
||||
static uint32_t lzma_48631a (struct lzmastate *p, const char **old_ecx, uint32_t *old_edx, uint32_t *retval, char *src, uint32_t size)
|
||||
{
|
||||
uint32_t copy1, copy2;
|
||||
uint32_t loc_esi, loc_edi, ret;
|
||||
char *loc_ebx;
|
||||
const char *loc_ebx;
|
||||
|
||||
copy1 = *old_edx;
|
||||
loc_edi = 0;
|
||||
@@ -347,7 +347,7 @@ static uint32_t lzma_48631a (struct lzmastate *p, char **old_ecx, uint32_t *old_
|
||||
}
|
||||
|
||||
|
||||
int mew_lzma(char *orgsource, char *buf, uint32_t size_sum, uint32_t vma, uint32_t special)
|
||||
int mew_lzma(char *orgsource, const char *buf, uint32_t size_sum, uint32_t vma, uint32_t special)
|
||||
{
|
||||
uint32_t var08, var0C, var10, var14, var20, var24, var28, var34;
|
||||
struct lzmastate var40;
|
||||
@@ -355,8 +355,12 @@ int mew_lzma(char *orgsource, char *buf, uint32_t size_sum, uint32_t vma, uint32
|
||||
int i, mainloop;
|
||||
|
||||
char var1, var30;
|
||||
char *source = buf, *dest, *new_ebx, *new_ecx, *var0C_ecxcopy, *var2C;
|
||||
char *pushed_esi = NULL, *pushed_ebx = NULL;
|
||||
const char *source = buf;
|
||||
char *dest, *new_ebx;
|
||||
const char *new_ecx, *var0C_ecxcopy;
|
||||
const char *var2C;
|
||||
char *pushed_esi = NULL;
|
||||
const char *pushed_ebx = NULL;
|
||||
uint32_t pushed_edx=0;
|
||||
|
||||
uint32_t loc_esi, loc_edi;
|
||||
@@ -774,8 +778,10 @@ int unmew11(char *src, int off, int ssize, int dsize, uint32_t base, uint32_t va
|
||||
{
|
||||
uint32_t entry_point, newedi, loc_ds=dsize, loc_ss=ssize;
|
||||
char *source = src + dsize + off;
|
||||
char *lesi = source + 12, *ledi;
|
||||
char *f1, *f2;
|
||||
const char *lesi = source + 12;
|
||||
char *ledi;
|
||||
const char *f1;
|
||||
char *f2;
|
||||
int i;
|
||||
struct cli_exe_section *section = NULL;
|
||||
uint32_t vma = base + vadd, size_sum = ssize + dsize;
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
#include "cltypes.h"
|
||||
|
||||
struct lzmastate {
|
||||
char *p0;
|
||||
const char *p0;
|
||||
uint32_t p1, p2;
|
||||
};
|
||||
|
||||
int mew_lzma(char *, char *, uint32_t, uint32_t, uint32_t);
|
||||
int mew_lzma(char *, const char *, uint32_t, uint32_t, uint32_t);
|
||||
|
||||
uint32_t lzma_upack_esi_00(struct lzmastate *, char *, char *, uint32_t);
|
||||
uint32_t lzma_upack_esi_50(struct lzmastate *, uint32_t, uint32_t, char **, char *, uint32_t *, char *, uint32_t);
|
||||
|
||||
@@ -94,7 +94,7 @@ struct msexp_hdr {
|
||||
|
||||
int cli_msexpand(cli_ctx *ctx, int ofd)
|
||||
{
|
||||
struct msexp_hdr *hdr;
|
||||
const struct msexp_hdr *hdr;
|
||||
uint8_t i, mask, bits;
|
||||
unsigned char buff[B_SIZE], wbuff[RW_SIZE];
|
||||
const unsigned char *rbuff;
|
||||
|
||||
@@ -70,7 +70,7 @@ struct nsis_st {
|
||||
struct CLI_LZMA lz;
|
||||
/* z_stream z; */
|
||||
nsis_z_stream z;
|
||||
unsigned char *freeme;
|
||||
const unsigned char *freeme;
|
||||
fmap_t *map;
|
||||
char ofn[1024];
|
||||
};
|
||||
@@ -183,7 +183,7 @@ static int nsis_decomp(struct nsis_st *n) {
|
||||
}
|
||||
|
||||
static int nsis_unpack_next(struct nsis_st *n, cli_ctx *ctx) {
|
||||
unsigned char *ibuf;
|
||||
const unsigned char *ibuf;
|
||||
uint32_t size, loops;
|
||||
int ret, gotsome=0;
|
||||
unsigned char obuf[BUFSIZ];
|
||||
@@ -258,7 +258,7 @@ static int nsis_unpack_next(struct nsis_st *n, cli_ctx *ctx) {
|
||||
}
|
||||
|
||||
n->nsis.avail_in = size;
|
||||
n->nsis.next_in = ibuf;
|
||||
n->nsis.next_in = (void*)ibuf;
|
||||
n->nsis.next_out = obuf;
|
||||
n->nsis.avail_out = BUFSIZ;
|
||||
loops=0;
|
||||
@@ -325,7 +325,7 @@ static int nsis_unpack_next(struct nsis_st *n, cli_ctx *ctx) {
|
||||
close(n->ofd);
|
||||
return CL_EREAD;
|
||||
}
|
||||
n->nsis.next_in = n->freeme;
|
||||
n->nsis.next_in = (void*)n->freeme;
|
||||
n->nsis.avail_in = n->asz;
|
||||
}
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ static void print_ole2_header(ole2_header_t *hdr)
|
||||
static int ole2_read_block(ole2_header_t *hdr, void *buff, unsigned int size, int32_t blockno)
|
||||
{
|
||||
off_t offset, offend;
|
||||
void *pblock;
|
||||
const void *pblock;
|
||||
|
||||
if (blockno < 0) {
|
||||
return FALSE;
|
||||
@@ -872,7 +872,7 @@ int cli_ole2_extract(const char *dirname, cli_ctx *ctx, struct uniq **vba)
|
||||
int hdr_size, ret=CL_CLEAN;
|
||||
unsigned int file_count=0;
|
||||
unsigned long scansize, scansize2;
|
||||
void *phdr;
|
||||
const void *phdr;
|
||||
|
||||
cli_dbgmsg("in cli_ole2_extract()\n");
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "pe.h"
|
||||
#include "packlibs.h"
|
||||
|
||||
static int doubledl(char **scur, uint8_t *mydlptr, char *buffer, uint32_t buffersize)
|
||||
static int doubledl(const char **scur, uint8_t *mydlptr, const char *buffer, uint32_t buffersize)
|
||||
{
|
||||
unsigned char mydl = *mydlptr;
|
||||
unsigned char olddl = mydl;
|
||||
@@ -45,10 +45,11 @@ static int doubledl(char **scur, uint8_t *mydlptr, char *buffer, uint32_t buffer
|
||||
}
|
||||
|
||||
|
||||
int cli_unfsg(char *source, char *dest, int ssize, int dsize, char **endsrc, char **enddst) {
|
||||
int cli_unfsg(const char *source, char *dest, int ssize, int dsize, const char **endsrc, char **enddst) {
|
||||
uint8_t mydl=0x80;
|
||||
uint32_t backbytes, backsize, oldback = 0;
|
||||
char *csrc = source, *cdst = dest;
|
||||
const char *csrc = source;
|
||||
char *cdst = dest;
|
||||
int oob, lostbit = 1;
|
||||
|
||||
if (ssize<=0 || dsize<=0) return -1;
|
||||
@@ -170,10 +171,11 @@ int cli_unfsg(char *source, char *dest, int ssize, int dsize, char **endsrc, cha
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unmew(char *source, char *dest, int ssize, int dsize, char **endsrc, char **enddst) {
|
||||
int unmew(const char *source, char *dest, int ssize, int dsize, const char **endsrc, char **enddst) {
|
||||
uint8_t mydl=0x80;
|
||||
uint32_t myeax_backbytes, myecx_backsize, oldback = 0;
|
||||
char *csrc = source, *cdst = dest;
|
||||
const char *csrc = source;
|
||||
char *cdst = dest;
|
||||
int oob, lostbit = 1;
|
||||
|
||||
*cdst++=*csrc++;
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#include "cltypes.h"
|
||||
#include "rebuildpe.h"
|
||||
|
||||
int cli_unfsg(char *, char *, int, int, char **, char **);
|
||||
int cli_unfsg(const char *, char *, int, int, const char **, char **);
|
||||
|
||||
int unmew(char *, char *, int, int, char **, char **);
|
||||
int unmew(const char *, char *, int, int, const char **, char **);
|
||||
|
||||
#endif
|
||||
|
||||
3220
libclamav/pe.c
3220
libclamav/pe.c
File diff suppressed because it is too large
Load Diff
@@ -88,7 +88,7 @@ int cli_scanicon(icon_groupset *set, uint32_t resdir_rva, cli_ctx *ctx, struct c
|
||||
findres(14, 0xffffffff, resdir_rva, map, exe_sections, nsections, hdr_size, groupicon_cb, &gicons);
|
||||
|
||||
for(curicon=0; curicon<gicons.cnt; curicon++) {
|
||||
uint8_t *grp = fmap_need_off_once(map, cli_rawaddr(gicons.rvas[curicon], exe_sections, nsections, &err, map->len, hdr_size), 16);
|
||||
const uint8_t *grp = fmap_need_off_once(map, cli_rawaddr(gicons.rvas[curicon], exe_sections, nsections, &err, map->len, hdr_size), 16);
|
||||
if(grp && !err) {
|
||||
uint32_t gsz = cli_readint32(grp + 4);
|
||||
if(gsz>6) {
|
||||
@@ -1192,9 +1192,10 @@ static int parseicon(icon_groupset *set, uint32_t rva, cli_ctx *ctx, struct cli_
|
||||
unsigned int important;
|
||||
} bmphdr;
|
||||
struct icomtr metrics;
|
||||
unsigned char *rawimage;
|
||||
const unsigned char *rawimage;
|
||||
const char *tempd;
|
||||
uint32_t *palette = NULL, *imagedata;
|
||||
const uint32_t *palette = NULL;
|
||||
uint32_t *imagedata;
|
||||
unsigned int scanlinesz, andlinesz;
|
||||
unsigned int width, height, depth, x, y;
|
||||
unsigned int err, scalemode = 2, enginesize;
|
||||
@@ -1210,12 +1211,12 @@ static int parseicon(icon_groupset *set, uint32_t rva, cli_ctx *ctx, struct cli_
|
||||
icoff = cli_rawaddr(rva, exe_sections, nsections, &err, map->len, hdr_size);
|
||||
|
||||
/* read the bitmap header */
|
||||
if(err || !(imagedata = fmap_need_off_once(map, icoff, 4))) {
|
||||
if(err || !(rawimage = fmap_need_off_once(map, icoff, 4))) {
|
||||
cli_dbgmsg("parseicon: offset to icon is out of file\n");
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
rva = cli_readint32(imagedata);
|
||||
rva = cli_readint32(rawimage);
|
||||
icoff = cli_rawaddr(rva, exe_sections, nsections, &err, map->len, hdr_size);
|
||||
if(err || fmap_readn(map, &bmphdr, icoff, sizeof(bmphdr)) != sizeof(bmphdr)) {
|
||||
cli_dbgmsg("parseicon: bmp header is out of file\n");
|
||||
|
||||
@@ -488,7 +488,7 @@ static int cli_scangzip(cli_ctx *ctx)
|
||||
|
||||
while (at < map->len) {
|
||||
unsigned int bytes = MIN(map->len - at, map->pgsz);
|
||||
if(!(z.next_in = fmap_need_off_once(map, at, bytes))) {
|
||||
if(!(z.next_in = (void*)fmap_need_off_once(map, at, bytes))) {
|
||||
cli_dbgmsg("GZip: Can't read %u bytes @ %lu.\n", bytes, (long unsigned)at);
|
||||
inflateEnd(&z);
|
||||
close(fd);
|
||||
@@ -1050,7 +1050,7 @@ static int cli_scanhtml(cli_ctx *ctx)
|
||||
|
||||
static int cli_scanscript(cli_ctx *ctx)
|
||||
{
|
||||
unsigned char *buff;
|
||||
const unsigned char *buff;
|
||||
unsigned char* normalized;
|
||||
struct text_norm_state state;
|
||||
char *tmpname = NULL;
|
||||
@@ -1147,7 +1147,8 @@ static int cli_scanscript(cli_ctx *ctx)
|
||||
|
||||
static int cli_scanhtml_utf16(cli_ctx *ctx)
|
||||
{
|
||||
char *tempname, *decoded, *buff;
|
||||
char *tempname, *decoded;
|
||||
const char *buff;
|
||||
int ret = CL_CLEAN, fd, bytes;
|
||||
size_t at = 0;
|
||||
fmap_t *map = *ctx->fmap;
|
||||
@@ -1640,7 +1641,7 @@ static int cli_scanembpe(cli_ctx *ctx, off_t offset)
|
||||
{
|
||||
int fd, bytes, ret = CL_CLEAN;
|
||||
unsigned long int size = 0, todo;
|
||||
char *buff;
|
||||
const char *buff;
|
||||
char *tmpname;
|
||||
fmap_t *map = *ctx->fmap;
|
||||
unsigned int corrupted_input;
|
||||
@@ -2261,7 +2262,7 @@ static int magic_scandesc(cli_ctx *ctx, cli_file_t type)
|
||||
break;
|
||||
}
|
||||
do {
|
||||
char *b;
|
||||
const char *b;
|
||||
|
||||
len = 0;
|
||||
b = fmap_need_off_once_len(*ctx->fmap, pos, BUFSIZ, &len);
|
||||
|
||||
@@ -283,7 +283,7 @@ static int real_scansis(cli_ctx *ctx, const char *tmpd) {
|
||||
return CL_CLEAN;
|
||||
}
|
||||
for (i = 0; i< sis.langs; i++)
|
||||
alangs[i]=EC32(llangs[i])<MAXLANG ? sislangs[EC32(llangs[i])] : sislangs[0];
|
||||
alangs[i]=EC16(llangs[i])<MAXLANG ? sislangs[EC16(llangs[i])] : sislangs[0];
|
||||
|
||||
if (!sis.pnames) {
|
||||
cli_dbgmsg("SIS: Application without a name?\n");
|
||||
@@ -420,7 +420,7 @@ static int real_scansis(cli_ctx *ctx, const char *tmpd) {
|
||||
int fd;
|
||||
|
||||
for (j=0; j<fcount; j++) {
|
||||
void *decomp;
|
||||
void *decomp = NULL;
|
||||
const void *comp;
|
||||
const void *decompp = NULL;
|
||||
uLongf olen;
|
||||
|
||||
@@ -120,12 +120,12 @@ nsp1:00435A5A push 8000h
|
||||
|
||||
|
||||
/* real_unpack(start_of_stuff, dest, malloc, free); */
|
||||
uint32_t unspack(char *start_of_stuff, char *dest, cli_ctx *ctx, uint32_t rva, uint32_t base, uint32_t ep, int file) {
|
||||
uint32_t unspack(const char *start_of_stuff, char *dest, cli_ctx *ctx, uint32_t rva, uint32_t base, uint32_t ep, int file) {
|
||||
uint8_t c = *start_of_stuff;
|
||||
uint32_t i,firstbyte,tre,allocsz,tablesz,dsize,ssize;
|
||||
uint16_t *table;
|
||||
char *dst = dest;
|
||||
char *src = start_of_stuff+0xd;
|
||||
const char *src = start_of_stuff+0xd;
|
||||
struct cli_exe_section section;
|
||||
|
||||
if (c>=0xe1) return 1;
|
||||
@@ -170,7 +170,7 @@ uint32_t unspack(char *start_of_stuff, char *dest, cli_ctx *ctx, uint32_t rva, u
|
||||
}
|
||||
|
||||
|
||||
uint32_t very_real_unpack(uint16_t *table, uint32_t tablesz, uint32_t tre, uint32_t allocsz, uint32_t firstbyte, char *src, uint32_t ssize, char *dst, uint32_t dsize) {
|
||||
uint32_t very_real_unpack(uint16_t *table, uint32_t tablesz, uint32_t tre, uint32_t allocsz, uint32_t firstbyte, const char *src, uint32_t ssize, char *dst, uint32_t dsize) {
|
||||
struct UNSP read_struct;
|
||||
uint32_t i = (0x300<<((allocsz+tre)&0xff)) + 0x736;
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#include "others.h"
|
||||
|
||||
struct UNSP {
|
||||
char *src_curr;
|
||||
char *src_end;
|
||||
const char *src_curr;
|
||||
const char *src_end;
|
||||
uint32_t bitmap;
|
||||
uint32_t oldval;
|
||||
int error;
|
||||
@@ -35,8 +35,8 @@ struct UNSP {
|
||||
char *table;
|
||||
};
|
||||
|
||||
uint32_t unspack(char *, char *, cli_ctx *, uint32_t, uint32_t, uint32_t, int);
|
||||
uint32_t very_real_unpack(uint16_t *, uint32_t, uint32_t, uint32_t, uint32_t, char *, uint32_t, char *, uint32_t);
|
||||
uint32_t unspack(const char *, char *, cli_ctx *, uint32_t, uint32_t, uint32_t, int);
|
||||
uint32_t very_real_unpack(uint16_t *, uint32_t, uint32_t, uint32_t, uint32_t,const char *, uint32_t, char *, uint32_t);
|
||||
uint32_t get_byte(struct UNSP *);
|
||||
int getbit_from_table(uint16_t *, struct UNSP *);
|
||||
uint32_t get_100_bits_from_tablesize(uint16_t *, struct UNSP *, uint32_t);
|
||||
|
||||
@@ -56,7 +56,7 @@ static int wrap_inflateinit2(void *a, int b) {
|
||||
return inflateInit2(a, b);
|
||||
}
|
||||
|
||||
static int unz(uint8_t *src, uint32_t csize, uint32_t usize, uint16_t method, uint16_t flags, unsigned int *fu, cli_ctx *ctx, char *tmpd) {
|
||||
static int unz(const uint8_t *src, uint32_t csize, uint32_t usize, uint16_t method, uint16_t flags, unsigned int *fu, cli_ctx *ctx, char *tmpd) {
|
||||
char name[1024], obuf[BUFSIZ];
|
||||
char *tempfile = name;
|
||||
int of, ret=CL_CLEAN;
|
||||
@@ -134,7 +134,7 @@ static int unz(uint8_t *src, uint32_t csize, uint32_t usize, uint16_t method, ui
|
||||
|
||||
memset(&strm, 0, sizeof(strm));
|
||||
|
||||
*next_in = src;
|
||||
*next_in = (void*) src;
|
||||
*next_out = obuf;
|
||||
*avail_in = csize;
|
||||
*avail_out = sizeof(obuf);
|
||||
@@ -216,7 +216,7 @@ static int unz(uint8_t *src, uint32_t csize, uint32_t usize, uint16_t method, ui
|
||||
|
||||
case ALG_IMPLODE: {
|
||||
struct xplstate strm;
|
||||
strm.next_in = src;
|
||||
strm.next_in = (void*)src;
|
||||
strm.next_out = (uint8_t *)obuf;
|
||||
strm.avail_in = csize;
|
||||
strm.avail_out = sizeof(obuf);
|
||||
@@ -297,8 +297,8 @@ static int unz(uint8_t *src, uint32_t csize, uint32_t usize, uint16_t method, ui
|
||||
return ret;
|
||||
}
|
||||
|
||||
static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int *fu, unsigned int fc, uint8_t *ch, int *ret, cli_ctx *ctx, char *tmpd, int detect_encrypted) {
|
||||
uint8_t *lh, *zip;
|
||||
static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int *fu, unsigned int fc, const uint8_t *ch, int *ret, cli_ctx *ctx, char *tmpd, int detect_encrypted) {
|
||||
const uint8_t *lh, *zip;
|
||||
char name[256];
|
||||
uint32_t csize, usize;
|
||||
|
||||
@@ -323,7 +323,7 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int
|
||||
}
|
||||
if(ctx->engine->cdb || cli_debug_flag) {
|
||||
uint32_t nsize = (LH_flen>=sizeof(name))?sizeof(name)-1:LH_flen;
|
||||
char *src;
|
||||
const char *src;
|
||||
if(nsize && (src = fmap_need_ptr_once(map, zip, nsize))) {
|
||||
memcpy(name, zip, nsize);
|
||||
name[nsize]='\0';
|
||||
@@ -416,7 +416,7 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int
|
||||
static unsigned int chdr(fmap_t *map, uint32_t coff, uint32_t zsize, unsigned int *fu, unsigned int fc, int *ret, cli_ctx *ctx, char *tmpd) {
|
||||
char name[256];
|
||||
int last = 0;
|
||||
uint8_t *ch;
|
||||
const uint8_t *ch;
|
||||
|
||||
if(!(ch = fmap_need_off(map, coff, SIZEOF_CH)) || CH_magic != 0x02014b50) {
|
||||
if(ch) fmap_unneed_ptr(map, ch, SIZEOF_CH);
|
||||
@@ -433,7 +433,7 @@ static unsigned int chdr(fmap_t *map, uint32_t coff, uint32_t zsize, unsigned in
|
||||
}
|
||||
if(cli_debug_flag && !last) {
|
||||
unsigned int size = (CH_flen>=sizeof(name))?sizeof(name)-1:CH_flen;
|
||||
char *src = fmap_need_off_once(map, coff, size);
|
||||
const char *src = fmap_need_off_once(map, coff, size);
|
||||
if(src) {
|
||||
memcpy(name, src, size);
|
||||
name[size]='\0';
|
||||
@@ -467,7 +467,8 @@ int cli_unzip(cli_ctx *ctx) {
|
||||
int ret=CL_CLEAN;
|
||||
uint32_t fsize, lhoff = 0, coff = 0;
|
||||
fmap_t *map = *ctx->fmap;
|
||||
char *tmpd, *ptr;
|
||||
char *tmpd;
|
||||
const char *ptr;
|
||||
|
||||
cli_dbgmsg("in cli_unzip\n");
|
||||
fsize = (uint32_t)map->len;
|
||||
|
||||
@@ -116,7 +116,7 @@ static char *checkpe(char *dst, uint32_t dsize, char *pehdr, uint32_t *valign, u
|
||||
|
||||
/* PE from UPX */
|
||||
|
||||
static int pefromupx (char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t ep, uint32_t upx0, uint32_t upx1, uint32_t *magic, uint32_t dend)
|
||||
static int pefromupx (const char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t ep, uint32_t upx0, uint32_t upx1, uint32_t *magic, uint32_t dend)
|
||||
{
|
||||
char *imports, *sections=NULL, *pehdr=NULL, *newbuf;
|
||||
unsigned int sectcnt=0, upd=1;
|
||||
@@ -259,7 +259,7 @@ static int pefromupx (char *src, uint32_t ssize, char *dst, uint32_t *dsize, uin
|
||||
|
||||
/* [doubleebx] */
|
||||
|
||||
static int doubleebx(char *src, uint32_t *myebx, uint32_t *scur, uint32_t ssize)
|
||||
static int doubleebx(const char *src, uint32_t *myebx, uint32_t *scur, uint32_t ssize)
|
||||
{
|
||||
uint32_t oldebx = *myebx;
|
||||
|
||||
@@ -276,7 +276,7 @@ static int doubleebx(char *src, uint32_t *myebx, uint32_t *scur, uint32_t ssize)
|
||||
|
||||
/* [inflate] */
|
||||
|
||||
int upx_inflate2b(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep)
|
||||
int upx_inflate2b(const char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep)
|
||||
{
|
||||
int32_t backbytes, unp_offset = -1;
|
||||
uint32_t backsize, myebx = 0, scur=0, dcur=0, i, magic[]={0x108,0x110,0xd5,0};
|
||||
@@ -351,7 +351,7 @@ int upx_inflate2b(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_
|
||||
return pefromupx (src, ssize, dst, dsize, ep, upx0, upx1, magic, dcur);
|
||||
}
|
||||
|
||||
int upx_inflate2d(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep)
|
||||
int upx_inflate2d(const char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep)
|
||||
{
|
||||
int32_t backbytes, unp_offset = -1;
|
||||
uint32_t backsize, myebx = 0, scur=0, dcur=0, i, magic[]={0x11c,0x124,0};
|
||||
@@ -433,7 +433,7 @@ int upx_inflate2d(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_
|
||||
return pefromupx (src, ssize, dst, dsize, ep, upx0, upx1, magic, dcur);
|
||||
}
|
||||
|
||||
int upx_inflate2e(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep)
|
||||
int upx_inflate2e(const char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep)
|
||||
{
|
||||
int32_t backbytes, unp_offset = -1;
|
||||
uint32_t backsize, myebx = 0, scur=0, dcur=0, i, magic[]={0x128,0x130,0};
|
||||
@@ -522,7 +522,7 @@ int upx_inflate2e(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_
|
||||
return pefromupx (src, ssize, dst, dsize, ep, upx0, upx1, magic, dcur);
|
||||
}
|
||||
|
||||
int upx_inflatelzma(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep) {
|
||||
int upx_inflatelzma(const char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep) {
|
||||
struct CLI_LZMA l;
|
||||
uint32_t magic[]={0xb16,0xb1e,0};
|
||||
unsigned char fake_lzmahdr[5];
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
|
||||
#include "cltypes.h"
|
||||
|
||||
int upx_inflate2b(char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t);
|
||||
int upx_inflate2d(char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t);
|
||||
int upx_inflate2e(char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t);
|
||||
int upx_inflatelzma(char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t);
|
||||
int upx_inflate2b(const char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t);
|
||||
int upx_inflate2d(const char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t);
|
||||
int upx_inflate2e(const char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t);
|
||||
int upx_inflatelzma(const char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -336,6 +336,7 @@ static int get_test_file(int i, char *file, unsigned fsize, unsigned long *size)
|
||||
*size = st.st_size;
|
||||
return fd;
|
||||
}
|
||||
#ifdef CHECK_HAVE_LOOPS
|
||||
|
||||
static ssize_t pread_cb(void *handle, void *buf, size_t count, off_t offset)
|
||||
{
|
||||
@@ -396,7 +397,7 @@ START_TEST (test_cl_scanmap_callback_mem)
|
||||
munmap(mem, size);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
#endif
|
||||
|
||||
static Suite *test_cl_suite(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user