... | ... |
@@ -176,7 +176,7 @@ static uint32_t getbits(struct UNP *UNP, uint32_t size) { |
176 | 176 |
*********************/ |
177 | 177 |
|
178 | 178 |
|
179 |
-static int ea05(cli_ctx *ctx, uint8_t *base, char *tmpd) { |
|
179 |
+static int ea05(cli_ctx *ctx, const uint8_t *base, char *tmpd) { |
|
180 | 180 |
uint8_t b[300], comp; |
181 | 181 |
uint32_t s, m4sum=0; |
182 | 182 |
int i, ret; |
... | ... |
@@ -480,7 +480,7 @@ static void LAME_decrypt (uint8_t *cypher, uint32_t size, uint16_t seed) { |
480 | 480 |
autoit3 EA06 handler |
481 | 481 |
*********************/ |
482 | 482 |
|
483 |
-static int ea06(cli_ctx *ctx, uint8_t *base, char *tmpd) { |
|
483 |
+static int ea06(cli_ctx *ctx, const uint8_t *base, char *tmpd) { |
|
484 | 484 |
uint8_t b[600], comp, script, *buf; |
485 | 485 |
uint32_t s; |
486 | 486 |
int i, ret; |
... | ... |
@@ -916,7 +916,7 @@ static int ea06(cli_ctx *ctx, uint8_t *base, char *tmpd) { |
916 | 916 |
*********************/ |
917 | 917 |
|
918 | 918 |
int cli_scanautoit(cli_ctx *ctx, off_t offset) { |
919 |
- uint8_t *version; |
|
919 |
+ const uint8_t *version; |
|
920 | 920 |
int r; |
921 | 921 |
char *tmpd; |
922 | 922 |
fmap_t *map = *ctx->fmap; |
... | ... |
@@ -48,7 +48,8 @@ static const uint8_t hqxtbl[] = { |
48 | 48 |
|
49 | 49 |
int cli_binhex(cli_ctx *ctx) { |
50 | 50 |
fmap_t *map = *ctx->fmap; |
51 |
- uint8_t *encoded, decoded[BUFSIZ], spare_bits, last_byte=0, this_byte, offset=0; |
|
51 |
+ const uint8_t *encoded; |
|
52 |
+ uint8_t decoded[BUFSIZ], spare_bits, last_byte=0, this_byte, offset=0; |
|
52 | 53 |
size_t enc_done=0, enc_todo=map->len; |
53 | 54 |
unsigned int dec_done=0, chunksz = 0, chunkoff=0; |
54 | 55 |
uint32_t datalen, reslen; |
... | ... |
@@ -534,7 +534,7 @@ int32_t cli_bcapi_extract_new(struct cli_bc_ctx *ctx, int32_t id) |
534 | 534 |
int32_t cli_bcapi_read_number(struct cli_bc_ctx *ctx, uint32_t radix) |
535 | 535 |
{ |
536 | 536 |
unsigned i; |
537 |
- char *p; |
|
537 |
+ const char *p; |
|
538 | 538 |
int32_t result; |
539 | 539 |
|
540 | 540 |
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) |
705 | 705 |
return ctx->file_size - b->read_cursor; |
706 | 706 |
} |
707 | 707 |
|
708 |
-uint8_t* cli_bcapi_buffer_pipe_read_get(struct cli_bc_ctx *ctx , int32_t id, uint32_t size) |
|
708 |
+const uint8_t* cli_bcapi_buffer_pipe_read_get(struct cli_bc_ctx *ctx , int32_t id, uint32_t size) |
|
709 | 709 |
{ |
710 | 710 |
struct bc_buffer *b = get_buffer(ctx, id); |
711 | 711 |
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) |
843 | 843 |
b->stream.avail_in = avail_in_orig = |
844 | 844 |
cli_bcapi_buffer_pipe_read_avail(ctx, b->from); |
845 | 845 |
|
846 |
- b->stream.next_in = cli_bcapi_buffer_pipe_read_get(ctx, b->from, |
|
846 |
+ b->stream.next_in = (void*)cli_bcapi_buffer_pipe_read_get(ctx, b->from, |
|
847 | 847 |
b->stream.avail_in); |
848 | 848 |
|
849 | 849 |
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) |
959 | 959 |
int32_t cli_bcapi_jsnorm_process(struct cli_bc_ctx *ctx, int32_t id) |
960 | 960 |
{ |
961 | 961 |
unsigned avail; |
962 |
- unsigned char *in; |
|
962 |
+ const unsigned char *in; |
|
963 | 963 |
cli_ctx *cctx = ctx->ctx; |
964 | 964 |
struct bc_jsnorm *b = get_jsnorm(ctx, id); |
965 | 965 |
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) |
1448 | 1448 |
return ctx->pdf_objs[objidx+1].start - ctx->pdf_objs[objidx].start - 4; |
1449 | 1449 |
} |
1450 | 1450 |
|
1451 |
-uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t objidx, uint32_t amount) |
|
1451 |
+const uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t objidx, uint32_t amount) |
|
1452 | 1452 |
{ |
1453 | 1453 |
uint32_t size = cli_bcapi_pdf_getobjsize(ctx, objidx); |
1454 | 1454 |
if (amount > size) |
... | ... |
@@ -65,7 +65,7 @@ int32_t cli_bcapi_hashset_empty(struct cli_bc_ctx *ctx , int32_t); |
65 | 65 |
int32_t cli_bcapi_buffer_pipe_new(struct cli_bc_ctx *ctx , uint32_t); |
66 | 66 |
int32_t cli_bcapi_buffer_pipe_new_fromfile(struct cli_bc_ctx *ctx , uint32_t); |
67 | 67 |
uint32_t cli_bcapi_buffer_pipe_read_avail(struct cli_bc_ctx *ctx , int32_t); |
68 |
-uint8_t* cli_bcapi_buffer_pipe_read_get(struct cli_bc_ctx *ctx , int32_t, uint32_t); |
|
68 |
+const uint8_t* cli_bcapi_buffer_pipe_read_get(struct cli_bc_ctx *ctx , int32_t, uint32_t); |
|
69 | 69 |
int32_t cli_bcapi_buffer_pipe_read_stopped(struct cli_bc_ctx *ctx , int32_t, uint32_t); |
70 | 70 |
uint32_t cli_bcapi_buffer_pipe_write_avail(struct cli_bc_ctx *ctx , int32_t); |
71 | 71 |
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 ); |
114 | 114 |
int32_t cli_bcapi_pdf_set_flags(struct cli_bc_ctx *ctx , int32_t); |
115 | 115 |
int32_t cli_bcapi_pdf_lookupobj(struct cli_bc_ctx *ctx , uint32_t); |
116 | 116 |
uint32_t cli_bcapi_pdf_getobjsize(struct cli_bc_ctx *ctx , int32_t); |
117 |
-uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t, uint32_t); |
|
117 |
+const uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t, uint32_t); |
|
118 | 118 |
int32_t cli_bcapi_pdf_getobjid(struct cli_bc_ctx *ctx , int32_t); |
119 | 119 |
int32_t cli_bcapi_pdf_getobjflags(struct cli_bc_ctx *ctx , int32_t); |
120 | 120 |
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); |
63 | 63 |
int32_t cli_bcapi_buffer_pipe_new(struct cli_bc_ctx *ctx , uint32_t); |
64 | 64 |
int32_t cli_bcapi_buffer_pipe_new_fromfile(struct cli_bc_ctx *ctx , uint32_t); |
65 | 65 |
uint32_t cli_bcapi_buffer_pipe_read_avail(struct cli_bc_ctx *ctx , int32_t); |
66 |
-uint8_t* cli_bcapi_buffer_pipe_read_get(struct cli_bc_ctx *ctx , int32_t, uint32_t); |
|
66 |
+const uint8_t* cli_bcapi_buffer_pipe_read_get(struct cli_bc_ctx *ctx , int32_t, uint32_t); |
|
67 | 67 |
int32_t cli_bcapi_buffer_pipe_read_stopped(struct cli_bc_ctx *ctx , int32_t, uint32_t); |
68 | 68 |
uint32_t cli_bcapi_buffer_pipe_write_avail(struct cli_bc_ctx *ctx , int32_t); |
69 | 69 |
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 ); |
112 | 112 |
int32_t cli_bcapi_pdf_set_flags(struct cli_bc_ctx *ctx , int32_t); |
113 | 113 |
int32_t cli_bcapi_pdf_lookupobj(struct cli_bc_ctx *ctx , uint32_t); |
114 | 114 |
uint32_t cli_bcapi_pdf_getobjsize(struct cli_bc_ctx *ctx , int32_t); |
115 |
-uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t, uint32_t); |
|
115 |
+const uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t, uint32_t); |
|
116 | 116 |
int32_t cli_bcapi_pdf_getobjid(struct cli_bc_ctx *ctx , int32_t); |
117 | 117 |
int32_t cli_bcapi_pdf_getobjflags(struct cli_bc_ctx *ctx , int32_t); |
118 | 118 |
int32_t cli_bcapi_pdf_setobjflags(struct cli_bc_ctx *ctx , int32_t, int32_t); |
... | ... |
@@ -95,7 +95,8 @@ struct cab_block_hdr |
95 | 95 |
static char *cab_readstr(fmap_t *map, off_t *offset, int *ret) |
96 | 96 |
{ |
97 | 97 |
int i; |
98 |
- char *str, *retstr; |
|
98 |
+ const char *str; |
|
99 |
+ char *retstr; |
|
99 | 100 |
|
100 | 101 |
if(!(str = fmap_need_offstr(map, *offset, 256))) { |
101 | 102 |
*ret = CL_EFORMAT; |
... | ... |
@@ -181,8 +182,8 @@ int cab_open(fmap_t *map, off_t offset, struct cab_archive *cab) |
181 | 181 |
unsigned int i, folders = 0; |
182 | 182 |
struct cab_file *file, *lfile = NULL; |
183 | 183 |
struct cab_folder *folder, *lfolder = NULL; |
184 |
- struct cab_hdr *hdr; |
|
185 |
- struct cab_hdr_opt *hdr_opt; |
|
184 |
+ const struct cab_hdr *hdr; |
|
185 |
+ const struct cab_hdr_opt *hdr_opt; |
|
186 | 186 |
uint16_t fidx; |
187 | 187 |
uint32_t coffFiles; |
188 | 188 |
char *pt; |
... | ... |
@@ -305,7 +306,7 @@ int cab_open(fmap_t *map, off_t offset, struct cab_archive *cab) |
305 | 305 |
|
306 | 306 |
/* folders */ |
307 | 307 |
for(i = 0; i < cab->nfolders; i++) { |
308 |
- struct cab_folder_hdr *folder_hdr; |
|
308 |
+ const struct cab_folder_hdr *folder_hdr; |
|
309 | 309 |
|
310 | 310 |
if(!(folder_hdr = fmap_need_off_once(map, cur_offset, sizeof(*folder_hdr)))) { |
311 | 311 |
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) |
360 | 360 |
cur_offset = coffFiles; |
361 | 361 |
} |
362 | 362 |
for(i = 0; i < cab->nfiles; i++) { |
363 |
- struct cab_file_hdr *file_hdr; |
|
363 |
+ const struct cab_file_hdr *file_hdr; |
|
364 | 364 |
|
365 | 365 |
if(!(file_hdr = fmap_need_off_once(map, cur_offset, sizeof(*file_hdr)))) { |
366 | 366 |
cli_dbgmsg("cab_open: Can't read file %u header\n", i); |
... | ... |
@@ -449,7 +450,7 @@ int cab_open(fmap_t *map, off_t offset, struct cab_archive *cab) |
449 | 449 |
|
450 | 450 |
static int cab_read_block(struct cab_file *file) |
451 | 451 |
{ |
452 |
- struct cab_block_hdr *block_hdr; |
|
452 |
+ const struct cab_block_hdr *block_hdr; |
|
453 | 453 |
struct cab_state *state = file->cab->state; |
454 | 454 |
|
455 | 455 |
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) { |
703 | 703 |
|
704 | 704 |
cli_md5_init(&md5); |
705 | 705 |
while(todo) { |
706 |
- void *buf; |
|
706 |
+ const void *buf; |
|
707 | 707 |
size_t readme = todo < FILEBUFF ? todo : FILEBUFF; |
708 | 708 |
if(!(buf = fmap_need_off_once(map, at, readme))) |
709 | 709 |
return CL_VIRUS; |
... | ... |
@@ -105,7 +105,7 @@ typedef struct lzx_content_tag { |
105 | 105 |
/* Read in a block of data from either the mmap area or the given fd */ |
106 | 106 |
static int chm_read_data(fmap_t *map, char *dest, off_t offset, off_t len) |
107 | 107 |
{ |
108 |
- void *src = fmap_need_off_once(map, offset, len); |
|
108 |
+ const void *src = fmap_need_off_once(map, offset, len); |
|
109 | 109 |
if(!src) return FALSE; |
110 | 110 |
memcpy(dest, src, len); |
111 | 111 |
return TRUE; |
... | ... |
@@ -233,10 +233,10 @@ static int itsp_read_header(chm_metadata_t *metadata, off_t offset) |
233 | 233 |
return TRUE; |
234 | 234 |
} |
235 | 235 |
|
236 |
-static uint64_t read_enc_int(char **start, char *end) |
|
236 |
+static uint64_t read_enc_int(const char **start, const char *end) |
|
237 | 237 |
{ |
238 | 238 |
uint64_t retval=0; |
239 |
- char *current; |
|
239 |
+ const char *current; |
|
240 | 240 |
|
241 | 241 |
current = *start; |
242 | 242 |
|
... | ... |
@@ -258,7 +258,7 @@ static uint64_t read_enc_int(char **start, char *end) |
258 | 258 |
/* Read control entries */ |
259 | 259 |
static int read_control_entries(chm_metadata_t *metadata) |
260 | 260 |
{ |
261 |
- char *name; |
|
261 |
+ const char *name; |
|
262 | 262 |
uint64_t name_len, section, offset, length; |
263 | 263 |
|
264 | 264 |
while (metadata->chunk_entries--) { |
... | ... |
@@ -108,9 +108,9 @@ typedef struct chm_metadata_tag { |
108 | 108 |
int ofd; |
109 | 109 |
uint32_t num_chunks; |
110 | 110 |
off_t chunk_offset; |
111 |
- char *chunk_data; |
|
112 |
- char *chunk_current; |
|
113 |
- char *chunk_end; |
|
111 |
+ const char *chunk_data; |
|
112 |
+ const char *chunk_current; |
|
113 |
+ const char *chunk_end; |
|
114 | 114 |
fmap_t *map; |
115 | 115 |
uint16_t chunk_entries; |
116 | 116 |
} chm_metadata_t; |
... | ... |
@@ -155,11 +155,12 @@ cli_file_t cli_filetype(const unsigned char *buf, size_t buflen, const struct cl |
155 | 155 |
return cli_texttype(buf, buflen); |
156 | 156 |
} |
157 | 157 |
|
158 |
-int is_tar(unsigned char *buf, unsigned int nbytes); |
|
158 |
+int is_tar(const unsigned char *buf, unsigned int nbytes); |
|
159 | 159 |
|
160 | 160 |
cli_file_t cli_filetype2(fmap_t *map, const struct cl_engine *engine) |
161 | 161 |
{ |
162 |
- unsigned char *buff, *decoded; |
|
162 |
+ const unsigned char *buff; |
|
163 |
+ unsigned char *decoded; |
|
163 | 164 |
int bread = MIN(map->len, MAGIC_BUFFER_SIZE), sret; |
164 | 165 |
cli_file_t ret = CL_TYPE_BINARY_DATA; |
165 | 166 |
struct cli_matcher *root; |
... | ... |
@@ -103,12 +103,12 @@ static inline size_t fmap_ptr2off(const fmap_t *m, const void *ptr) |
103 | 103 |
:(const char*)ptr - (const char*)m - m->hdrsz; |
104 | 104 |
} |
105 | 105 |
|
106 |
-static inline const void *fmap_need_ptr(fmap_t *m, void *ptr, size_t len) |
|
106 |
+static inline const void *fmap_need_ptr(fmap_t *m, const void *ptr, size_t len) |
|
107 | 107 |
{ |
108 | 108 |
return m->need(m, fmap_ptr2off(m, ptr), len, 1); |
109 | 109 |
} |
110 | 110 |
|
111 |
-static inline const void *fmap_need_ptr_once(fmap_t *m, void *ptr, size_t len) |
|
111 |
+static inline const void *fmap_need_ptr_once(fmap_t *m, const void *ptr, size_t len) |
|
112 | 112 |
{ |
113 | 113 |
return m->need(m, fmap_ptr2off(m, ptr), len, 0); |
114 | 114 |
} |
... | ... |
@@ -118,7 +118,7 @@ static inline void fmap_unneed_off(fmap_t *m, size_t at, size_t len) |
118 | 118 |
m->unneed_off(m, at, len); |
119 | 119 |
} |
120 | 120 |
|
121 |
-static inline void fmap_unneed_ptr(fmap_t *m, void *ptr, size_t len) |
|
121 |
+static inline void fmap_unneed_ptr(fmap_t *m, const void *ptr, size_t len) |
|
122 | 122 |
{ |
123 | 123 |
fmap_unneed_off(m, fmap_ptr2off(m, ptr), len); |
124 | 124 |
} |
... | ... |
@@ -140,7 +140,7 @@ static inline int fmap_readn(fmap_t *m, void *dst, size_t at, size_t len) |
140 | 140 |
return len; |
141 | 141 |
} |
142 | 142 |
|
143 |
-static inline const void *fmap_need_str(fmap_t *m, void *ptr, size_t len_hint) |
|
143 |
+static inline const void *fmap_need_str(fmap_t *m, const void *ptr, size_t len_hint) |
|
144 | 144 |
{ |
145 | 145 |
return m->need_offstr(m, fmap_ptr2off(m, ptr), len_hint); |
146 | 146 |
} |
... | ... |
@@ -46,7 +46,7 @@ |
46 | 46 |
#include "packlibs.h" |
47 | 47 |
#include "fsg.h" |
48 | 48 |
|
49 |
-int unfsg_200(char *source, char *dest, int ssize, int dsize, uint32_t rva, uint32_t base, uint32_t ep, int file) { |
|
49 |
+int unfsg_200(const char *source, char *dest, int ssize, int dsize, uint32_t rva, uint32_t base, uint32_t ep, int file) { |
|
50 | 50 |
struct cli_exe_section section; /* Yup, just one ;) */ |
51 | 51 |
|
52 | 52 |
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 |
64 | 64 |
} |
65 | 65 |
|
66 | 66 |
|
67 |
-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) { |
|
68 |
- char *tsrc=source, *tdst=dest; |
|
67 |
+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) { |
|
68 |
+ const char *tsrc=source; |
|
69 |
+ char *tdst=dest; |
|
69 | 70 |
int i, upd=1, offs=0, lastsz=dsize; |
70 | 71 |
|
71 | 72 |
for (i = 0 ; i <= sectcount ; i++) { |
... | ... |
@@ -24,8 +24,8 @@ |
24 | 24 |
#include "cltypes.h" |
25 | 25 |
#include "execs.h" |
26 | 26 |
|
27 |
-int unfsg_200(char *, char *, int, int, uint32_t, uint32_t, uint32_t, int); |
|
28 |
-int unfsg_133(char *, char *, int , int, struct cli_exe_section *, int, uint32_t, uint32_t, int); |
|
27 |
+int unfsg_200(const char *, char *, int, int, uint32_t, uint32_t, uint32_t, int); |
|
28 |
+int unfsg_133(const char *, char *, int , int, struct cli_exe_section *, int, uint32_t, uint32_t, int); |
|
29 | 29 |
|
30 | 30 |
#endif |
31 | 31 |
|
... | ... |
@@ -32,7 +32,7 @@ static int from_oct(int digs, char *where); |
32 | 32 |
* 1 for old UNIX tar file, |
33 | 33 |
* 2 for Unix Std (POSIX) tar file. |
34 | 34 |
*/ |
35 |
-int is_tar(unsigned char *buf, unsigned int nbytes) |
|
35 |
+int is_tar(const unsigned char *buf, unsigned int nbytes) |
|
36 | 36 |
{ |
37 | 37 |
union record *header = (union record *)buf; |
38 | 38 |
int i; |
... | ... |
@@ -193,7 +193,7 @@ static const uint8_t skey[] = { 0xec, 0xca, 0x79, 0xf8 }; /* ~0x13, ~0x35, ~0x86 |
193 | 193 |
|
194 | 194 |
/* Extracts the content of MSI based IS */ |
195 | 195 |
int cli_scanishield_msi(cli_ctx *ctx, off_t off) { |
196 |
- uint8_t *buf; |
|
196 |
+ const uint8_t *buf; |
|
197 | 197 |
unsigned int fcount, scanned = 0; |
198 | 198 |
int ret; |
199 | 199 |
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 |
337 | 337 |
|
338 | 338 |
/* Extract the content of older (non-MSI) IS */ |
339 | 339 |
int cli_scanishield(cli_ctx *ctx, off_t off, size_t sz) { |
340 |
- char *fname, *path, *version, *strsz, *eostr, *data; |
|
340 |
+ const char *fname, *path, *version, *strsz, *data; |
|
341 |
+ char *eostr; |
|
341 | 342 |
int ret = CL_CLEAN; |
342 | 343 |
long fsize; |
343 | 344 |
off_t coff = off; |
... | ... |
@@ -436,7 +437,8 @@ int cli_scanishield(cli_ctx *ctx, off_t off, size_t sz) { |
436 | 436 |
|
437 | 437 |
/* Utility func to scan a fd @ a given offset and size */ |
438 | 438 |
static int is_dump_and_scan(cli_ctx *ctx, off_t off, size_t fsize) { |
439 |
- char *fname, *buf; |
|
439 |
+ char *fname; |
|
440 |
+ const char *buf; |
|
440 | 441 |
int ofd, ret = CL_CLEAN; |
441 | 442 |
fmap_t *map = *ctx->fmap; |
442 | 443 |
|
... | ... |
@@ -486,7 +488,7 @@ static int is_parse_hdr(cli_ctx *ctx, struct IS_CABSTUFF *c) { |
486 | 486 |
char hash[33], *hdr; |
487 | 487 |
fmap_t *map = *ctx->fmap; |
488 | 488 |
|
489 |
- struct IS_HDR *h1; |
|
489 |
+ const struct IS_HDR *h1; |
|
490 | 490 |
struct IS_OBJECTS *objs; |
491 | 491 |
/* struct IS_INSTTYPEHDR *typehdr; -- UNUSED */ |
492 | 492 |
|
... | ... |
@@ -675,7 +677,8 @@ static void md5str(uint8_t *sum) { |
675 | 675 |
#define IS_CABBUFSZ 65536 |
676 | 676 |
|
677 | 677 |
static int is_extract_cab(cli_ctx *ctx, uint64_t off, uint64_t size, uint64_t csize) { |
678 |
- uint8_t *inbuf, *outbuf; |
|
678 |
+ const uint8_t *inbuf; |
|
679 |
+ uint8_t *outbuf; |
|
679 | 680 |
char *tempfile; |
680 | 681 |
int ofd, ret = CL_CLEAN; |
681 | 682 |
z_stream z; |
... | ... |
@@ -37,7 +37,7 @@ typedef struct { |
37 | 37 |
} iso9660_t; |
38 | 38 |
|
39 | 39 |
|
40 |
-static void *needblock(const iso9660_t *iso, unsigned int block, int temp) { |
|
40 |
+static const void *needblock(const iso9660_t *iso, unsigned int block, int temp) { |
|
41 | 41 |
cli_ctx *ctx = iso->ctx; |
42 | 42 |
size_t loff; |
43 | 43 |
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 |
59 | 59 |
|
60 | 60 |
cli_dbgmsg("iso_scan_file: dumping to %s\n", tmpf); |
61 | 61 |
while(len) { |
62 |
- void *buf = needblock(iso, block, 1); |
|
62 |
+ const void *buf = needblock(iso, block, 1); |
|
63 | 63 |
unsigned int todo = MIN(len, iso->blocksz); |
64 | 64 |
if(cli_writen(fd, buf, todo) != todo) { |
65 | 65 |
close(fd); |
... | ... |
@@ -88,7 +88,7 @@ static int iso_scan_file(const iso9660_t *iso, unsigned int block, unsigned int |
88 | 88 |
return ret; |
89 | 89 |
} |
90 | 90 |
|
91 |
-static char *iso_string(iso9660_t *iso, void *src, unsigned int len) { |
|
91 |
+static char *iso_string(iso9660_t *iso, const void *src, unsigned int len) { |
|
92 | 92 |
if(iso->joliet) { |
93 | 93 |
char *utf8; |
94 | 94 |
if(len > sizeof(iso->buf)) |
... | ... |
@@ -120,7 +120,7 @@ static int iso_parse_dir(iso9660_t *iso, unsigned int block, unsigned int len) { |
120 | 120 |
} |
121 | 121 |
|
122 | 122 |
for(; len && ret == CL_CLEAN; block++, len -= MIN(len, iso->blocksz)) { |
123 |
- uint8_t *dir, *dir_orig; |
|
123 |
+ const uint8_t *dir, *dir_orig; |
|
124 | 124 |
unsigned int dirsz; |
125 | 125 |
|
126 | 126 |
if(iso->dir_blocks.count > 1024) { |
... | ... |
@@ -205,7 +205,7 @@ static int iso_parse_dir(iso9660_t *iso, unsigned int block, unsigned int len) { |
205 | 205 |
} |
206 | 206 |
|
207 | 207 |
int cli_scaniso(cli_ctx *ctx, size_t offset) { |
208 |
- uint8_t *privol, *next; |
|
208 |
+ const uint8_t *privol, *next; |
|
209 | 209 |
iso9660_t iso; |
210 | 210 |
int i; |
211 | 211 |
|
... | ... |
@@ -396,7 +396,7 @@ int cli_checkfp(unsigned char *digest, size_t size, cli_ctx *ctx) |
396 | 396 |
SHA1Context sha1; |
397 | 397 |
SHA256_CTX sha256; |
398 | 398 |
fmap_t *map; |
399 |
- char *ptr; |
|
399 |
+ const char *ptr; |
|
400 | 400 |
uint8_t shash1[SHA1_HASH_SIZE*2+1]; |
401 | 401 |
uint8_t shash256[SHA256_HASH_SIZE*2+1]; |
402 | 402 |
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 |
610 | 610 |
|
611 | 611 |
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) |
612 | 612 |
{ |
613 |
- unsigned char *buff; |
|
613 |
+ const unsigned char *buff; |
|
614 | 614 |
int ret = CL_CLEAN, type = CL_CLEAN, bytes, compute_hash[CLI_HASH_AVAIL_TYPES]; |
615 | 615 |
unsigned int i = 0, bm_offmode = 0; |
616 | 616 |
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 |
760 | 760 |
} |
761 | 761 |
|
762 | 762 |
if(hdb) { |
763 |
- void *data = buff + maxpatlen * (offset!=0); |
|
763 |
+ const void *data = buff + maxpatlen * (offset!=0); |
|
764 | 764 |
uint32_t data_len = bytes - maxpatlen * (offset!=0); |
765 | 765 |
|
766 | 766 |
if(compute_hash[CLI_HASH_MD5]) |
... | ... |
@@ -656,7 +656,7 @@ parseEmailFile(fmap_t *map, size_t *at, const table_t *rfc821, const char *first |
656 | 656 |
bodyIsEmpty = TRUE; |
657 | 657 |
} else { |
658 | 658 |
char *ptr; |
659 |
- char *lookahead; |
|
659 |
+ const char *lookahead; |
|
660 | 660 |
|
661 | 661 |
if(fullline == NULL) { |
662 | 662 |
char cmd[RFC2821LENGTH + 1], out[RFC2821LENGTH + 1]; |
... | ... |
@@ -3212,7 +3212,8 @@ usefulHeader(int commandNumber, const char *cmd) |
3212 | 3212 |
static char * |
3213 | 3213 |
getline_from_mbox(char *buffer, size_t buffer_len, fmap_t *map, size_t *at) |
3214 | 3214 |
{ |
3215 |
- char *src, *cursrc, *curbuf; |
|
3215 |
+ const char *src, *cursrc; |
|
3216 |
+ char *curbuf; |
|
3216 | 3217 |
size_t i; |
3217 | 3218 |
size_t input_len = MIN(map->len - *at, buffer_len + 1); |
3218 | 3219 |
src = cursrc = fmap_need_off_once(map, *at, input_len); |
... | ... |
@@ -64,7 +64,7 @@ |
64 | 64 |
/* northfox does this shitty way, |
65 | 65 |
* this should be done with just a bswap |
66 | 66 |
*/ |
67 |
-static char *lzma_bswap_4861dc(struct lzmastate *p, char *old_edx) |
|
67 |
+static const char *lzma_bswap_4861dc(struct lzmastate *p, const char *old_edx) |
|
68 | 68 |
{ |
69 | 69 |
/* dumb_dump_start |
70 | 70 |
* |
... | ... |
@@ -99,7 +99,7 @@ static char *lzma_bswap_4861dc(struct lzmastate *p, char *old_edx) |
99 | 99 |
return p->p0; |
100 | 100 |
} |
101 | 101 |
|
102 |
-static uint32_t lzma_486248 (struct lzmastate *p, char **old_ecx, char *src, uint32_t size) |
|
102 |
+static uint32_t lzma_486248 (struct lzmastate *p,const char **old_ecx, char *src, uint32_t size) |
|
103 | 103 |
{ |
104 | 104 |
uint32_t loc_esi, loc_edi, loc_eax, loc_ecx, ret; |
105 | 105 |
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 |
152 | 152 |
|
153 | 153 |
} |
154 | 154 |
|
155 |
-static uint32_t lzma_48635C(uint8_t znaczek, char **old_ecx, struct lzmastate *p, uint32_t *retval, char *src, uint32_t size) |
|
155 |
+static uint32_t lzma_48635C(uint8_t znaczek, const char **old_ecx, struct lzmastate *p, uint32_t *retval, char *src, uint32_t size) |
|
156 | 156 |
{ |
157 | 157 |
uint32_t loc_esi = (znaczek&0xff) >> 7, /* msb */ |
158 | 158 |
loc_ebx, ret; |
159 |
- char *loc_edi; |
|
159 |
+ const char *loc_edi; |
|
160 | 160 |
znaczek <<= 1; |
161 | 161 |
ret = loc_esi << 9; |
162 | 162 |
loc_edi = *old_ecx; |
... | ... |
@@ -196,10 +196,10 @@ static uint32_t lzma_48635C(uint8_t znaczek, char **old_ecx, struct lzmastate *p |
196 | 196 |
return 0; |
197 | 197 |
} |
198 | 198 |
|
199 |
-static uint32_t lzma_4862e0 (struct lzmastate *p, char **old_ecx, uint32_t *old_edx, uint32_t *retval, char *src, uint32_t size) |
|
199 |
+static uint32_t lzma_4862e0 (struct lzmastate *p, const char **old_ecx, uint32_t *old_edx, uint32_t *retval, char *src, uint32_t size) |
|
200 | 200 |
{ |
201 | 201 |
uint32_t loc_ebx, loc_esi, stack_ecx, ret; |
202 |
- char *loc_edi; |
|
202 |
+ const char *loc_edi; |
|
203 | 203 |
|
204 | 204 |
loc_ebx = *old_edx; |
205 | 205 |
ret = 1; |
... | ... |
@@ -229,10 +229,10 @@ static uint32_t lzma_4862e0 (struct lzmastate *p, char **old_ecx, uint32_t *old_ |
229 | 229 |
} |
230 | 230 |
|
231 | 231 |
/* old_edx - write only */ |
232 |
-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) |
|
232 |
+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) |
|
233 | 233 |
{ |
234 | 234 |
uint32_t ret; |
235 |
- char *loc_esi = *old_ecx; |
|
235 |
+ const char *loc_esi = *old_ecx; |
|
236 | 236 |
|
237 | 237 |
if ((ret = lzma_486248 (p, old_ecx, src, size)) == 0xffffffff) |
238 | 238 |
return -1; |
... | ... |
@@ -274,7 +274,7 @@ static uint32_t lzma_4863da (uint32_t var0, struct lzmastate *p, char **old_ecx |
274 | 274 |
static uint32_t lzma_486204 (struct lzmastate *p, uint32_t old_edx, uint32_t *retval, char *src, uint32_t size) |
275 | 275 |
{ |
276 | 276 |
uint32_t loc_esi, loc_edi, loc_ebx, loc_eax; |
277 |
- char *loc_edx; |
|
277 |
+ const char *loc_edx; |
|
278 | 278 |
loc_esi = p->p1; |
279 | 279 |
loc_edi = p->p2; |
280 | 280 |
loc_eax = 0; |
... | ... |
@@ -311,11 +311,11 @@ static uint32_t lzma_486204 (struct lzmastate *p, uint32_t old_edx, uint32_t *re |
311 | 311 |
return 0; |
312 | 312 |
} |
313 | 313 |
|
314 |
-static uint32_t lzma_48631a (struct lzmastate *p, char **old_ecx, uint32_t *old_edx, uint32_t *retval, char *src, uint32_t size) |
|
314 |
+static uint32_t lzma_48631a (struct lzmastate *p, const char **old_ecx, uint32_t *old_edx, uint32_t *retval, char *src, uint32_t size) |
|
315 | 315 |
{ |
316 | 316 |
uint32_t copy1, copy2; |
317 | 317 |
uint32_t loc_esi, loc_edi, ret; |
318 |
- char *loc_ebx; |
|
318 |
+ const char *loc_ebx; |
|
319 | 319 |
|
320 | 320 |
copy1 = *old_edx; |
321 | 321 |
loc_edi = 0; |
... | ... |
@@ -347,7 +347,7 @@ static uint32_t lzma_48631a (struct lzmastate *p, char **old_ecx, uint32_t *old_ |
347 | 347 |
} |
348 | 348 |
|
349 | 349 |
|
350 |
-int mew_lzma(char *orgsource, char *buf, uint32_t size_sum, uint32_t vma, uint32_t special) |
|
350 |
+int mew_lzma(char *orgsource, const char *buf, uint32_t size_sum, uint32_t vma, uint32_t special) |
|
351 | 351 |
{ |
352 | 352 |
uint32_t var08, var0C, var10, var14, var20, var24, var28, var34; |
353 | 353 |
struct lzmastate var40; |
... | ... |
@@ -355,8 +355,12 @@ int mew_lzma(char *orgsource, char *buf, uint32_t size_sum, uint32_t vma, uint32 |
355 | 355 |
int i, mainloop; |
356 | 356 |
|
357 | 357 |
char var1, var30; |
358 |
- char *source = buf, *dest, *new_ebx, *new_ecx, *var0C_ecxcopy, *var2C; |
|
359 |
- char *pushed_esi = NULL, *pushed_ebx = NULL; |
|
358 |
+ const char *source = buf; |
|
359 |
+ char *dest, *new_ebx; |
|
360 |
+ const char *new_ecx, *var0C_ecxcopy; |
|
361 |
+ const char *var2C; |
|
362 |
+ char *pushed_esi = NULL; |
|
363 |
+ const char *pushed_ebx = NULL; |
|
360 | 364 |
uint32_t pushed_edx=0; |
361 | 365 |
|
362 | 366 |
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 |
774 | 774 |
{ |
775 | 775 |
uint32_t entry_point, newedi, loc_ds=dsize, loc_ss=ssize; |
776 | 776 |
char *source = src + dsize + off; |
777 |
- char *lesi = source + 12, *ledi; |
|
778 |
- char *f1, *f2; |
|
777 |
+ const char *lesi = source + 12; |
|
778 |
+ char *ledi; |
|
779 |
+ const char *f1; |
|
780 |
+ char *f2; |
|
779 | 781 |
int i; |
780 | 782 |
struct cli_exe_section *section = NULL; |
781 | 783 |
uint32_t vma = base + vadd, size_sum = ssize + dsize; |
... | ... |
@@ -28,11 +28,11 @@ |
28 | 28 |
#include "cltypes.h" |
29 | 29 |
|
30 | 30 |
struct lzmastate { |
31 |
- char *p0; |
|
31 |
+ const char *p0; |
|
32 | 32 |
uint32_t p1, p2; |
33 | 33 |
}; |
34 | 34 |
|
35 |
-int mew_lzma(char *, char *, uint32_t, uint32_t, uint32_t); |
|
35 |
+int mew_lzma(char *, const char *, uint32_t, uint32_t, uint32_t); |
|
36 | 36 |
|
37 | 37 |
uint32_t lzma_upack_esi_00(struct lzmastate *, char *, char *, uint32_t); |
38 | 38 |
uint32_t lzma_upack_esi_50(struct lzmastate *, uint32_t, uint32_t, char **, char *, uint32_t *, char *, uint32_t); |
... | ... |
@@ -70,7 +70,7 @@ struct nsis_st { |
70 | 70 |
struct CLI_LZMA lz; |
71 | 71 |
/* z_stream z; */ |
72 | 72 |
nsis_z_stream z; |
73 |
- unsigned char *freeme; |
|
73 |
+ const unsigned char *freeme; |
|
74 | 74 |
fmap_t *map; |
75 | 75 |
char ofn[1024]; |
76 | 76 |
}; |
... | ... |
@@ -183,7 +183,7 @@ static int nsis_decomp(struct nsis_st *n) { |
183 | 183 |
} |
184 | 184 |
|
185 | 185 |
static int nsis_unpack_next(struct nsis_st *n, cli_ctx *ctx) { |
186 |
- unsigned char *ibuf; |
|
186 |
+ const unsigned char *ibuf; |
|
187 | 187 |
uint32_t size, loops; |
188 | 188 |
int ret, gotsome=0; |
189 | 189 |
unsigned char obuf[BUFSIZ]; |
... | ... |
@@ -258,7 +258,7 @@ static int nsis_unpack_next(struct nsis_st *n, cli_ctx *ctx) { |
258 | 258 |
} |
259 | 259 |
|
260 | 260 |
n->nsis.avail_in = size; |
261 |
- n->nsis.next_in = ibuf; |
|
261 |
+ n->nsis.next_in = (void*)ibuf; |
|
262 | 262 |
n->nsis.next_out = obuf; |
263 | 263 |
n->nsis.avail_out = BUFSIZ; |
264 | 264 |
loops=0; |
... | ... |
@@ -325,7 +325,7 @@ static int nsis_unpack_next(struct nsis_st *n, cli_ctx *ctx) { |
325 | 325 |
close(n->ofd); |
326 | 326 |
return CL_EREAD; |
327 | 327 |
} |
328 |
- n->nsis.next_in = n->freeme; |
|
328 |
+ n->nsis.next_in = (void*)n->freeme; |
|
329 | 329 |
n->nsis.avail_in = n->asz; |
330 | 330 |
} |
331 | 331 |
|
... | ... |
@@ -276,7 +276,7 @@ static void print_ole2_header(ole2_header_t *hdr) |
276 | 276 |
static int ole2_read_block(ole2_header_t *hdr, void *buff, unsigned int size, int32_t blockno) |
277 | 277 |
{ |
278 | 278 |
off_t offset, offend; |
279 |
- void *pblock; |
|
279 |
+ const void *pblock; |
|
280 | 280 |
|
281 | 281 |
if (blockno < 0) { |
282 | 282 |
return FALSE; |
... | ... |
@@ -872,7 +872,7 @@ int cli_ole2_extract(const char *dirname, cli_ctx *ctx, struct uniq **vba) |
872 | 872 |
int hdr_size, ret=CL_CLEAN; |
873 | 873 |
unsigned int file_count=0; |
874 | 874 |
unsigned long scansize, scansize2; |
875 |
- void *phdr; |
|
875 |
+ const void *phdr; |
|
876 | 876 |
|
877 | 877 |
cli_dbgmsg("in cli_ole2_extract()\n"); |
878 | 878 |
|
... | ... |
@@ -27,7 +27,7 @@ |
27 | 27 |
#include "pe.h" |
28 | 28 |
#include "packlibs.h" |
29 | 29 |
|
30 |
-static int doubledl(char **scur, uint8_t *mydlptr, char *buffer, uint32_t buffersize) |
|
30 |
+static int doubledl(const char **scur, uint8_t *mydlptr, const char *buffer, uint32_t buffersize) |
|
31 | 31 |
{ |
32 | 32 |
unsigned char mydl = *mydlptr; |
33 | 33 |
unsigned char olddl = mydl; |
... | ... |
@@ -45,10 +45,11 @@ static int doubledl(char **scur, uint8_t *mydlptr, char *buffer, uint32_t buffer |
45 | 45 |
} |
46 | 46 |
|
47 | 47 |
|
48 |
-int cli_unfsg(char *source, char *dest, int ssize, int dsize, char **endsrc, char **enddst) { |
|
48 |
+int cli_unfsg(const char *source, char *dest, int ssize, int dsize, const char **endsrc, char **enddst) { |
|
49 | 49 |
uint8_t mydl=0x80; |
50 | 50 |
uint32_t backbytes, backsize, oldback = 0; |
51 |
- char *csrc = source, *cdst = dest; |
|
51 |
+ const char *csrc = source; |
|
52 |
+ char *cdst = dest; |
|
52 | 53 |
int oob, lostbit = 1; |
53 | 54 |
|
54 | 55 |
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 |
170 | 170 |
return 0; |
171 | 171 |
} |
172 | 172 |
|
173 |
-int unmew(char *source, char *dest, int ssize, int dsize, char **endsrc, char **enddst) { |
|
173 |
+int unmew(const char *source, char *dest, int ssize, int dsize, const char **endsrc, char **enddst) { |
|
174 | 174 |
uint8_t mydl=0x80; |
175 | 175 |
uint32_t myeax_backbytes, myecx_backsize, oldback = 0; |
176 |
- char *csrc = source, *cdst = dest; |
|
176 |
+ const char *csrc = source; |
|
177 |
+ char *cdst = dest; |
|
177 | 178 |
int oob, lostbit = 1; |
178 | 179 |
|
179 | 180 |
*cdst++=*csrc++; |
... | ... |
@@ -28,8 +28,8 @@ |
28 | 28 |
#include "cltypes.h" |
29 | 29 |
#include "rebuildpe.h" |
30 | 30 |
|
31 |
-int cli_unfsg(char *, char *, int, int, char **, char **); |
|
31 |
+int cli_unfsg(const char *, char *, int, int, const char **, char **); |
|
32 | 32 |
|
33 |
-int unmew(char *, char *, int, int, char **, char **); |
|
33 |
+int unmew(const char *, char *, int, int, const char **, char **); |
|
34 | 34 |
|
35 | 35 |
#endif |
... | ... |
@@ -325,7 +325,7 @@ static int cli_ddump(int desc, int offset, int size, const char *file) { |
325 | 325 |
void findres(uint32_t by_type, uint32_t by_name, uint32_t res_rva, fmap_t *map, struct cli_exe_section *exe_sections, uint16_t nsections, uint32_t hdr_size, int (*cb)(void *, uint32_t, uint32_t, uint32_t, uint32_t), void *opaque) { |
326 | 326 |
unsigned int err = 0; |
327 | 327 |
uint32_t type, type_offs, name, name_offs, lang, lang_offs; |
328 |
- uint8_t *resdir, *type_entry, *name_entry, *lang_entry ; |
|
328 |
+ const uint8_t *resdir, *type_entry, *name_entry, *lang_entry ; |
|
329 | 329 |
uint16_t type_cnt, name_cnt, lang_cnt; |
330 | 330 |
|
331 | 331 |
if (!(resdir = fmap_need_off_once(map, cli_rawaddr(res_rva, exe_sections, nsections, &err, map->len, hdr_size), 16)) || err) |
... | ... |
@@ -389,7 +389,7 @@ void findres(uint32_t by_type, uint32_t by_name, uint32_t res_rva, fmap_t *map, |
389 | 389 |
} |
390 | 390 |
|
391 | 391 |
static unsigned int cli_md5sect(fmap_t *map, struct cli_exe_section *s, unsigned char *digest) { |
392 |
- void *hashme; |
|
392 |
+ const void *hashme; |
|
393 | 393 |
cli_md5_ctx md5; |
394 | 394 |
|
395 | 395 |
if (s->rsz > CLI_MAX_ALLOCATION) { |
... | ... |
@@ -411,8 +411,8 @@ static unsigned int cli_md5sect(fmap_t *map, struct cli_exe_section *s, unsigned |
411 | 411 |
|
412 | 412 |
static void cli_parseres_special(uint32_t base, uint32_t rva, fmap_t *map, struct cli_exe_section *exe_sections, uint16_t nsections, size_t fsize, uint32_t hdr_size, unsigned int level, uint32_t type, unsigned int *maxres, struct swizz_stats *stats) { |
413 | 413 |
unsigned int err = 0, i; |
414 |
- uint8_t *resdir; |
|
415 |
- uint8_t *entry, *oentry; |
|
414 |
+ const uint8_t *resdir; |
|
415 |
+ const uint8_t *entry, *oentry; |
|
416 | 416 |
uint16_t named, unnamed; |
417 | 417 |
uint32_t rawaddr = cli_rawaddr(rva, exe_sections, nsections, &err, fsize, hdr_size); |
418 | 418 |
uint32_t entries; |
... | ... |
@@ -481,7 +481,7 @@ static void cli_parseres_special(uint32_t base, uint32_t rva, fmap_t *map, struc |
481 | 481 |
rawaddr = cli_rawaddr(base + offs, exe_sections, nsections, &err, fsize, hdr_size); |
482 | 482 |
if (!err && (resdir = fmap_need_off_once(map, rawaddr, 16))) { |
483 | 483 |
uint32_t isz = cli_readint32(resdir+4); |
484 |
- uint8_t *str; |
|
484 |
+ const uint8_t *str; |
|
485 | 485 |
rawaddr = cli_rawaddr(cli_readint32(resdir), exe_sections, nsections, &err, fsize, hdr_size); |
486 | 486 |
if (err || !isz || isz >= fsize || rawaddr+isz >= fsize) { |
487 | 487 |
cli_dbgmsg("cli_parseres_special: invalid resource table entry: %lu + %lu\n", |
... | ... |
@@ -519,8 +519,9 @@ int cli_scanpe(cli_ctx *ctx) |
519 | 519 |
ssize_t bytes, at; |
520 | 520 |
unsigned int i, found, upx_success = 0, min = 0, max = 0, err, overlays = 0; |
521 | 521 |
unsigned int ssize = 0, dsize = 0, dll = 0, pe_plus = 0, corrupted_cur; |
522 |
- int (*upxfn)(char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t) = NULL; |
|
523 |
- char *src = NULL, *dest = NULL; |
|
522 |
+ int (*upxfn)(const char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t) = NULL; |
|
523 |
+ const char *src = NULL; |
|
524 |
+ char *dest = NULL; |
|
524 | 525 |
int ndesc, ret = CL_CLEAN, upack = 0, native=0; |
525 | 526 |
size_t fsize; |
526 | 527 |
uint32_t valign, falign, hdr_size, j; |
... | ... |
@@ -1247,19 +1248,19 @@ int cli_scanpe(cli_ctx *ctx) |
1247 | 1247 |
|
1248 | 1248 |
if(vsize >= 0x612c && rsize >= 0x612c && ((vsize & 0xff) == 0xec)) { |
1249 | 1249 |
int bw = rsize < 0x7000 ? rsize : 0x7000; |
1250 |
- char *tbuff; |
|
1250 |
+ const char *tbuff; |
|
1251 | 1251 |
|
1252 | 1252 |
if((tbuff = fmap_need_off_once(map, exe_sections[nsections - 1].raw + rsize - bw, 4096))) { |
1253 | 1253 |
if(cli_memstr(tbuff, 4091, "\xe8\x2c\x61\x00\x00", 5)) { |
1254 | 1254 |
*ctx->virname = dam ? "Heuristics.W32.Magistr.A.dam" : "Heuristics.W32.Magistr.A"; |
1255 | 1255 |
free(exe_sections); |
1256 | 1256 |
return CL_VIRUS; |
1257 |
- } |
|
1257 |
+ } |
|
1258 | 1258 |
} |
1259 | 1259 |
|
1260 | 1260 |
} else if(rsize >= 0x7000 && vsize >= 0x7000 && ((vsize & 0xff) == 0xed)) { |
1261 | 1261 |
int bw = rsize < 0x8000 ? rsize : 0x8000; |
1262 |
- char *tbuff; |
|
1262 |
+ const char *tbuff; |
|
1263 | 1263 |
|
1264 | 1264 |
if((tbuff = fmap_need_off_once(map, exe_sections[nsections - 1].raw + rsize - bw, 4096))) { |
1265 | 1265 |
if(cli_memstr(tbuff, 4091, "\xe8\x04\x72\x00\x00", 5)) { |
... | ... |
@@ -1274,7 +1275,7 @@ int cli_scanpe(cli_ctx *ctx) |
1274 | 1274 |
/* W32.Polipos.A */ |
1275 | 1275 |
while(polipos && !dll && nsections > 2 && nsections < 13 && e_lfanew <= 0x800 && (EC16(optional_hdr32.Subsystem) == 2 || EC16(optional_hdr32.Subsystem) == 3) && EC16(file_hdr.Machine) == 0x14c && optional_hdr32.SizeOfStackReserve >= 0x80000) { |
1276 | 1276 |
uint32_t jump, jold, *jumps = NULL; |
1277 |
- uint8_t *code; |
|
1277 |
+ const uint8_t *code; |
|
1278 | 1278 |
unsigned int xsjs = 0; |
1279 | 1279 |
|
1280 | 1280 |
if(exe_sections[0].rsz > CLI_MAX_ALLOCATION) break; |
... | ... |
@@ -1367,10 +1368,11 @@ int cli_scanpe(cli_ctx *ctx) |
1367 | 1367 |
/* MEW support */ |
1368 | 1368 |
if (found && (DCONF & PE_CONF_MEW) && epsize>=16 && epbuff[0]=='\xe9') { |
1369 | 1369 |
uint32_t fileoffset; |
1370 |
- char *tbuff; |
|
1370 |
+ const char *tbuff; |
|
1371 | 1371 |
|
1372 | 1372 |
fileoffset = (vep + cli_readint32(epbuff + 1) + 5); |
1373 | 1373 |
while (fileoffset == 0x154 || fileoffset == 0x158) { |
1374 |
+ char *src; |
|
1374 | 1375 |
uint32_t offdiff, uselzma; |
1375 | 1376 |
|
1376 | 1377 |
cli_dbgmsg ("MEW: found MEW characteristics %08X + %08X + 5 = %08X\n", |
... | ... |
@@ -1543,7 +1545,8 @@ int cli_scanpe(cli_ctx *ctx) |
1543 | 1543 |
} |
1544 | 1544 |
|
1545 | 1545 |
|
1546 |
- while(found && (DCONF & PE_CONF_FSG) && epbuff[0] == '\x87' && epbuff[1] == '\x25') { |
|
1546 |
+ while(found && (DCONF & PE_CONF_FSG) && epbuff[0] == '\x87' && epbuff[1] == '\x25') { |
|
1547 |
+ const char *dst; |
|
1547 | 1548 |
|
1548 | 1549 |
/* FSG v2.0 support - thanks to aCaB ! */ |
1549 | 1550 |
|
... | ... |
@@ -1572,28 +1575,28 @@ int cli_scanpe(cli_ctx *ctx) |
1572 | 1572 |
return CL_ESEEK; |
1573 | 1573 |
} |
1574 | 1574 |
|
1575 |
- dest = src + newedx - exe_sections[i + 1].rva; |
|
1576 |
- if(newedx < exe_sections[i + 1].rva || !CLI_ISCONTAINED(src, ssize, dest, 4)) { |
|
1575 |
+ dst = src + newedx - exe_sections[i + 1].rva; |
|
1576 |
+ if(newedx < exe_sections[i + 1].rva || !CLI_ISCONTAINED(src, ssize, dst, 4)) { |
|
1577 | 1577 |
cli_dbgmsg("FSG: New ESP out of bounds\n"); |
1578 | 1578 |
break; |
1579 | 1579 |
} |
1580 | 1580 |
|
1581 |
- newedx = cli_readint32(dest) - EC32(optional_hdr32.ImageBase); |
|
1581 |
+ newedx = cli_readint32(dst) - EC32(optional_hdr32.ImageBase); |
|
1582 | 1582 |
if(!CLI_ISCONTAINED(exe_sections[i + 1].rva, exe_sections[i + 1].rsz, newedx, 4)) { |
1583 | 1583 |
cli_dbgmsg("FSG: New ESP (%x) is wrong\n", newedx); |
1584 | 1584 |
break; |
1585 | 1585 |
} |
1586 | 1586 |
|
1587 |
- dest = src + newedx - exe_sections[i + 1].rva; |
|
1588 |
- if(!CLI_ISCONTAINED(src, ssize, dest, 32)) { |
|
1587 |
+ dst = src + newedx - exe_sections[i + 1].rva; |
|
1588 |
+ if(!CLI_ISCONTAINED(src, ssize, dst, 32)) { |
|
1589 | 1589 |
cli_dbgmsg("FSG: New stack out of bounds\n"); |
1590 | 1590 |
break; |
1591 | 1591 |
} |
1592 | 1592 |
|
1593 |
- newedi = cli_readint32(dest) - EC32(optional_hdr32.ImageBase); |
|
1594 |
- newesi = cli_readint32(dest + 4) - EC32(optional_hdr32.ImageBase); |
|
1595 |
- newebx = cli_readint32(dest + 16) - EC32(optional_hdr32.ImageBase); |
|
1596 |
- newedx = cli_readint32(dest + 20); |
|
1593 |
+ newedi = cli_readint32(dst) - EC32(optional_hdr32.ImageBase); |
|
1594 |
+ newesi = cli_readint32(dst + 4) - EC32(optional_hdr32.ImageBase); |
|
1595 |
+ newebx = cli_readint32(dst + 16) - EC32(optional_hdr32.ImageBase); |
|
1596 |
+ newedx = cli_readint32(dst + 20); |
|
1597 | 1597 |
|
1598 | 1598 |
if(newedi != exe_sections[i].rva) { |
1599 | 1599 |
cli_dbgmsg("FSG: Bad destination buffer (edi is %x should be %x)\n", newedi, exe_sections[i].rva); |
... | ... |
@@ -1615,7 +1618,6 @@ int cli_scanpe(cli_ctx *ctx) |
1615 | 1615 |
|
1616 | 1616 |
if((dest = (char *) cli_calloc(dsize, sizeof(char))) == NULL) { |
1617 | 1617 |
free(exe_sections); |
1618 |
- free(src); |
|
1619 | 1618 |
return CL_EMEM; |
1620 | 1619 |
} |
1621 | 1620 |
|
... | ... |
@@ -1630,7 +1632,7 @@ int cli_scanpe(cli_ctx *ctx) |
1630 | 1630 |
/* FSG support - v. 1.33 (thx trog for the many samples) */ |
1631 | 1631 |
|
1632 | 1632 |
int sectcnt = 0; |
1633 |
- char *support; |
|
1633 |
+ const char *support; |
|
1634 | 1634 |
uint32_t newesi, newedi, oldep, gp, t; |
1635 | 1635 |
struct cli_exe_section *sections; |
1636 | 1636 |
|
... | ... |
@@ -1733,7 +1735,7 @@ int cli_scanpe(cli_ctx *ctx) |
1733 | 1733 |
|
1734 | 1734 |
int sectcnt = 0; |
1735 | 1735 |
uint32_t gp, t = cli_rawaddr(cli_readint32(epbuff+1) - EC32(optional_hdr32.ImageBase), NULL, 0 , &err, fsize, hdr_size); |
1736 |
- char *support; |
|
1736 |
+ const char *support; |
|
1737 | 1737 |
uint32_t newesi = cli_readint32(epbuff+11) - EC32(optional_hdr32.ImageBase); |
1738 | 1738 |
uint32_t newedi = cli_readint32(epbuff+6) - EC32(optional_hdr32.ImageBase); |
1739 | 1739 |
uint32_t oldep = vep - exe_sections[i + 1].rva; |
... | ... |
@@ -2124,6 +2126,7 @@ int cli_scanpe(cli_ctx *ctx) |
2124 | 2124 |
memcmp(epbuff+0x68, "\xe8\x00\x00\x00\x00\x58\x2d\x6d\x00\x00\x00\x50\x60\x33\xc9\x50\x58\x50\x50", 19) == 0) { |
2125 | 2125 |
uint32_t head = exe_sections[nsections - 1].raw; |
2126 | 2126 |
uint8_t *packer; |
2127 |
+ char *src; |
|
2127 | 2128 |
|
2128 | 2129 |
ssize = 0; |
2129 | 2130 |
for(i=0 ; ; i++) { |
... | ... |
@@ -2178,6 +2181,7 @@ int cli_scanpe(cli_ctx *ctx) |
2178 | 2178 |
|
2179 | 2179 |
/* ASPACK support */ |
2180 | 2180 |
while((DCONF & PE_CONF_ASPACK) && ep+58+0x70e < fsize && !memcmp(epbuff,"\x60\xe8\x03\x00\x00\x00\xe9\xeb",8)) { |
2181 |
+ char *src; |
|
2181 | 2182 |
|
2182 | 2183 |
if(epsize<0x3bf || memcmp(epbuff+0x3b9, "\x68\x00\x00\x00\x00\xc3",6)) break; |
2183 | 2184 |
ssize = 0; |
... | ... |
@@ -2214,7 +2218,7 @@ int cli_scanpe(cli_ctx *ctx) |
2214 | 2214 |
uint32_t eprva = vep; |
2215 | 2215 |
uint32_t start_of_stuff, rep = ep; |
2216 | 2216 |
unsigned int nowinldr; |
2217 |
- char *nbuff; |
|
2217 |
+ const char *nbuff; |
|
2218 | 2218 |
|
2219 | 2219 |
src=epbuff; |
2220 | 2220 |
if (*epbuff=='\xe9') { /* bitched headers */ |
... | ... |
@@ -2471,7 +2475,7 @@ int cli_peheader(fmap_t *map, struct cli_exe_info *peinfo) |
2471 | 2471 |
|
2472 | 2472 |
while(dirs[2].Size) { |
2473 | 2473 |
struct vinfo_list vlist; |
2474 |
- uint8_t *vptr, *baseptr; |
|
2474 |
+ const uint8_t *vptr, *baseptr; |
|
2475 | 2475 |
uint32_t rva, res_sz; |
2476 | 2476 |
|
2477 | 2477 |
memset(&vlist, 0, sizeof(vlist)); |
... | ... |
@@ -2555,7 +2559,7 @@ int cli_peheader(fmap_t *map, struct cli_exe_info *peinfo) |
2555 | 2555 |
|
2556 | 2556 |
while(sfi_sz > 6) { /* enum all stringtables - RESUMABLE */ |
2557 | 2557 |
uint32_t st_sz = cli_readint32(vptr) & 0xffff; |
2558 |
- uint8_t *next_vptr = vptr + st_sz; |
|
2558 |
+ const uint8_t *next_vptr = vptr + st_sz; |
|
2559 | 2559 |
uint32_t next_sfi_sz = sfi_sz - st_sz; |
2560 | 2560 |
|
2561 | 2561 |
if(st_sz > sfi_sz || st_sz <= 24) { |
... | ... |
@@ -88,7 +88,7 @@ int cli_scanicon(icon_groupset *set, uint32_t resdir_rva, cli_ctx *ctx, struct c |
88 | 88 |
findres(14, 0xffffffff, resdir_rva, map, exe_sections, nsections, hdr_size, groupicon_cb, &gicons); |
89 | 89 |
|
90 | 90 |
for(curicon=0; curicon<gicons.cnt; curicon++) { |
91 |
- uint8_t *grp = fmap_need_off_once(map, cli_rawaddr(gicons.rvas[curicon], exe_sections, nsections, &err, map->len, hdr_size), 16); |
|
91 |
+ const uint8_t *grp = fmap_need_off_once(map, cli_rawaddr(gicons.rvas[curicon], exe_sections, nsections, &err, map->len, hdr_size), 16); |
|
92 | 92 |
if(grp && !err) { |
93 | 93 |
uint32_t gsz = cli_readint32(grp + 4); |
94 | 94 |
if(gsz>6) { |
... | ... |
@@ -1192,9 +1192,10 @@ static int parseicon(icon_groupset *set, uint32_t rva, cli_ctx *ctx, struct cli_ |
1192 | 1192 |
unsigned int important; |
1193 | 1193 |
} bmphdr; |
1194 | 1194 |
struct icomtr metrics; |
1195 |
- unsigned char *rawimage; |
|
1195 |
+ const unsigned char *rawimage; |
|
1196 | 1196 |
const char *tempd; |
1197 |
- uint32_t *palette = NULL, *imagedata; |
|
1197 |
+ const uint32_t *palette = NULL; |
|
1198 |
+ uint32_t *imagedata; |
|
1198 | 1199 |
unsigned int scanlinesz, andlinesz; |
1199 | 1200 |
unsigned int width, height, depth, x, y; |
1200 | 1201 |
unsigned int err, scalemode = 2, enginesize; |
... | ... |
@@ -1210,12 +1211,12 @@ static int parseicon(icon_groupset *set, uint32_t rva, cli_ctx *ctx, struct cli_ |
1210 | 1210 |
icoff = cli_rawaddr(rva, exe_sections, nsections, &err, map->len, hdr_size); |
1211 | 1211 |
|
1212 | 1212 |
/* read the bitmap header */ |
1213 |
- if(err || !(imagedata = fmap_need_off_once(map, icoff, 4))) { |
|
1213 |
+ if(err || !(rawimage = fmap_need_off_once(map, icoff, 4))) { |
|
1214 | 1214 |
cli_dbgmsg("parseicon: offset to icon is out of file\n"); |
1215 | 1215 |
return CL_SUCCESS; |
1216 | 1216 |
} |
1217 | 1217 |
|
1218 |
- rva = cli_readint32(imagedata); |
|
1218 |
+ rva = cli_readint32(rawimage); |
|
1219 | 1219 |
icoff = cli_rawaddr(rva, exe_sections, nsections, &err, map->len, hdr_size); |
1220 | 1220 |
if(err || fmap_readn(map, &bmphdr, icoff, sizeof(bmphdr)) != sizeof(bmphdr)) { |
1221 | 1221 |
cli_dbgmsg("parseicon: bmp header is out of file\n"); |
... | ... |
@@ -488,7 +488,7 @@ static int cli_scangzip(cli_ctx *ctx) |
488 | 488 |
|
489 | 489 |
while (at < map->len) { |
490 | 490 |
unsigned int bytes = MIN(map->len - at, map->pgsz); |
491 |
- if(!(z.next_in = fmap_need_off_once(map, at, bytes))) { |
|
491 |
+ if(!(z.next_in = (void*)fmap_need_off_once(map, at, bytes))) { |
|
492 | 492 |
cli_dbgmsg("GZip: Can't read %u bytes @ %lu.\n", bytes, (long unsigned)at); |
493 | 493 |
inflateEnd(&z); |
494 | 494 |
close(fd); |
... | ... |
@@ -1050,7 +1050,7 @@ static int cli_scanhtml(cli_ctx *ctx) |
1050 | 1050 |
|
1051 | 1051 |
static int cli_scanscript(cli_ctx *ctx) |
1052 | 1052 |
{ |
1053 |
- unsigned char *buff; |
|
1053 |
+ const unsigned char *buff; |
|
1054 | 1054 |
unsigned char* normalized; |
1055 | 1055 |
struct text_norm_state state; |
1056 | 1056 |
char *tmpname = NULL; |
... | ... |
@@ -1147,7 +1147,8 @@ static int cli_scanscript(cli_ctx *ctx) |
1147 | 1147 |
|
1148 | 1148 |
static int cli_scanhtml_utf16(cli_ctx *ctx) |
1149 | 1149 |
{ |
1150 |
- char *tempname, *decoded, *buff; |
|
1150 |
+ char *tempname, *decoded; |
|
1151 |
+ const char *buff; |
|
1151 | 1152 |
int ret = CL_CLEAN, fd, bytes; |
1152 | 1153 |
size_t at = 0; |
1153 | 1154 |
fmap_t *map = *ctx->fmap; |
... | ... |
@@ -1640,7 +1641,7 @@ static int cli_scanembpe(cli_ctx *ctx, off_t offset) |
1640 | 1640 |
{ |
1641 | 1641 |
int fd, bytes, ret = CL_CLEAN; |
1642 | 1642 |
unsigned long int size = 0, todo; |
1643 |
- char *buff; |
|
1643 |
+ const char *buff; |
|
1644 | 1644 |
char *tmpname; |
1645 | 1645 |
fmap_t *map = *ctx->fmap; |
1646 | 1646 |
unsigned int corrupted_input; |
... | ... |
@@ -2261,7 +2262,7 @@ static int magic_scandesc(cli_ctx *ctx, cli_file_t type) |
2261 | 2261 |
break; |
2262 | 2262 |
} |
2263 | 2263 |
do { |
2264 |
- char *b; |
|
2264 |
+ const char *b; |
|
2265 | 2265 |
|
2266 | 2266 |
len = 0; |
2267 | 2267 |
b = fmap_need_off_once_len(*ctx->fmap, pos, BUFSIZ, &len); |
... | ... |
@@ -120,12 +120,12 @@ nsp1:00435A5A push 8000h |
120 | 120 |
|
121 | 121 |
|
122 | 122 |
/* real_unpack(start_of_stuff, dest, malloc, free); */ |
123 |
-uint32_t unspack(char *start_of_stuff, char *dest, cli_ctx *ctx, uint32_t rva, uint32_t base, uint32_t ep, int file) { |
|
123 |
+uint32_t unspack(const char *start_of_stuff, char *dest, cli_ctx *ctx, uint32_t rva, uint32_t base, uint32_t ep, int file) { |
|
124 | 124 |
uint8_t c = *start_of_stuff; |
125 | 125 |
uint32_t i,firstbyte,tre,allocsz,tablesz,dsize,ssize; |
126 | 126 |
uint16_t *table; |
127 | 127 |
char *dst = dest; |
128 |
- char *src = start_of_stuff+0xd; |
|
128 |
+ const char *src = start_of_stuff+0xd; |
|
129 | 129 |
struct cli_exe_section section; |
130 | 130 |
|
131 | 131 |
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 |
170 | 170 |
} |
171 | 171 |
|
172 | 172 |
|
173 |
-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) { |
|
173 |
+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) { |
|
174 | 174 |
struct UNSP read_struct; |
175 | 175 |
uint32_t i = (0x300<<((allocsz+tre)&0xff)) + 0x736; |
176 | 176 |
|
... | ... |
@@ -25,8 +25,8 @@ |
25 | 25 |
#include "others.h" |
26 | 26 |
|
27 | 27 |
struct UNSP { |
28 |
- char *src_curr; |
|
29 |
- char *src_end; |
|
28 |
+ const char *src_curr; |
|
29 |
+ const char *src_end; |
|
30 | 30 |
uint32_t bitmap; |
31 | 31 |
uint32_t oldval; |
32 | 32 |
int error; |
... | ... |
@@ -35,8 +35,8 @@ struct UNSP { |
35 | 35 |
char *table; |
36 | 36 |
}; |
37 | 37 |
|
38 |
-uint32_t unspack(char *, char *, cli_ctx *, uint32_t, uint32_t, uint32_t, int); |
|
39 |
-uint32_t very_real_unpack(uint16_t *, uint32_t, uint32_t, uint32_t, uint32_t, char *, uint32_t, char *, uint32_t); |
|
38 |
+uint32_t unspack(const char *, char *, cli_ctx *, uint32_t, uint32_t, uint32_t, int); |
|
39 |
+uint32_t very_real_unpack(uint16_t *, uint32_t, uint32_t, uint32_t, uint32_t,const char *, uint32_t, char *, uint32_t); |
|
40 | 40 |
uint32_t get_byte(struct UNSP *); |
41 | 41 |
int getbit_from_table(uint16_t *, struct UNSP *); |
42 | 42 |
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) { |
56 | 56 |
return inflateInit2(a, b); |
57 | 57 |
} |
58 | 58 |
|
59 |
-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) { |
|
59 |
+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) { |
|
60 | 60 |
char name[1024], obuf[BUFSIZ]; |
61 | 61 |
char *tempfile = name; |
62 | 62 |
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 |
134 | 134 |
|
135 | 135 |
memset(&strm, 0, sizeof(strm)); |
136 | 136 |
|
137 |
- *next_in = src; |
|
137 |
+ *next_in = (void*) src; |
|
138 | 138 |
*next_out = obuf; |
139 | 139 |
*avail_in = csize; |
140 | 140 |
*avail_out = sizeof(obuf); |
... | ... |
@@ -216,7 +216,7 @@ static int unz(uint8_t *src, uint32_t csize, uint32_t usize, uint16_t method, ui |
216 | 216 |
|
217 | 217 |
case ALG_IMPLODE: { |
218 | 218 |
struct xplstate strm; |
219 |
- strm.next_in = src; |
|
219 |
+ strm.next_in = (void*)src; |
|
220 | 220 |
strm.next_out = (uint8_t *)obuf; |
221 | 221 |
strm.avail_in = csize; |
222 | 222 |
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 |
297 | 297 |
return ret; |
298 | 298 |
} |
299 | 299 |
|
300 |
-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) { |
|
301 |
- uint8_t *lh, *zip; |
|
300 |
+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) { |
|
301 |
+ const uint8_t *lh, *zip; |
|
302 | 302 |
char name[256]; |
303 | 303 |
uint32_t csize, usize; |
304 | 304 |
|
... | ... |
@@ -323,7 +323,7 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int |
323 | 323 |
} |
324 | 324 |
if(ctx->engine->cdb || cli_debug_flag) { |
325 | 325 |
uint32_t nsize = (LH_flen>=sizeof(name))?sizeof(name)-1:LH_flen; |
326 |
- char *src; |
|
326 |
+ const char *src; |
|
327 | 327 |
if(nsize && (src = fmap_need_ptr_once(map, zip, nsize))) { |
328 | 328 |
memcpy(name, zip, nsize); |
329 | 329 |
name[nsize]='\0'; |
... | ... |
@@ -416,7 +416,7 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int |
416 | 416 |
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) { |
417 | 417 |
char name[256]; |
418 | 418 |
int last = 0; |
419 |
- uint8_t *ch; |
|
419 |
+ const uint8_t *ch; |
|
420 | 420 |
|
421 | 421 |
if(!(ch = fmap_need_off(map, coff, SIZEOF_CH)) || CH_magic != 0x02014b50) { |
422 | 422 |
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 |
433 | 433 |
} |
434 | 434 |
if(cli_debug_flag && !last) { |
435 | 435 |
unsigned int size = (CH_flen>=sizeof(name))?sizeof(name)-1:CH_flen; |
436 |
- char *src = fmap_need_off_once(map, coff, size); |
|
436 |
+ const char *src = fmap_need_off_once(map, coff, size); |
|
437 | 437 |
if(src) { |
438 | 438 |
memcpy(name, src, size); |
439 | 439 |
name[size]='\0'; |
... | ... |
@@ -467,7 +467,8 @@ int cli_unzip(cli_ctx *ctx) { |
467 | 467 |
int ret=CL_CLEAN; |
468 | 468 |
uint32_t fsize, lhoff = 0, coff = 0; |
469 | 469 |
fmap_t *map = *ctx->fmap; |
470 |
- char *tmpd, *ptr; |
|
470 |
+ char *tmpd; |
|
471 |
+ const char *ptr; |
|
471 | 472 |
|
472 | 473 |
cli_dbgmsg("in cli_unzip\n"); |
473 | 474 |
fsize = (uint32_t)map->len; |
... | ... |
@@ -116,7 +116,7 @@ static char *checkpe(char *dst, uint32_t dsize, char *pehdr, uint32_t *valign, u |
116 | 116 |
|
117 | 117 |
/* PE from UPX */ |
118 | 118 |
|
119 |
-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) |
|
119 |
+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) |
|
120 | 120 |
{ |
121 | 121 |
char *imports, *sections=NULL, *pehdr=NULL, *newbuf; |
122 | 122 |
unsigned int sectcnt=0, upd=1; |
... | ... |
@@ -259,7 +259,7 @@ static int pefromupx (char *src, uint32_t ssize, char *dst, uint32_t *dsize, uin |
259 | 259 |
|
260 | 260 |
/* [doubleebx] */ |
261 | 261 |
|
262 |
-static int doubleebx(char *src, uint32_t *myebx, uint32_t *scur, uint32_t ssize) |
|
262 |
+static int doubleebx(const char *src, uint32_t *myebx, uint32_t *scur, uint32_t ssize) |
|
263 | 263 |
{ |
264 | 264 |
uint32_t oldebx = *myebx; |
265 | 265 |
|
... | ... |
@@ -276,7 +276,7 @@ static int doubleebx(char *src, uint32_t *myebx, uint32_t *scur, uint32_t ssize) |
276 | 276 |
|
277 | 277 |
/* [inflate] */ |
278 | 278 |
|
279 |
-int upx_inflate2b(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep) |
|
279 |
+int upx_inflate2b(const char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep) |
|
280 | 280 |
{ |
281 | 281 |
int32_t backbytes, unp_offset = -1; |
282 | 282 |
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_ |
351 | 351 |
return pefromupx (src, ssize, dst, dsize, ep, upx0, upx1, magic, dcur); |
352 | 352 |
} |
353 | 353 |
|
354 |
-int upx_inflate2d(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep) |
|
354 |
+int upx_inflate2d(const char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep) |
|
355 | 355 |
{ |
356 | 356 |
int32_t backbytes, unp_offset = -1; |
357 | 357 |
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_ |
433 | 433 |
return pefromupx (src, ssize, dst, dsize, ep, upx0, upx1, magic, dcur); |
434 | 434 |
} |
435 | 435 |
|
436 |
-int upx_inflate2e(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep) |
|
436 |
+int upx_inflate2e(const char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep) |
|
437 | 437 |
{ |
438 | 438 |
int32_t backbytes, unp_offset = -1; |
439 | 439 |
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_ |
522 | 522 |
return pefromupx (src, ssize, dst, dsize, ep, upx0, upx1, magic, dcur); |
523 | 523 |
} |
524 | 524 |
|
525 |
-int upx_inflatelzma(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep) { |
|
525 |
+int upx_inflatelzma(const char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep) { |
|
526 | 526 |
struct CLI_LZMA l; |
527 | 527 |
uint32_t magic[]={0xb16,0xb1e,0}; |
528 | 528 |
unsigned char fake_lzmahdr[5]; |
... | ... |
@@ -23,9 +23,9 @@ |
23 | 23 |
|
24 | 24 |
#include "cltypes.h" |
25 | 25 |
|
26 |
-int upx_inflate2b(char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t); |
|
27 |
-int upx_inflate2d(char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t); |
|
28 |
-int upx_inflate2e(char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t); |
|
29 |
-int upx_inflatelzma(char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t); |
|
26 |
+int upx_inflate2b(const char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t); |
|
27 |
+int upx_inflate2d(const char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t); |
|
28 |
+int upx_inflate2e(const char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t); |
|
29 |
+int upx_inflatelzma(const char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t); |
|
30 | 30 |
|
31 | 31 |
#endif |