git-svn: trunk@2031
Tomasz Kojm authored on 2006/06/18 06:00:44... | ... |
@@ -57,7 +57,11 @@ int cli_untgz(int fd, const char *destdir) |
57 | 57 |
return -1; |
58 | 58 |
} |
59 | 59 |
|
60 |
- fullname = (char *) calloc(sizeof(char), strlen(destdir) + 100 + 5); |
|
60 |
+ fullname = (char *) cli_calloc(sizeof(char), strlen(destdir) + 100 + 5); |
|
61 |
+ if(!fullname) { |
|
62 |
+ cli_errmsg("cli_untgz: Can't allocate memory for fullname\n"); |
|
63 |
+ return -1; |
|
64 |
+ } |
|
61 | 65 |
|
62 | 66 |
while(1) { |
63 | 67 |
|
... | ... |
@@ -175,6 +179,10 @@ struct cl_cvd *cl_cvdparse(const char *head) |
175 | 175 |
} |
176 | 176 |
|
177 | 177 |
cvd = (struct cl_cvd *) cli_calloc(1, sizeof(struct cl_cvd)); |
178 |
+ if(!cvd) { |
|
179 |
+ cli_errmsg("cl_cvdparse: Can't allocate memory for cvd\n"); |
|
180 |
+ return NULL; |
|
181 |
+ } |
|
178 | 182 |
|
179 | 183 |
if(!(cvd->time = cli_strtok(head, 1, ":"))) { |
180 | 184 |
cli_errmsg("CVD -> Can't extract time from header.\n"); |
... | ... |
@@ -75,17 +75,26 @@ static char *cli_decodesig(const char *sig, int plainlen, mpz_t e, mpz_t n) |
75 | 75 |
mpz_init(c); |
76 | 76 |
|
77 | 77 |
for(i = 0; i < siglen; i++) { |
78 |
- if((dec = cli_ndecode(sig[i])) < 0) |
|
78 |
+ if((dec = cli_ndecode(sig[i])) < 0) { |
|
79 |
+ mpz_clear(r); |
|
80 |
+ mpz_clear(c); |
|
79 | 81 |
return NULL; |
82 |
+ } |
|
80 | 83 |
|
81 | 84 |
mpz_set_ui(r, dec); |
82 | 85 |
mpz_mul_2exp(r, r, 6 * i); |
83 | 86 |
mpz_add(c, c, r); |
84 | 87 |
} |
85 | 88 |
|
86 |
- mpz_init(p); |
|
87 |
- decoded = (char *) calloc(plainlen + 1, sizeof(char)); |
|
89 |
+ decoded = (char *) cli_calloc(plainlen + 1, sizeof(char)); |
|
90 |
+ if(!decoded) { |
|
91 |
+ cli_errmsg("cli_decodesig: Can't allocate memory\n"); |
|
92 |
+ mpz_clear(r); |
|
93 |
+ mpz_clear(c); |
|
94 |
+ return NULL; |
|
95 |
+ } |
|
88 | 96 |
|
97 |
+ mpz_init(p); |
|
89 | 98 |
mpz_powm(p, c, e, n); /* plain = cipher^e mod n */ |
90 | 99 |
mpz_clear(c); |
91 | 100 |
|
... | ... |
@@ -191,7 +191,7 @@ int cli_scanelf(int desc, cli_ctx *ctx) |
191 | 191 |
|
192 | 192 |
shoff = EC32(file_hdr.e_shoff); |
193 | 193 |
cli_dbgmsg("ELF: Section header table offset: %d\n", shoff); |
194 |
- if(lseek(desc, shoff, SEEK_SET) != shoff) { |
|
194 |
+ if((uint32_t) lseek(desc, shoff, SEEK_SET) != shoff) { |
|
195 | 195 |
/* Possibly broken end of file */ |
196 | 196 |
if(DETECT_BROKEN) { |
197 | 197 |
if(ctx->virname) |
... | ... |
@@ -353,7 +353,7 @@ int cli_elfheader(int desc, struct cli_exe_info *elfinfo) |
353 | 353 |
} |
354 | 354 |
|
355 | 355 |
shoff = EC32(file_hdr.e_shoff); |
356 |
- if(lseek(desc, shoff, SEEK_SET) != shoff) { |
|
356 |
+ if((uint32_t) lseek(desc, shoff, SEEK_SET) != shoff) { |
|
357 | 357 |
/* Possibly broken end of file */ |
358 | 358 |
return -1; |
359 | 359 |
} |
... | ... |
@@ -227,7 +227,7 @@ cli_file_t cli_filetype(const char *buf, size_t buflen) |
227 | 227 |
return ascii ? CL_TYPE_UNKNOWN_TEXT : CL_TYPE_UNKNOWN_DATA; |
228 | 228 |
} |
229 | 229 |
|
230 |
-int is_tar(unsigned char *buf, int nbytes); |
|
230 |
+int is_tar(unsigned char *buf, unsigned int nbytes); |
|
231 | 231 |
|
232 | 232 |
cli_file_t cli_filetype2(int desc) |
233 | 233 |
{ |
... | ... |
@@ -5,7 +5,7 @@ |
5 | 5 |
* Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu). |
6 | 6 |
* |
7 | 7 |
* @(#)list.c 1.18 9/23/86 Public Domain - gnu |
8 |
- * $Id: is_tar.c,v 1.1 2005/03/22 21:26:25 kojm Exp $ |
|
8 |
+ * $Id: is_tar.c,v 1.2 2006/06/17 21:00:44 tkojm Exp $ |
|
9 | 9 |
* |
10 | 10 |
* Comments changed and some code/comments reformatted |
11 | 11 |
* for file command by Ian Darwin. |
... | ... |
@@ -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, int nbytes) |
|
35 |
+int is_tar(unsigned char *buf, unsigned int nbytes) |
|
36 | 36 |
{ |
37 | 37 |
union record *header = (union record *)buf; |
38 | 38 |
int i; |
... | ... |
@@ -294,7 +294,7 @@ int cli_ac_scanbuff(const char *buffer, unsigned int length, const char **virnam |
294 | 294 |
else |
295 | 295 |
t = ftype; |
296 | 296 |
|
297 |
- if((fd == -1 && !t) || !cli_validatesig(pt->target, t, pt->offset, offset + position, fd, pt->virname)) { |
|
297 |
+ if((fd == -1 && !t) || !cli_validatesig(t, pt->offset, offset + position, fd, pt->virname)) { |
|
298 | 298 |
pt = pt->next; |
299 | 299 |
continue; |
300 | 300 |
} |
... | ... |
@@ -190,7 +190,7 @@ int cli_bm_scanbuff(const char *buffer, unsigned int length, const char **virnam |
190 | 190 |
if(p->target || p->offset) { |
191 | 191 |
off = offset + i - BM_MIN_LENGTH + BM_BLOCK_SIZE; |
192 | 192 |
|
193 |
- if((fd == -1 && !ftype) || !cli_validatesig(p->target, ftype, p->offset, off, fd, p->virname)) { |
|
193 |
+ if((fd == -1 && !ftype) || !cli_validatesig(ftype, p->offset, off, fd, p->virname)) { |
|
194 | 194 |
p = p->next; |
195 | 195 |
continue; |
196 | 196 |
} |
... | ... |
@@ -395,7 +395,7 @@ static int cli_checkfp(int fd, const struct cl_engine *engine) |
395 | 395 |
return 0; |
396 | 396 |
} |
397 | 397 |
|
398 |
-int cli_validatesig(unsigned short target, unsigned short ftype, const char *offstr, unsigned long int fileoff, int desc, const char *virname) |
|
398 |
+int cli_validatesig(unsigned short ftype, const char *offstr, unsigned long int fileoff, int desc, const char *virname) |
|
399 | 399 |
{ |
400 | 400 |
|
401 | 401 |
if(offstr && desc != -1) { |
... | ... |
@@ -30,6 +30,6 @@ int cli_scandesc(int desc, cli_ctx *ctx, unsigned short otfrec, unsigned short f |
30 | 30 |
|
31 | 31 |
int cli_scanbuff(const char *buffer, unsigned int length, const char **virname, const struct cl_engine *engine, unsigned short ftype); |
32 | 32 |
|
33 |
-int cli_validatesig(unsigned short target, unsigned short ftype, const char *offstr, unsigned long int fileoff, int desc, const char *virname); |
|
33 |
+int cli_validatesig(unsigned short ftype, const char *offstr, unsigned long int fileoff, int desc, const char *virname); |
|
34 | 34 |
|
35 | 35 |
#endif |
... | ... |
@@ -115,7 +115,7 @@ static struct mspack_file *msp_open(struct mspack_system *this, |
115 | 115 |
default: return NULL; |
116 | 116 |
} |
117 | 117 |
|
118 |
- if ((fh = malloc(sizeof(struct mspack_file_p)))) { |
|
118 |
+ if ((fh = cli_malloc(sizeof(struct mspack_file_p)))) { |
|
119 | 119 |
fh->name = filename; |
120 | 120 |
fh->desc = 0; |
121 | 121 |
if ((fh->fh = fopen(filename, fmode))) return (struct mspack_file *) fh; |
... | ... |
@@ -138,7 +138,7 @@ static struct mspack_file *msp_dopen(struct mspack_system *this, |
138 | 138 |
default: return NULL; |
139 | 139 |
} |
140 | 140 |
|
141 |
- if ((fh = malloc(sizeof(struct mspack_file_p)))) { |
|
141 |
+ if ((fh = cli_malloc(sizeof(struct mspack_file_p)))) { |
|
142 | 142 |
fh->name = "descriptor"; |
143 | 143 |
fh->desc = desc; |
144 | 144 |
if ((fh->fh = fdopen(desc, fmode))) return (struct mspack_file *) fh; |
... | ... |
@@ -213,7 +213,7 @@ static void msp_msg(struct mspack_file *file, char *format, ...) { |
213 | 213 |
static void *msp_alloc(struct mspack_system *this, size_t bytes) { |
214 | 214 |
#ifdef DEBUG |
215 | 215 |
/* make uninitialised data obvious */ |
216 |
- char *buf = malloc(bytes + 8); |
|
216 |
+ char *buf = cli_malloc(bytes + 8); |
|
217 | 217 |
if (buf) memset(buf, 0xDC, bytes); |
218 | 218 |
*((size_t *)buf) = bytes; |
219 | 219 |
return &buf[8]; |
... | ... |
@@ -1641,7 +1641,7 @@ int cli_scanpe(int desc, cli_ctx *ctx) |
1641 | 1641 |
} |
1642 | 1642 |
|
1643 | 1643 |
lseek(desc, 0, SEEK_SET); |
1644 |
- if(read(desc, spinned, fsize) != fsize) { |
|
1644 |
+ if((size_t) read(desc, spinned, fsize) != fsize) { |
|
1645 | 1645 |
cli_dbgmsg("PESpin: Can't read %d bytes\n", fsize); |
1646 | 1646 |
free(spinned); |
1647 | 1647 |
free(section_hdr); |
... | ... |
@@ -1707,7 +1707,7 @@ int cli_scanpe(int desc, cli_ctx *ctx) |
1707 | 1707 |
} |
1708 | 1708 |
|
1709 | 1709 |
lseek(desc, 0, SEEK_SET); |
1710 |
- if(read(desc, spinned, fsize) != fsize) { |
|
1710 |
+ if((size_t) read(desc, spinned, fsize) != fsize) { |
|
1711 | 1711 |
cli_dbgmsg("yC: Can't read %d bytes\n", fsize); |
1712 | 1712 |
free(spinned); |
1713 | 1713 |
free(section_hdr); |
... | ... |
@@ -124,9 +124,9 @@ static int cli_ac_addsig(struct cli_matcher *root, const char *virname, const ch |
124 | 124 |
*start++ = 0; |
125 | 125 |
|
126 | 126 |
new->alt++; |
127 |
- new->altn = (unsigned short int *) realloc(new->altn, new->alt * sizeof(unsigned short int)); |
|
127 |
+ new->altn = (unsigned short int *) cli_realloc(new->altn, new->alt * sizeof(unsigned short int)); |
|
128 | 128 |
new->altn[new->alt - 1] = 0; |
129 |
- new->altc = (char **) realloc(new->altc, new->alt * sizeof(char *)); |
|
129 |
+ new->altc = (char **) cli_realloc(new->altc, new->alt * sizeof(char *)); |
|
130 | 130 |
new->altc[new->alt - 1] = NULL; |
131 | 131 |
|
132 | 132 |
for(i = 0; i < strlen(pt); i++) |
... | ... |
@@ -391,7 +391,7 @@ int cli_parse_add(struct cli_matcher *root, const char *virname, const char *hex |
391 | 391 |
} |
392 | 392 |
|
393 | 393 |
} else { |
394 |
- bm_new = (struct cli_bm_patt *) calloc(1, sizeof(struct cli_bm_patt)); |
|
394 |
+ bm_new = (struct cli_bm_patt *) cli_calloc(1, sizeof(struct cli_bm_patt)); |
|
395 | 395 |
if(!bm_new) |
396 | 396 |
return CL_EMEM; |
397 | 397 |
|
... | ... |
@@ -802,7 +802,7 @@ static int cli_loadhdb(FILE *fd, struct cl_engine **engine, unsigned int *signo, |
802 | 802 |
static int cli_loadmd(FILE *fd, struct cl_engine **engine, unsigned int *signo, int type, unsigned int options) |
803 | 803 |
{ |
804 | 804 |
char buffer[FILEBUFF], *pt; |
805 |
- int line = 0, comments = 0, ret = 0; |
|
805 |
+ int line = 0, comments = 0, ret = 0, crc32; |
|
806 | 806 |
struct cli_meta_node *new; |
807 | 807 |
|
808 | 808 |
|
... | ... |
@@ -892,11 +892,12 @@ static int cli_loadmd(FILE *fd, struct cl_engine **engine, unsigned int *signo, |
892 | 892 |
if(!strcmp(pt, "*")) { |
893 | 893 |
new->crc32 = 0; |
894 | 894 |
} else { |
895 |
- new->crc32 = cli_hex2num(pt); |
|
896 |
- if(new->crc32 == -1) { |
|
895 |
+ crc32 = cli_hex2num(pt); |
|
896 |
+ if(crc32 == -1) { |
|
897 | 897 |
ret = CL_EMALFDB; |
898 | 898 |
break; |
899 | 899 |
} |
900 |
+ new->crc32 = (unsigned int) crc32; |
|
900 | 901 |
} |
901 | 902 |
free(pt); |
902 | 903 |
} |
... | ... |
@@ -1249,7 +1250,7 @@ int cl_statinidir(const char *dirname, struct cl_stat *dbstat) |
1249 | 1249 |
fname = cli_calloc(strlen(dirname) + strlen(dent->d_name) + 2, sizeof(char)); |
1250 | 1250 |
sprintf(fname, "%s/%s", dirname, dent->d_name); |
1251 | 1251 |
#if defined(C_INTERIX) || defined(C_OS2) |
1252 |
- dbstat->statdname[dbstat->no - 1] = (char *) calloc(strlen(dent->d_name) + 1, sizeof(char)); |
|
1252 |
+ dbstat->statdname[dbstat->no - 1] = (char *) cli_calloc(strlen(dent->d_name) + 1, sizeof(char)); |
|
1253 | 1253 |
strcpy(dbstat->statdname[dbstat->no - 1], dent->d_name); |
1254 | 1254 |
#endif |
1255 | 1255 |
stat(fname, &dbstat->stattab[dbstat->no - 1]); |
... | ... |
@@ -330,16 +330,16 @@ static int cli_scanzip(int desc, cli_ctx *ctx, off_t sfx_offset, uint32_t *sfx_c |
330 | 330 |
if(mdata->encrypted != encrypted) |
331 | 331 |
continue; |
332 | 332 |
|
333 |
- if(mdata->crc32 && mdata->crc32 != (unsigned int) zdirent.d_crc32) |
|
333 |
+ if(mdata->crc32 && mdata->crc32 != zdirent.d_crc32) |
|
334 | 334 |
continue; |
335 | 335 |
|
336 |
- if(mdata->csize > 0 && mdata->csize != zdirent.d_csize) |
|
336 |
+ if(mdata->csize > 0 && (uint32_t) mdata->csize != zdirent.d_csize) |
|
337 | 337 |
continue; |
338 | 338 |
|
339 |
- if(mdata->size >= 0 && mdata->size != zdirent.st_size) |
|
339 |
+ if(mdata->size >= 0 && (uint32_t) mdata->size != zdirent.st_size) |
|
340 | 340 |
continue; |
341 | 341 |
|
342 |
- if(mdata->method >= 0 && mdata->method != (unsigned int) zdirent.d_compr) |
|
342 |
+ if(mdata->method >= 0 && (uint16_t) mdata->method != zdirent.d_compr) |
|
343 | 343 |
continue; |
344 | 344 |
|
345 | 345 |
if(mdata->fileno && mdata->fileno != files) |
... | ... |
@@ -373,8 +373,8 @@ static int cli_scanzip(int desc, cli_ctx *ctx, off_t sfx_offset, uint32_t *sfx_c |
373 | 373 |
continue; |
374 | 374 |
} |
375 | 375 |
|
376 |
- if(zdirent.d_csize <= 0 || zdirent.st_size < 0) { |
|
377 |
- cli_dbgmsg("Zip: Malformed archive detected.\n"); |
|
376 |
+ if(!zdirent.d_csize) { |
|
377 |
+ cli_dbgmsg("Zip: Malformed file (d_csize == 0 but st_size != 0)\n"); |
|
378 | 378 |
*ctx->virname = "Suspect.Zip"; |
379 | 379 |
ret = CL_VIRUS; |
380 | 380 |
break; |
... | ... |
@@ -1313,8 +1313,8 @@ static int cli_scanjpeg(int desc, const char **virname) |
1313 | 1313 |
|
1314 | 1314 |
static int cli_scancryptff(int desc, cli_ctx *ctx) |
1315 | 1315 |
{ |
1316 |
- int ret = CL_CLEAN, i, ndesc; |
|
1317 |
- unsigned int length; |
|
1316 |
+ int ret = CL_CLEAN, ndesc; |
|
1317 |
+ unsigned int length, i; |
|
1318 | 1318 |
unsigned char *src = NULL, *dest = NULL; |
1319 | 1319 |
char *tempfile; |
1320 | 1320 |
struct stat sb; |
... | ... |
@@ -73,7 +73,7 @@ static char *langcodes[] = { |
73 | 73 |
static char *sis_utf16_decode(const char *str, uint32_t length) |
74 | 74 |
{ |
75 | 75 |
char *decoded; |
76 |
- int i, j; |
|
76 |
+ uint32_t i, j; |
|
77 | 77 |
|
78 | 78 |
|
79 | 79 |
if(!length || length % 2) { |
... | ... |
@@ -305,7 +305,7 @@ static int sis_extract_simple(int fd, char *mfile, uint32_t length, uint32_t off |
305 | 305 |
return CL_EIO; |
306 | 306 |
} |
307 | 307 |
|
308 |
- if(cli_writen(desc, buff, filelen) != filelen) { |
|
308 |
+ if((uint32_t) cli_writen(desc, buff, filelen) != filelen) { |
|
309 | 309 |
cli_errmsg("SIS: sis_extract_simple: Can't write %d bytes to %s\n", filelen, fname); |
310 | 310 |
free(subdir); |
311 | 311 |
free(fname); |
... | ... |
@@ -241,7 +241,7 @@ static void *read_header(int fd, header_type hdr_type) |
241 | 241 |
case MAIN_HEAD: { |
242 | 242 |
main_header_t *main_hdr; |
243 | 243 |
|
244 |
- main_hdr = (main_header_t *) malloc(sizeof(main_header_t)); |
|
244 |
+ main_hdr = (main_header_t *) cli_malloc(sizeof(main_header_t)); |
|
245 | 245 |
if (!main_hdr) { |
246 | 246 |
return NULL; |
247 | 247 |
} |
... | ... |
@@ -257,7 +257,7 @@ static void *read_header(int fd, header_type hdr_type) |
257 | 257 |
case FILE_HEAD: { |
258 | 258 |
file_header_t *file_hdr; |
259 | 259 |
|
260 |
- file_hdr = (file_header_t *) malloc(sizeof(file_header_t)); |
|
260 |
+ file_hdr = (file_header_t *) cli_malloc(sizeof(file_header_t)); |
|
261 | 261 |
if (!file_hdr) { |
262 | 262 |
return NULL; |
263 | 263 |
} |
... | ... |
@@ -320,7 +320,7 @@ static file_header_t *read_block(int fd, header_type hdr_type) |
320 | 320 |
cli_dbgmsg("Pack Size: %u\n", file_header->pack_size); |
321 | 321 |
cli_dbgmsg("UnPack Version: 0x%.2x\n", file_header->unpack_ver); |
322 | 322 |
cli_dbgmsg("Pack Method: 0x%.2x\n", file_header->method); |
323 |
- file_header->filename = (unsigned char *) malloc(file_header->name_size+1); |
|
323 |
+ file_header->filename = (unsigned char *) cli_malloc(file_header->name_size+1); |
|
324 | 324 |
if (!file_header->filename) { |
325 | 325 |
free(file_header); |
326 | 326 |
return NULL; |
... | ... |
@@ -884,7 +884,7 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte, |
884 | 884 |
cli_dbgmsg("ERROR: vm_codesize=0x%x\n", vm_codesize); |
885 | 885 |
return FALSE; |
886 | 886 |
} |
887 |
- vm_code = (unsigned char *) malloc(vm_codesize); |
|
887 |
+ vm_code = (unsigned char *) cli_malloc(vm_codesize); |
|
888 | 888 |
for (i=0 ; i < vm_codesize ; i++) { |
889 | 889 |
vm_code[i] = rarvm_getbits(&rarvm_input) >> 8; |
890 | 890 |
rarvm_addbits(&rarvm_input, 8); |
... | ... |
@@ -898,13 +898,13 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte, |
898 | 898 |
|
899 | 899 |
static_size = filter->prg.static_size; |
900 | 900 |
if (static_size > 0 && static_size < VM_GLOBALMEMSIZE) { |
901 |
- stack_filter->prg.static_data = malloc(static_size); |
|
901 |
+ stack_filter->prg.static_data = cli_malloc(static_size); |
|
902 | 902 |
memcpy(stack_filter->prg.static_data, filter->prg.static_data, static_size); |
903 | 903 |
} |
904 | 904 |
|
905 | 905 |
if (stack_filter->prg.global_size < VM_FIXEDGLOBALSIZE) { |
906 | 906 |
free(stack_filter->prg.global_data); |
907 |
- stack_filter->prg.global_data = malloc(VM_FIXEDGLOBALSIZE); |
|
907 |
+ stack_filter->prg.global_data = cli_malloc(VM_FIXEDGLOBALSIZE); |
|
908 | 908 |
memset(stack_filter->prg.global_data, 0, VM_FIXEDGLOBALSIZE); |
909 | 909 |
stack_filter->prg.global_size = VM_FIXEDGLOBALSIZE; |
910 | 910 |
} |
... | ... |
@@ -958,7 +958,7 @@ static int read_vm_code(unpack_data_t *unpack_data, int fd) |
958 | 958 |
length = getbits(unpack_data); |
959 | 959 |
addbits(unpack_data, 16); |
960 | 960 |
} |
961 |
- vmcode = (unsigned char *) malloc(length + 2); |
|
961 |
+ vmcode = (unsigned char *) cli_malloc(length + 2); |
|
962 | 962 |
rar_dbgmsg("VM code length: %d\n", length); |
963 | 963 |
if (!vmcode) { |
964 | 964 |
return FALSE; |
... | ... |
@@ -1004,7 +1004,7 @@ static int read_vm_code_PPM(unpack_data_t *unpack_data, int fd) |
1004 | 1004 |
} |
1005 | 1005 |
length = b1*256 + b2; |
1006 | 1006 |
} |
1007 |
- vmcode = (unsigned char *) malloc(length + 2); |
|
1007 |
+ vmcode = (unsigned char *) cli_malloc(length + 2); |
|
1008 | 1008 |
rar_dbgmsg("VM PPM code length: %d\n", length); |
1009 | 1009 |
if (!vmcode) { |
1010 | 1010 |
return FALSE; |
... | ... |
@@ -1317,7 +1317,7 @@ rar_metadata_t *cli_unrar(int fd, const char *dirname, const struct cl_limits *l |
1317 | 1317 |
if (!is_rar_archive(fd)) { |
1318 | 1318 |
return FALSE; |
1319 | 1319 |
} |
1320 |
- unpack_data = malloc(sizeof(unpack_data_t)); |
|
1320 |
+ unpack_data = cli_malloc(sizeof(unpack_data_t)); |
|
1321 | 1321 |
unpack_data->rarvm_data.mem = NULL; |
1322 | 1322 |
unpack_data->old_filter_lengths = NULL; |
1323 | 1323 |
unpack_data->PrgStack.array = unpack_data->Filters.array = NULL; |
... | ... |
@@ -1373,7 +1373,7 @@ rar_metadata_t *cli_unrar(int fd, const char *dirname, const struct cl_limits *l |
1373 | 1373 |
if (!file_header) { |
1374 | 1374 |
break; |
1375 | 1375 |
} |
1376 |
- new_metadata = malloc(sizeof(rar_metadata_t)); |
|
1376 |
+ new_metadata = cli_malloc(sizeof(rar_metadata_t)); |
|
1377 | 1377 |
if (!new_metadata) { |
1378 | 1378 |
break; |
1379 | 1379 |
} |
... | ... |
@@ -66,7 +66,7 @@ struct UnpackFilter *rar_filter_new(void) |
66 | 66 |
{ |
67 | 67 |
struct UnpackFilter *filter; |
68 | 68 |
|
69 |
- filter = (struct UnpackFilter *) malloc(sizeof(struct UnpackFilter)); |
|
69 |
+ filter = (struct UnpackFilter *) cli_malloc(sizeof(struct UnpackFilter)); |
|
70 | 70 |
if (!filter) { |
71 | 71 |
return NULL; |
72 | 72 |
} |
... | ... |
@@ -111,7 +111,7 @@ static int sub_allocator_start_sub_allocator(sub_allocator_t *sub_alloc, int sa_ |
111 | 111 |
} |
112 | 112 |
sub_allocator_stop_sub_allocator(sub_alloc); |
113 | 113 |
alloc_size = t/FIXED_UNIT_SIZE*UNIT_SIZE+UNIT_SIZE; |
114 |
- if ((sub_alloc->heap_start = (uint8_t *) malloc(alloc_size)) == NULL) { |
|
114 |
+ if ((sub_alloc->heap_start = (uint8_t *) cli_malloc(alloc_size)) == NULL) { |
|
115 | 115 |
cli_dbgmsg("sub_alloc start failed\n"); |
116 | 116 |
return FALSE; |
117 | 117 |
} |
... | ... |
@@ -195,7 +195,7 @@ uint32_t rar_crc(uint32_t start_crc, void *addr, uint32_t size) |
195 | 195 |
|
196 | 196 |
int rarvm_init(rarvm_data_t *rarvm_data) |
197 | 197 |
{ |
198 |
- rarvm_data->mem = (uint8_t *) malloc(RARVM_MEMSIZE+4); |
|
198 |
+ rarvm_data->mem = (uint8_t *) cli_malloc(RARVM_MEMSIZE+4); |
|
199 | 199 |
init_crc(); |
200 | 200 |
if (!rarvm_data->mem) { |
201 | 201 |
return FALSE; |
... | ... |
@@ -1066,7 +1066,7 @@ void rarvm_prepare(rarvm_data_t *rarvm_data, rarvm_input_t *rarvm_input, unsigne |
1066 | 1066 |
if (data_flag & 0x8000) { |
1067 | 1067 |
int data_size = rarvm_read_data(rarvm_input)+1; |
1068 | 1068 |
rar_dbgmsg("data_size=%d\n", data_size); |
1069 |
- prg->static_data = malloc(data_size); |
|
1069 |
+ prg->static_data = cli_malloc(data_size); |
|
1070 | 1070 |
for (i=0 ; rarvm_input->in_addr < code_size && i < data_size ; i++) { |
1071 | 1071 |
prg->static_size++; |
1072 | 1072 |
prg->static_data = realloc(prg->static_data, prg->static_size); |
... | ... |
@@ -126,13 +126,13 @@ int __zip_find_disk_trailer(int fd, off_t filesize, struct zip_disk_trailer *tra |
126 | 126 |
__fixup_rootseek(offset + tail - buf, trailer); |
127 | 127 |
|
128 | 128 |
u_rootseek = EC32(trailer->z_rootseek); |
129 |
- if(u_rootseek > filesize) { |
|
129 |
+ if(u_rootseek > (uint32_t) filesize) { |
|
130 | 130 |
cli_dbgmsg("Unzip: __zip_find_disk_trailer: u_rootseek > filesize, continue search\n"); |
131 | 131 |
continue; |
132 | 132 |
} |
133 | 133 |
|
134 | 134 |
for(i = 0; i < 2; i++) { |
135 |
- if(u_rootseek + shift + sizeof(dirent) < filesize) { |
|
135 |
+ if(u_rootseek + shift + sizeof(dirent) < (uint32_t) filesize) { |
|
136 | 136 |
if(lseek(fd, u_rootseek + shift, SEEK_SET) < 0) { |
137 | 137 |
cli_errmsg("Unzip: __zip_find_disk_trailer: Can't lseek descriptor %d\n", fd); |
138 | 138 |
free(buf); |
... | ... |
@@ -169,7 +169,7 @@ int __zip_parse_root_directory(int fd, struct zip_disk_trailer *trailer, zip_dir |
169 | 169 |
struct zip_root_dirent dirent, *d; |
170 | 170 |
zip_dir_hdr *hdr, *hdr0; |
171 | 171 |
uint16_t *p_reclen = NULL, entries; |
172 |
- off_t offset; |
|
172 |
+ uint32_t offset; |
|
173 | 173 |
struct stat sb; |
174 | 174 |
uint16_t u_entries = EC16(trailer->z_entries); |
175 | 175 |
uint32_t u_rootsize = EC32(trailer->z_rootsize); |
... | ... |
@@ -183,7 +183,7 @@ int __zip_parse_root_directory(int fd, struct zip_disk_trailer *trailer, zip_dir |
183 | 183 |
return CL_EIO; |
184 | 184 |
} |
185 | 185 |
|
186 |
- if(u_rootsize > sb.st_size) { |
|
186 |
+ if(u_rootsize > (uint32_t) sb.st_size) { |
|
187 | 187 |
cli_errmsg("Unzip: __zip_parse_root_directory: Incorrect root size\n"); |
188 | 188 |
return CL_EFORMAT; |
189 | 189 |
} |
... | ... |
@@ -452,7 +452,7 @@ zip_file *zip_file_open(zip_dir *dir, const char *name, int d_off) |
452 | 452 |
while(1) { |
453 | 453 |
hdr_name = hdr->d_name; |
454 | 454 |
|
455 |
- if(!strcmp(hdr_name, name) && (d_off == -1 || d_off == hdr->d_off)) { |
|
455 |
+ if(!strcmp(hdr_name, name) && (d_off == -1 || (uint32_t) d_off == hdr->d_off)) { |
|
456 | 456 |
switch (hdr->d_compr) { |
457 | 457 |
case ZIP_METHOD_STORED: |
458 | 458 |
case ZIP_METHOD_DEFLATED: |
... | ... |
@@ -207,7 +207,7 @@ int yc_decrypt(char *fbuf, unsigned int filesize, struct pe_image_section_hdr *s |
207 | 207 |
name == 0x6164722E || /* .rda */ |
208 | 208 |
name == 0x6164692E || /* .ida */ |
209 | 209 |
name == 0x736C742E || /* .tls */ |
210 |
- (name&0xffff == 0x4379) || /* yC */ |
|
210 |
+ ((name&0xffff) == 0x4379) || /* yC */ |
|
211 | 211 |
EC32(sections[i].PointerToRawData) == 0 || |
212 | 212 |
EC32(sections[i].SizeOfRawData) == 0 ) continue; |
213 | 213 |
cli_dbgmsg("yC: decrypting sect%d\n",i); |