Conflicts:
ChangeLog
libclamav/pdf.c
... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Thu, Jul 31 11:50:23 EDT 2014 (swebb) |
|
2 |
+------------------------------------ |
|
3 |
+* bb#10731 - Allow to specificy a group for the socket of which the user is |
|
4 |
+not a member |
|
5 |
+ |
|
1 | 6 |
Tue, 08 Jul 11:30:00 EDT 2014 (morgan) |
2 | 7 |
------------------------------------ |
3 | 8 |
* 0.98.5 beta release |
... | ... |
@@ -114,6 +114,104 @@ int main(int argc, char **argv) { |
114 | 114 |
} |
115 | 115 |
} |
116 | 116 |
|
117 |
+ if(!(my_socket = optget(opts, "MilterSocket")->strarg)) { |
|
118 |
+ logg("!Please configure the MilterSocket directive\n"); |
|
119 |
+ logg_close(); |
|
120 |
+ optfree(opts); |
|
121 |
+ return 1; |
|
122 |
+ } |
|
123 |
+ |
|
124 |
+ if(smfi_setconn(my_socket) == MI_FAILURE) { |
|
125 |
+ logg("!smfi_setconn failed\n"); |
|
126 |
+ logg_close(); |
|
127 |
+ optfree(opts); |
|
128 |
+ return 1; |
|
129 |
+ } |
|
130 |
+ if(smfi_register(descr) == MI_FAILURE) { |
|
131 |
+ logg("!smfi_register failed\n"); |
|
132 |
+ logg_close(); |
|
133 |
+ optfree(opts); |
|
134 |
+ return 1; |
|
135 |
+ } |
|
136 |
+ opt = optget(opts, "FixStaleSocket"); |
|
137 |
+ umsk = umask(0777); /* socket is created with 000 to avoid races */ |
|
138 |
+ if(smfi_opensocket(opt->enabled) == MI_FAILURE) { |
|
139 |
+ logg("!Failed to create socket %s\n", my_socket); |
|
140 |
+ logg_close(); |
|
141 |
+ optfree(opts); |
|
142 |
+ return 1; |
|
143 |
+ } |
|
144 |
+ umask(umsk); /* restore umask */ |
|
145 |
+ if(strncmp(my_socket, "inet:", 5) && strncmp(my_socket, "inet6:", 6)) { |
|
146 |
+ /* set group ownership and perms on the local socket */ |
|
147 |
+ char *sock_name = my_socket; |
|
148 |
+ mode_t sock_mode; |
|
149 |
+ if(!strncmp(my_socket, "unix:", 5)) |
|
150 |
+ sock_name += 5; |
|
151 |
+ if(!strncmp(my_socket, "local:", 6)) |
|
152 |
+ sock_name += 6; |
|
153 |
+ if(*my_socket == ':') |
|
154 |
+ sock_name ++; |
|
155 |
+ |
|
156 |
+ if(optget(opts, "MilterSocketGroup")->enabled) { |
|
157 |
+ char *gname = optget(opts, "MilterSocketGroup")->strarg, *end; |
|
158 |
+ gid_t sock_gid = strtol(gname, &end, 10); |
|
159 |
+ if(*end) { |
|
160 |
+ struct group *pgrp = getgrnam(gname); |
|
161 |
+ if(!pgrp) { |
|
162 |
+ logg("!Unknown group %s\n", gname); |
|
163 |
+ logg_close(); |
|
164 |
+ optfree(opts); |
|
165 |
+ return 1; |
|
166 |
+ } |
|
167 |
+ sock_gid = pgrp->gr_gid; |
|
168 |
+ } |
|
169 |
+ if(chown(sock_name, -1, sock_gid)) { |
|
170 |
+ logg("!Failed to change socket ownership to group %s\n", gname); |
|
171 |
+ logg_close(); |
|
172 |
+ optfree(opts); |
|
173 |
+ return 1; |
|
174 |
+ } |
|
175 |
+ } |
|
176 |
+ |
|
177 |
+ if ((opt = optget(opts, "User"))->enabled) { |
|
178 |
+ struct passwd *user; |
|
179 |
+ if ((user = getpwnam(opt->strarg)) == NULL) { |
|
180 |
+ logg("ERROR: Can't get information about user %s.\n", |
|
181 |
+ opt->strarg); |
|
182 |
+ logg_close(); |
|
183 |
+ optfree(opts); |
|
184 |
+ return 1; |
|
185 |
+ } |
|
186 |
+ |
|
187 |
+ if(chown(sock_name, user->pw_uid, -1)) { |
|
188 |
+ logg("!Failed to change socket ownership to user %s\n", user->pw_name); |
|
189 |
+ optfree(opts); |
|
190 |
+ logg_close(); |
|
191 |
+ return 1; |
|
192 |
+ } |
|
193 |
+ } |
|
194 |
+ |
|
195 |
+ if(optget(opts, "MilterSocketMode")->enabled) { |
|
196 |
+ char *end; |
|
197 |
+ sock_mode = strtol(optget(opts, "MilterSocketMode")->strarg, &end, 8); |
|
198 |
+ if(*end) { |
|
199 |
+ logg("!Invalid MilterSocketMode %s\n", optget(opts, "MilterSocketMode")->strarg); |
|
200 |
+ logg_close(); |
|
201 |
+ optfree(opts); |
|
202 |
+ return 1; |
|
203 |
+ } |
|
204 |
+ } else |
|
205 |
+ sock_mode = 0777 & ~umsk; |
|
206 |
+ |
|
207 |
+ if(chmod(sock_name, sock_mode & 0666)) { |
|
208 |
+ logg("!Cannot set milter socket permission to %s\n", optget(opts, "MilterSocketMode")->strarg); |
|
209 |
+ logg_close(); |
|
210 |
+ optfree(opts); |
|
211 |
+ return 1; |
|
212 |
+ } |
|
213 |
+ } |
|
214 |
+ |
|
117 | 215 |
if(geteuid() == 0 && (opt = optget(opts, "User"))->enabled) { |
118 | 216 |
struct passwd *user = NULL; |
119 | 217 |
if((user = getpwnam(opt->strarg)) == NULL) { |
... | ... |
@@ -246,15 +344,6 @@ int main(int argc, char **argv) { |
246 | 246 |
|
247 | 247 |
multircpt = optget(opts, "SupportMultipleRecipients")->enabled; |
248 | 248 |
|
249 |
- if(!(my_socket = optget(opts, "MilterSocket")->strarg)) { |
|
250 |
- logg("!Please configure the MilterSocket directive\n"); |
|
251 |
- localnets_free(); |
|
252 |
- whitelist_free(); |
|
253 |
- logg_close(); |
|
254 |
- optfree(opts); |
|
255 |
- return 1; |
|
256 |
- } |
|
257 |
- |
|
258 | 249 |
if(!optget(opts, "Foreground")->enabled) { |
259 | 250 |
if(daemonize() == -1) { |
260 | 251 |
logg("!daemonize() failed\n"); |
... | ... |
@@ -269,92 +358,6 @@ int main(int argc, char **argv) { |
269 | 269 |
logg("^Can't change current working directory to root\n"); |
270 | 270 |
} |
271 | 271 |
|
272 |
- if(smfi_setconn(my_socket) == MI_FAILURE) { |
|
273 |
- logg("!smfi_setconn failed\n"); |
|
274 |
- localnets_free(); |
|
275 |
- whitelist_free(); |
|
276 |
- logg_close(); |
|
277 |
- optfree(opts); |
|
278 |
- return 1; |
|
279 |
- } |
|
280 |
- if(smfi_register(descr) == MI_FAILURE) { |
|
281 |
- logg("!smfi_register failed\n"); |
|
282 |
- localnets_free(); |
|
283 |
- whitelist_free(); |
|
284 |
- logg_close(); |
|
285 |
- optfree(opts); |
|
286 |
- return 1; |
|
287 |
- } |
|
288 |
- opt = optget(opts, "FixStaleSocket"); |
|
289 |
- umsk = umask(0777); /* socket is created with 000 to avoid races */ |
|
290 |
- if(smfi_opensocket(opt->enabled) == MI_FAILURE) { |
|
291 |
- logg("!Failed to create socket %s\n", my_socket); |
|
292 |
- localnets_free(); |
|
293 |
- whitelist_free(); |
|
294 |
- logg_close(); |
|
295 |
- optfree(opts); |
|
296 |
- return 1; |
|
297 |
- } |
|
298 |
- umask(umsk); /* restore umask */ |
|
299 |
- if(strncmp(my_socket, "inet:", 5) && strncmp(my_socket, "inet6:", 6)) { |
|
300 |
- /* set group ownership and perms on the local socket */ |
|
301 |
- char *sock_name = my_socket; |
|
302 |
- mode_t sock_mode; |
|
303 |
- if(!strncmp(my_socket, "unix:", 5)) |
|
304 |
- sock_name += 5; |
|
305 |
- if(!strncmp(my_socket, "local:", 6)) |
|
306 |
- sock_name += 6; |
|
307 |
- if(*my_socket == ':') |
|
308 |
- sock_name ++; |
|
309 |
- |
|
310 |
- if(optget(opts, "MilterSocketGroup")->enabled) { |
|
311 |
- char *gname = optget(opts, "MilterSocketGroup")->strarg, *end; |
|
312 |
- gid_t sock_gid = strtol(gname, &end, 10); |
|
313 |
- if(*end) { |
|
314 |
- struct group *pgrp = getgrnam(gname); |
|
315 |
- if(!pgrp) { |
|
316 |
- logg("!Unknown group %s\n", gname); |
|
317 |
- localnets_free(); |
|
318 |
- whitelist_free(); |
|
319 |
- logg_close(); |
|
320 |
- optfree(opts); |
|
321 |
- return 1; |
|
322 |
- } |
|
323 |
- sock_gid = pgrp->gr_gid; |
|
324 |
- } |
|
325 |
- if(chown(sock_name, -1, sock_gid)) { |
|
326 |
- logg("!Failed to change socket ownership to group %s\n", gname); |
|
327 |
- localnets_free(); |
|
328 |
- whitelist_free(); |
|
329 |
- logg_close(); |
|
330 |
- optfree(opts); |
|
331 |
- return 1; |
|
332 |
- } |
|
333 |
- } |
|
334 |
- if(optget(opts, "MilterSocketMode")->enabled) { |
|
335 |
- char *end; |
|
336 |
- sock_mode = strtol(optget(opts, "MilterSocketMode")->strarg, &end, 8); |
|
337 |
- if(*end) { |
|
338 |
- logg("!Invalid MilterSocketMode %s\n", optget(opts, "MilterSocketMode")->strarg); |
|
339 |
- localnets_free(); |
|
340 |
- whitelist_free(); |
|
341 |
- logg_close(); |
|
342 |
- optfree(opts); |
|
343 |
- return 1; |
|
344 |
- } |
|
345 |
- } else |
|
346 |
- sock_mode = 0777 & ~umsk; |
|
347 |
- |
|
348 |
- if(chmod(sock_name, sock_mode & 0666)) { |
|
349 |
- logg("!Cannot set milter socket permission to %s\n", optget(opts, "MilterSocketMode")->strarg); |
|
350 |
- localnets_free(); |
|
351 |
- whitelist_free(); |
|
352 |
- logg_close(); |
|
353 |
- optfree(opts); |
|
354 |
- return 1; |
|
355 |
- } |
|
356 |
- } |
|
357 |
- |
|
358 | 272 |
maxfilesize = optget(opts, "MaxFileSize")->numarg; |
359 | 273 |
if(!maxfilesize) { |
360 | 274 |
logg("^Invalid MaxFileSize, using default (%d)\n", CLI_DEFAULT_MAXFILESIZE); |
... | ... |
@@ -56,6 +56,7 @@ static void help(void) |
56 | 56 |
printf(" --version -V Show version\n"); |
57 | 57 |
printf(" --info -i Print information about bytecode\n"); |
58 | 58 |
printf(" --printsrc -p Print bytecode source\n"); |
59 |
+ printf(" --printbcir -c Print bytecode IR\n"); |
|
59 | 60 |
printf(" --trace <level> Set bytecode trace level 0..7 (default 7)\n"); |
60 | 61 |
printf(" --no-trace-showsource Don't show source line during tracing\n"); |
61 | 62 |
printf(" file file to test\n"); |
... | ... |
@@ -112,16 +113,19 @@ static void tracehook(struct cli_bc_ctx *ctx, unsigned event) |
112 | 112 |
|
113 | 113 |
static void tracehook_op(struct cli_bc_ctx *ctx, const char *op) |
114 | 114 |
{ |
115 |
+ UNUSEDPARAM(ctx); |
|
115 | 116 |
fprintf(stderr, "[trace] %s\n", op); |
116 | 117 |
} |
117 | 118 |
|
118 | 119 |
static void tracehook_val(struct cli_bc_ctx *ctx, const char *name, uint32_t value) |
119 | 120 |
{ |
121 |
+ UNUSEDPARAM(ctx); |
|
120 | 122 |
fprintf(stderr, "[trace] %s = %u\n", name, value); |
121 | 123 |
} |
122 | 124 |
|
123 | 125 |
static void tracehook_ptr(struct cli_bc_ctx *ctx, const void *ptr) |
124 | 126 |
{ |
127 |
+ UNUSEDPARAM(ctx); |
|
125 | 128 |
fprintf(stderr, "[trace] %p\n", ptr); |
126 | 129 |
} |
127 | 130 |
|
... | ... |
@@ -325,6 +329,10 @@ int main(int argc, char *argv[]) |
325 | 325 |
cli_bytecode_describe(bc); |
326 | 326 |
} else if (optget(opts, "printsrc")->enabled) { |
327 | 327 |
print_src(opts->filename[0]); |
328 |
+ } else if (optget(opts, "printbcir")->enabled) { |
|
329 |
+ cli_bytetype_describe(bc); |
|
330 |
+ cli_bytevalue_describe(bc, 0); |
|
331 |
+ cli_bytefunc_describe(bc, 0); |
|
328 | 332 |
} else { |
329 | 333 |
cli_ctx cctx; |
330 | 334 |
struct cl_engine *engine = cl_engine_new(); |
... | ... |
@@ -76,6 +76,7 @@ short foreground = 0; |
76 | 76 |
char hostid[37]; |
77 | 77 |
|
78 | 78 |
char *get_hostid(void *cbdata); |
79 |
+int is_valid_hostid(void); |
|
79 | 80 |
|
80 | 81 |
static void help(void) |
81 | 82 |
{ |
... | ... |
@@ -118,11 +119,12 @@ int main(int argc, char **argv) |
118 | 118 |
time_t currtime; |
119 | 119 |
const char *dbdir, *cfgfile; |
120 | 120 |
char *pua_cats = NULL, *pt; |
121 |
- int ret, tcpsock = 0, localsock = 0, i, min_port, max_port; |
|
121 |
+ int ret, tcpsock = 0, localsock = 0, min_port, max_port; |
|
122 | 122 |
unsigned int sigs = 0; |
123 | 123 |
int *lsockets=NULL; |
124 | 124 |
unsigned int nlsockets = 0; |
125 | 125 |
unsigned int dboptions = 0; |
126 |
+ unsigned int i; |
|
126 | 127 |
#ifdef C_LINUX |
127 | 128 |
STATBUF sb; |
128 | 129 |
#endif |
... | ... |
@@ -576,8 +578,6 @@ int main(int argc, char **argv) |
576 | 576 |
} |
577 | 577 |
|
578 | 578 |
if(tcpsock) { |
579 |
- int *t; |
|
580 |
- |
|
581 | 579 |
opt = optget(opts, "TCPAddr"); |
582 | 580 |
if (opt->enabled) { |
583 | 581 |
int breakout = 0; |
... | ... |
@@ -670,7 +670,7 @@ int main(int argc, char **argv) |
670 | 670 |
if(!optget(opts, "Foreground")->enabled) { |
671 | 671 |
#ifdef C_BSD |
672 | 672 |
/* workaround for OpenBSD bug, see https://wwws.clamav.net/bugzilla/show_bug.cgi?id=885 */ |
673 |
- for(ret=0;ret<nlsockets;ret++) { |
|
673 |
+ for(ret=0;(unsigned int)ret<nlsockets;ret++) { |
|
674 | 674 |
if (fcntl(lsockets[ret], F_SETFL, fcntl(lsockets[ret], F_GETFL) | O_NONBLOCK) == -1) { |
675 | 675 |
logg("!fcntl for lsockets[] failed\n"); |
676 | 676 |
close(lsockets[ret]); |
... | ... |
@@ -688,7 +688,7 @@ int main(int argc, char **argv) |
688 | 688 |
} |
689 | 689 |
gengine = NULL; |
690 | 690 |
#ifdef C_BSD |
691 |
- for(ret=0;ret<nlsockets;ret++) { |
|
691 |
+ for(ret=0;(unsigned int)ret<nlsockets;ret++) { |
|
692 | 692 |
if (fcntl(lsockets[ret], F_SETFL, fcntl(lsockets[ret], F_GETFL) & ~O_NONBLOCK) == -1) { |
693 | 693 |
logg("!fcntl for lsockets[] failed\n"); |
694 | 694 |
close(lsockets[ret]); |
... | ... |
@@ -766,6 +766,8 @@ int is_valid_hostid(void) |
766 | 766 |
|
767 | 767 |
char *get_hostid(void *cbdata) |
768 | 768 |
{ |
769 |
+ UNUSEDPARAM(cbdata); |
|
770 |
+ |
|
769 | 771 |
if (!strcmp(hostid, "none")) |
770 | 772 |
return NULL; |
771 | 773 |
|
... | ... |
@@ -517,6 +517,8 @@ fds_poll_recv (struct fd_data *data, int timeout, int check_signals, |
517 | 517 |
int retval; |
518 | 518 |
time_t now, closest_timeout; |
519 | 519 |
|
520 |
+ UNUSEDPARAM(event); |
|
521 |
+ |
|
520 | 522 |
/* we must have at least one fd, the control fd! */ |
521 | 523 |
fds_cleanup (data); |
522 | 524 |
#ifndef _WIN32 |
... | ... |
@@ -76,6 +76,8 @@ void msg_callback(enum cl_msg severity, const char *fullmsg, const char *msg, vo |
76 | 76 |
struct cb_context *c = ctx; |
77 | 77 |
const char *filename = (c && c->filename) ? c->filename : ""; |
78 | 78 |
|
79 |
+ UNUSEDPARAM(fullmsg); |
|
80 |
+ |
|
79 | 81 |
switch (severity) { |
80 | 82 |
case CL_MSG_ERROR: |
81 | 83 |
logg("^[LibClamAV] %s: %s", filename, msg); |
... | ... |
@@ -95,10 +97,13 @@ void msg_callback(enum cl_msg severity, const char *fullmsg, const char *msg, vo |
95 | 95 |
void hash_callback(int fd, unsigned long long size, const unsigned char *md5, const char *virname, void *ctx) |
96 | 96 |
{ |
97 | 97 |
struct cb_context *c = ctx; |
98 |
+ UNUSEDPARAM(fd); |
|
99 |
+ UNUSEDPARAM(virname); |
|
100 |
+ |
|
98 | 101 |
if (!c) |
99 | 102 |
return; |
100 | 103 |
c->virsize = size; |
101 |
- strncpy(c->virhash, md5, 32); |
|
104 |
+ strncpy(c->virhash, (const char *)md5, 32); |
|
102 | 105 |
c->virhash[32] = '\0'; |
103 | 106 |
} |
104 | 107 |
|
... | ... |
@@ -346,6 +351,8 @@ int scanfd(const client_conn_t *conn, unsigned long int *scanned, |
346 | 346 |
char fdstr[32]; |
347 | 347 |
const char*reply_fdstr; |
348 | 348 |
|
349 |
+ UNUSEDPARAM(odesc); |
|
350 |
+ |
|
349 | 351 |
if (stream) { |
350 | 352 |
struct sockaddr_in sa; |
351 | 353 |
socklen_t salen = sizeof(sa); |
... | ... |
@@ -76,11 +76,12 @@ extern struct optstruct *clamdopts; |
76 | 76 |
static int isremote(const struct optstruct *opts) { |
77 | 77 |
int s, ret; |
78 | 78 |
const struct optstruct *opt; |
79 |
- static struct sockaddr_in testsock; |
|
80 | 79 |
char *ipaddr, port[10]; |
81 | 80 |
struct addrinfo hints, *info, *p; |
82 | 81 |
int res; |
83 | 82 |
|
83 |
+ UNUSEDPARAM(opts); |
|
84 |
+ |
|
84 | 85 |
#ifndef _WIN32 |
85 | 86 |
if((opt = optget(clamdopts, "LocalSocket"))->enabled) { |
86 | 87 |
memset((void *)&nixsock, 0, sizeof(nixsock)); |
... | ... |
@@ -236,6 +236,7 @@ static int chkpath(const char *path) |
236 | 236 |
|
237 | 237 |
static int ftw_chkpath(const char *path, struct cli_ftw_cbdata *data) |
238 | 238 |
{ |
239 |
+ UNUSEDPARAM(data); |
|
239 | 240 |
return chkpath(path); |
240 | 241 |
} |
241 | 242 |
|
... | ... |
@@ -378,6 +379,8 @@ static int serial_callback(STATBUF *sb, char *filename, const char *path, enum c |
378 | 378 |
int sockd, ret; |
379 | 379 |
const char *f = filename; |
380 | 380 |
|
381 |
+ UNUSEDPARAM(sb); |
|
382 |
+ |
|
381 | 383 |
if(chkpath(path)) |
382 | 384 |
return CL_SUCCESS; |
383 | 385 |
c->files++; |
... | ... |
@@ -532,6 +535,8 @@ static int parallel_callback(STATBUF *sb, char *filename, const char *path, enum |
532 | 532 |
struct SCANID *cid; |
533 | 533 |
int res = CL_CLEAN; |
534 | 534 |
|
535 |
+ UNUSEDPARAM(sb); |
|
536 |
+ |
|
535 | 537 |
if(chkpath(path)) |
536 | 538 |
return CL_SUCCESS; |
537 | 539 |
c->files++; |
... | ... |
@@ -57,6 +57,7 @@ |
57 | 57 |
#include <assert.h> |
58 | 58 |
#include <errno.h> |
59 | 59 |
|
60 |
+#include "libclamav/clamav.h" |
|
60 | 61 |
#include "shared/optparser.h" |
61 | 62 |
#include "shared/misc.h" |
62 | 63 |
|
... | ... |
@@ -101,6 +102,9 @@ static void cleanup(void); |
101 | 101 |
static int send_string_noreconn(conn_t *conn, const char *cmd); |
102 | 102 |
static void send_string(conn_t *conn, const char *cmd); |
103 | 103 |
static int read_version(conn_t *conn); |
104 |
+char *get_ip(const char *ip); |
|
105 |
+char *get_port(const char *ip); |
|
106 |
+char *make_ip(const char *host, const char *port); |
|
104 | 107 |
|
105 | 108 |
enum exit_reason { |
106 | 109 |
FAIL_CMDLINE=1, |
... | ... |
@@ -509,7 +513,7 @@ static void print_con_info(conn_t *conn, const char *fmt, ...) |
509 | 509 |
|
510 | 510 |
char *get_ip(const char *ip) |
511 | 511 |
{ |
512 |
- char *dupip, *p1, *p2; |
|
512 |
+ char *dupip, *p1; |
|
513 | 513 |
unsigned int i; |
514 | 514 |
|
515 | 515 |
/* |
... | ... |
@@ -608,7 +612,7 @@ static int make_connection_real(const char *soname, conn_t *conn) |
608 | 608 |
int s; |
609 | 609 |
struct timeval tv; |
610 | 610 |
char *port=NULL; |
611 |
- char *name, *pt = strdup(soname); |
|
611 |
+ char *pt = strdup(soname); |
|
612 | 612 |
const char *host = pt; |
613 | 613 |
struct addrinfo hints, *res=NULL, *p; |
614 | 614 |
int err; |
... | ... |
@@ -1217,6 +1221,7 @@ static int read_version(conn_t *conn) |
1217 | 1217 |
|
1218 | 1218 |
static void sigint(int a) |
1219 | 1219 |
{ |
1220 |
+ UNUSEDPARAM(a); |
|
1220 | 1221 |
EXIT_PROGRAM(SIGINT_REASON); |
1221 | 1222 |
} |
1222 | 1223 |
|
... | ... |
@@ -69,6 +69,7 @@ dev_t procdev; |
69 | 69 |
|
70 | 70 |
char hostid[37]; |
71 | 71 |
|
72 |
+int is_valid_hostid(void); |
|
72 | 73 |
char *get_hostid(void *cbdata); |
73 | 74 |
|
74 | 75 |
#ifdef _WIN32 |
... | ... |
@@ -135,6 +136,9 @@ struct metachain { |
135 | 135 |
static cl_error_t pre(int fd, const char *type, void *context) |
136 | 136 |
{ |
137 | 137 |
struct metachain *c = context; |
138 |
+ UNUSEDPARAM(fd); |
|
139 |
+ UNUSEDPARAM(type); |
|
140 |
+ |
|
138 | 141 |
if (c) { |
139 | 142 |
c->level++; |
140 | 143 |
} |
... | ... |
@@ -162,9 +166,11 @@ static int print_chain(struct metachain *c, char *str, unsigned len) |
162 | 162 |
static cl_error_t post(int fd, int result, const char *virname, void *context) |
163 | 163 |
{ |
164 | 164 |
struct metachain *c = context; |
165 |
+ UNUSEDPARAM(fd); |
|
166 |
+ UNUSEDPARAM(result); |
|
165 | 167 |
if (c && c->n) { |
166 | 168 |
char str[128]; |
167 |
- int toolong = print_chain(c, str, sizeof(str)); |
|
169 |
+ print_chain(c, str, sizeof(str)); |
|
168 | 170 |
if (c->level == c->lastadd && !virname) |
169 | 171 |
free(c->chains[--c->n]); |
170 | 172 |
if (virname && !c->lastvir) |
... | ... |
@@ -178,7 +184,6 @@ static cl_error_t post(int fd, int result, const char *virname, void *context) |
178 | 178 |
static cl_error_t meta(const char* container_type, unsigned long fsize_container, const char *filename, |
179 | 179 |
unsigned long fsize_real, int is_encrypted, unsigned int filepos_container, void *context) |
180 | 180 |
{ |
181 |
- int na = 0; |
|
182 | 181 |
char prev[128]; |
183 | 182 |
struct metachain *c = context; |
184 | 183 |
const char *type = !strncmp(container_type,"CL_TYPE_",8) ? container_type + 8 : container_type; |
... | ... |
@@ -187,6 +192,11 @@ static cl_error_t meta(const char* container_type, unsigned long fsize_container |
187 | 187 |
char **chains; |
188 | 188 |
int toolong; |
189 | 189 |
|
190 |
+ UNUSEDPARAM(fsize_container); |
|
191 |
+ UNUSEDPARAM(fsize_real); |
|
192 |
+ UNUSEDPARAM(is_encrypted); |
|
193 |
+ UNUSEDPARAM(filepos_container); |
|
194 |
+ |
|
190 | 195 |
if (!c) |
191 | 196 |
return CL_CLEAN; |
192 | 197 |
chain = malloc(n); |
... | ... |
@@ -1063,6 +1073,8 @@ int is_valid_hostid(void) |
1063 | 1063 |
|
1064 | 1064 |
char *get_hostid(void *cbdata) |
1065 | 1065 |
{ |
1066 |
+ UNUSEDPARAM(cbdata); |
|
1067 |
+ |
|
1066 | 1068 |
if (!strcmp(hostid, "none")) |
1067 | 1069 |
return NULL; |
1068 | 1070 |
|
... | ... |
@@ -13,6 +13,8 @@ |
13 | 13 |
#define OPTS "e:p:n:N:H:h?v" |
14 | 14 |
|
15 | 15 |
char *read_stream(void); |
16 |
+void usage(char *name); |
|
17 |
+void version(void); |
|
16 | 18 |
|
17 | 19 |
void usage(char *name) |
18 | 20 |
{ |
... | ... |
@@ -41,9 +43,7 @@ int main(int argc, char *argv[]) |
41 | 41 |
int ch; |
42 | 42 |
struct curl_httppost *post=NULL, *last=NULL; |
43 | 43 |
struct curl_slist *slist = NULL; |
44 |
- char *type; |
|
45 | 44 |
char *name=NULL, *email=NULL, *filename=NULL; |
46 |
- struct cl_engine *engine; |
|
47 | 45 |
int setURL=0, fromStream=0; |
48 | 46 |
|
49 | 47 |
curl_global_init(CURL_GLOBAL_ALL); |
... | ... |
@@ -17,4 +17,8 @@ |
17 | 17 |
# MA 02110-1301, USA. |
18 | 18 |
|
19 | 19 |
EXTRA_DIST = html $(top_srcdir)/docs/man/*.in clamdoc.pdf clamdoc.tex clamav-mirror-howto.pdf clamav-mirror-howto.tex phishsigs_howto.tex phishsigs_howto.pdf signatures.pdf signatures.tex clam.eps |
20 |
-man_MANS = man/clamscan.1 man/freshclam.1 man/sigtool.1 man/clamd.8 man/clamd.conf.5 man/clamdscan.1 man/clamav-milter.8 man/clamav-milter.conf.5 man/freshclam.conf.5 man/clamconf.1 man/clamdtop.1 man/clambc.1 man/clamsubmit.1 |
|
20 |
+man_MANS = man/clamscan.1 man/freshclam.1 man/sigtool.1 man/clamd.8 man/clamd.conf.5 man/clamdscan.1 man/clamav-milter.8 man/clamav-milter.conf.5 man/freshclam.conf.5 man/clamconf.1 man/clamdtop.1 man/clambc.1 |
|
21 |
+ |
|
22 |
+if ENABLE_CLAMSUBMIT |
|
23 |
+man_MANS += man/clamsubmit.1 |
|
24 |
+endif |
... | ... |
@@ -96,6 +96,7 @@ POST_UNINSTALL = : |
96 | 96 |
build_triplet = @build@ |
97 | 97 |
host_triplet = @host@ |
98 | 98 |
target_triplet = @target@ |
99 |
+@ENABLE_CLAMSUBMIT_TRUE@am__append_1 = man/clamsubmit.1 |
|
99 | 100 |
subdir = docs |
100 | 101 |
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am |
101 | 102 |
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
... | ... |
@@ -419,7 +420,10 @@ top_build_prefix = @top_build_prefix@ |
419 | 419 |
top_builddir = @top_builddir@ |
420 | 420 |
top_srcdir = @top_srcdir@ |
421 | 421 |
EXTRA_DIST = html $(top_srcdir)/docs/man/*.in clamdoc.pdf clamdoc.tex clamav-mirror-howto.pdf clamav-mirror-howto.tex phishsigs_howto.tex phishsigs_howto.pdf signatures.pdf signatures.tex clam.eps |
422 |
-man_MANS = man/clamscan.1 man/freshclam.1 man/sigtool.1 man/clamd.8 man/clamd.conf.5 man/clamdscan.1 man/clamav-milter.8 man/clamav-milter.conf.5 man/freshclam.conf.5 man/clamconf.1 man/clamdtop.1 man/clambc.1 man/clamsubmit.1 |
|
422 |
+man_MANS = man/clamscan.1 man/freshclam.1 man/sigtool.1 man/clamd.8 \ |
|
423 |
+ man/clamd.conf.5 man/clamdscan.1 man/clamav-milter.8 \ |
|
424 |
+ man/clamav-milter.conf.5 man/freshclam.conf.5 man/clamconf.1 \ |
|
425 |
+ man/clamdtop.1 man/clambc.1 $(am__append_1) |
|
423 | 426 |
all: all-am |
424 | 427 |
|
425 | 428 |
.SUFFIXES: |
... | ... |
@@ -72,6 +72,7 @@ char hostid[37]; |
72 | 72 |
|
73 | 73 |
void submit_host_info(struct optstruct *opts); |
74 | 74 |
char *get_hostid(void *cbdata); |
75 |
+int is_valid_hostid(void); |
|
75 | 76 |
|
76 | 77 |
static void |
77 | 78 |
sighandler (int sig) |
... | ... |
@@ -262,6 +263,9 @@ static void |
262 | 262 |
msg_callback (enum cl_msg severity, const char *fullmsg, const char *msg, |
263 | 263 |
void *ctx) |
264 | 264 |
{ |
265 |
+ UNUSEDPARAM(fullmsg); |
|
266 |
+ UNUSEDPARAM(ctx); |
|
267 |
+ |
|
265 | 268 |
switch (severity) |
266 | 269 |
{ |
267 | 270 |
case CL_MSG_ERROR: |
... | ... |
@@ -742,7 +746,6 @@ main (int argc, char **argv) |
742 | 742 |
|
743 | 743 |
void submit_host_info(struct optstruct *opts) |
744 | 744 |
{ |
745 |
- struct optstruct *opt; |
|
746 | 745 |
struct cl_engine *engine; |
747 | 746 |
cli_intel_t *intel; |
748 | 747 |
|
... | ... |
@@ -812,6 +815,8 @@ int is_valid_hostid(void) |
812 | 812 |
|
813 | 813 |
char *get_hostid(void *cbdata) |
814 | 814 |
{ |
815 |
+ UNUSEDPARAM(cbdata); |
|
816 |
+ |
|
815 | 817 |
if (!strcmp(hostid, "none")) |
816 | 818 |
return NULL; |
817 | 819 |
|
... | ... |
@@ -881,6 +881,10 @@ getfile_mirman (const char *srcfile, const char *destfile, |
881 | 881 |
char *remotename = NULL, *authorization = NULL, *headerline; |
882 | 882 |
const char *rotation = "|/-\\", *fname; |
883 | 883 |
|
884 |
+ UNUSEDPARAM(localip); |
|
885 |
+ UNUSEDPARAM(port); |
|
886 |
+ UNUSEDPARAM(ctimeout); |
|
887 |
+ UNUSEDPARAM(can_whitelist); |
|
884 | 888 |
|
885 | 889 |
if (proxy) |
886 | 890 |
{ |
... | ... |
@@ -1114,6 +1118,8 @@ getfile (const char *srcfile, const char *destfile, const char *hostname, |
1114 | 1114 |
int ret, sd; |
1115 | 1115 |
char ipaddr[46]; |
1116 | 1116 |
|
1117 |
+ UNUSEDPARAM(opts); |
|
1118 |
+ |
|
1117 | 1119 |
memset (ipaddr, 0, sizeof (ipaddr)); |
1118 | 1120 |
if (ip && ip[0]) /* use ip to connect */ |
1119 | 1121 |
sd = wwwconnect (ip, proxy, port, ipaddr, localip, ctimeout, mdat, |
... | ... |
@@ -22,10 +22,11 @@ int g_allocCount = 0; |
22 | 22 |
int g_allocCountTemp = 0; |
23 | 23 |
|
24 | 24 |
#endif |
25 |
+#include "clamav.h" |
|
25 | 26 |
|
26 | 27 |
void *SzAlloc(void *p, size_t size) |
27 | 28 |
{ |
28 |
- p = p; |
|
29 |
+ UNUSEDPARAM(p); |
|
29 | 30 |
if (size == 0) |
30 | 31 |
return 0; |
31 | 32 |
#ifdef _SZ_ALLOC_DEBUG |
... | ... |
@@ -37,7 +38,7 @@ void *SzAlloc(void *p, size_t size) |
37 | 37 |
|
38 | 38 |
void SzFree(void *p, void *address) |
39 | 39 |
{ |
40 |
- p = p; |
|
40 |
+ UNUSEDPARAM(p); |
|
41 | 41 |
#ifdef _SZ_ALLOC_DEBUG |
42 | 42 |
if (address != 0) |
43 | 43 |
{ |
... | ... |
@@ -50,7 +51,7 @@ void SzFree(void *p, void *address) |
50 | 50 |
|
51 | 51 |
void *SzAllocTemp(void *p, size_t size) |
52 | 52 |
{ |
53 |
- p = p; |
|
53 |
+ UNUSEDPARAM(p); |
|
54 | 54 |
if (size == 0) |
55 | 55 |
return 0; |
56 | 56 |
#ifdef _SZ_ALLOC_DEBUG |
... | ... |
@@ -65,7 +66,7 @@ void *SzAllocTemp(void *p, size_t size) |
65 | 65 |
|
66 | 66 |
void SzFreeTemp(void *p, void *address) |
67 | 67 |
{ |
68 |
- p = p; |
|
68 |
+ UNUSEDPARAM(p); |
|
69 | 69 |
#ifdef _SZ_ALLOC_DEBUG |
70 | 70 |
if (address != 0) |
71 | 71 |
{ |
... | ... |
@@ -19,6 +19,9 @@ Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; |
19 | 19 |
#define NUM_FOLDER_CODERS_MAX 32 |
20 | 20 |
#define NUM_CODER_STREAMS_MAX 32 |
21 | 21 |
|
22 |
+void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc); |
|
23 |
+int SzFolder_FindBindPairForOutStream(CSzFolder *p, UInt32 outStreamIndex); |
|
24 |
+ |
|
22 | 25 |
void SzCoderInfo_Init(CSzCoderInfo *p) |
23 | 26 |
{ |
24 | 27 |
Buf_Init(&p->Props); |
... | ... |
@@ -115,6 +115,8 @@ StopCompilingDueBUG |
115 | 115 |
|
116 | 116 |
#define LZMA_DIC_MIN (1 << 12) |
117 | 117 |
|
118 |
+void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState); |
|
119 |
+ |
|
118 | 120 |
/* First LZMA-symbol is always decoded. |
119 | 121 |
And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization |
120 | 122 |
Out: |
... | ... |
@@ -68,7 +68,7 @@ void XzCheck_Update(CXzCheck *p, const void *data, size_t size) |
68 | 68 |
case XZ_CHECK_CRC64: p->crc64 = Crc64Update(p->crc64, data, size); break; |
69 | 69 |
case XZ_CHECK_SHA256: |
70 | 70 |
if ((p->sha)) |
71 |
- cl_update_hash(p->sha, (const Byte *)data, size); |
|
71 |
+ cl_update_hash(p->sha, (void *)data, size); |
|
72 | 72 |
break; |
73 | 73 |
} |
74 | 74 |
} |
... | ... |
@@ -33,6 +33,11 @@ |
33 | 33 |
|
34 | 34 |
#define CODER_BUF_SIZE (1 << 17) |
35 | 35 |
|
36 |
+void BraState_Free(void *pp, ISzAlloc *alloc); |
|
37 |
+SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc); |
|
38 |
+void BraState_Init(void *pp); |
|
39 |
+SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, ISzAlloc *alloc); |
|
40 |
+ |
|
36 | 41 |
unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value) |
37 | 42 |
{ |
38 | 43 |
int i, limit; |
... | ... |
@@ -77,7 +82,7 @@ void BraState_Free(void *pp, ISzAlloc *alloc) |
77 | 77 |
SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc) |
78 | 78 |
{ |
79 | 79 |
CBraState *p = ((CBraState *)pp); |
80 |
- alloc = alloc; |
|
80 |
+ UNUSEDPARAM(alloc); |
|
81 | 81 |
p->encodeMode = 0; |
82 | 82 |
p->ip = 0; |
83 | 83 |
if (p->methodId == XZ_ID_Delta) |
... | ... |
@@ -133,9 +138,9 @@ static SRes BraState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src, |
133 | 133 |
CBraState *p = ((CBraState *)pp); |
134 | 134 |
SizeT destLenOrig = *destLen; |
135 | 135 |
SizeT srcLenOrig = *srcLen; |
136 |
+ UNUSEDPARAM(finishMode); |
|
136 | 137 |
*destLen = 0; |
137 | 138 |
*srcLen = 0; |
138 |
- finishMode = finishMode; |
|
139 | 139 |
*wasFinished = 0; |
140 | 140 |
while (destLenOrig > 0) |
141 | 141 |
{ |
... | ... |
@@ -302,7 +307,7 @@ static SRes Lzma2State_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *sr |
302 | 302 |
ELzmaStatus status; |
303 | 303 |
/* ELzmaFinishMode fm = (finishMode == LZMA_FINISH_ANY) ? LZMA_FINISH_ANY : LZMA_FINISH_END; */ |
304 | 304 |
SRes res = Lzma2Dec_DecodeToBuf((CLzma2Dec *)pp, dest, destLen, src, srcLen, finishMode, &status); |
305 |
- srcWasFinished = srcWasFinished; |
|
305 |
+ UNUSEDPARAM(srcWasFinished); |
|
306 | 306 |
*wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK); |
307 | 307 |
return res; |
308 | 308 |
} |
... | ... |
@@ -785,7 +790,7 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, |
785 | 785 |
srcRem = (SizeT)cur; |
786 | 786 |
p->crc = CrcUpdate(p->crc, src, srcRem); |
787 | 787 |
if ((p->sha)) |
788 |
- cl_update_hash(p->sha, src, srcRem); |
|
788 |
+ cl_update_hash(p->sha, (void *)src, srcRem); |
|
789 | 789 |
(*srcLen) += srcRem; |
790 | 790 |
src += srcRem; |
791 | 791 |
p->indexPos += srcRem; |
... | ... |
@@ -146,7 +146,7 @@ int cli_7unz (cli_ctx *ctx, size_t offset) { |
146 | 146 |
} |
147 | 147 |
|
148 | 148 |
name = (char *)utf16name; |
149 |
- for(j=0; j<newnamelen; j++) /* FIXME */ |
|
149 |
+ for(j=0; j<(size_t)newnamelen; j++) /* FIXME */ |
|
150 | 150 |
name[j] = utf16name[j]; |
151 | 151 |
name[j] = 0; |
152 | 152 |
cli_dbgmsg("cli_7unz: extracting %s\n", name); |
... | ... |
@@ -177,7 +177,7 @@ int cli_7unz (cli_ctx *ctx, size_t offset) { |
177 | 177 |
break; |
178 | 178 |
|
179 | 179 |
cli_dbgmsg("cli_7unz: Saving to %s\n", name); |
180 |
- if(cli_writen(fd, outBuffer + offset, outSizeProcessed) != outSizeProcessed) |
|
180 |
+ if((size_t)cli_writen(fd, outBuffer + offset, outSizeProcessed) != outSizeProcessed) |
|
181 | 181 |
found = CL_EWRITE; |
182 | 182 |
else |
183 | 183 |
if ((found = cli_magic_scandesc(fd, ctx)) == CL_VIRUS) |
... | ... |
@@ -271,11 +271,11 @@ am_libclamav_la_OBJECTS = libclamav_la-matcher-ac.lo \ |
271 | 271 |
libclamav_la-bytecode_api_decl.lo libclamav_la-cache.lo \ |
272 | 272 |
libclamav_la-bytecode_detect.lo libclamav_la-events.lo \ |
273 | 273 |
libclamav_la-adc.lo libclamav_la-dmg.lo libclamav_la-xar.lo \ |
274 |
- libclamav_la-mbr.lo libclamav_la-gpt.lo libclamav_la-apm.lo \ |
|
275 |
- libclamav_la-prtn_intxn.lo libclamav_la-json_api.lo \ |
|
276 |
- libclamav_la-xz_iface.lo libclamav_la-sf_base64decode.lo \ |
|
277 |
- libclamav_la-hfsplus.lo libclamav_la-swf.lo \ |
|
278 |
- libclamav_la-jpeg.lo libclamav_la-png.lo \ |
|
274 |
+ libclamav_la-xdp.lo libclamav_la-mbr.lo libclamav_la-gpt.lo \ |
|
275 |
+ libclamav_la-apm.lo libclamav_la-prtn_intxn.lo \ |
|
276 |
+ libclamav_la-json_api.lo libclamav_la-xz_iface.lo \ |
|
277 |
+ libclamav_la-sf_base64decode.lo libclamav_la-hfsplus.lo \ |
|
278 |
+ libclamav_la-swf.lo libclamav_la-jpeg.lo libclamav_la-png.lo \ |
|
279 | 279 |
libclamav_la-iso9660.lo libclamav_la-arc4.lo \ |
280 | 280 |
libclamav_la-rijndael.lo libclamav_la-crtmgr.lo \ |
281 | 281 |
libclamav_la-asn1.lo libclamav_la-fpu.lo libclamav_la-stats.lo \ |
... | ... |
@@ -874,14 +874,14 @@ libclamav_la_SOURCES = matcher-ac.c matcher-ac.h matcher-bm.c \ |
874 | 874 |
bytecode_api.h bytecode_api_impl.h bytecode_hooks.h cache.c \ |
875 | 875 |
cache.h bytecode_detect.c bytecode_detect.h \ |
876 | 876 |
builtin_bytecodes.h events.c events.h adc.c adc.h dmg.c dmg.h \ |
877 |
- xar.c xar.h mbr.c mbr.h gpt.c gpt.h apm.c apm.h prtn_intxn.c \ |
|
878 |
- prtn_intxn.h json_api.c json_api.h xz_iface.c xz_iface.h \ |
|
879 |
- sf_base64decode.c sf_base64decode.h hfsplus.c hfsplus.h swf.c \ |
|
880 |
- swf.h jpeg.c jpeg.h png.c png.h iso9660.c iso9660.h arc4.c \ |
|
881 |
- arc4.h rijndael.c rijndael.h crtmgr.c crtmgr.h asn1.c asn1.h \ |
|
882 |
- fpu.c fpu.h stats.c stats.h www.c www.h stats_json.c \ |
|
883 |
- stats_json.h hostid.c hostid.h openioc.c openioc.h bignum.h \ |
|
884 |
- bignum_fast.h tomsfastmath/addsub/fp_add.c \ |
|
877 |
+ xar.c xar.h xdp.c xdp.h mbr.c mbr.h gpt.c gpt.h apm.c apm.h \ |
|
878 |
+ prtn_intxn.c prtn_intxn.h json_api.c json_api.h xz_iface.c \ |
|
879 |
+ xz_iface.h sf_base64decode.c sf_base64decode.h hfsplus.c \ |
|
880 |
+ hfsplus.h swf.c swf.h jpeg.c jpeg.h png.c png.h iso9660.c \ |
|
881 |
+ iso9660.h arc4.c arc4.h rijndael.c rijndael.h crtmgr.c \ |
|
882 |
+ crtmgr.h asn1.c asn1.h fpu.c fpu.h stats.c stats.h www.c www.h \ |
|
883 |
+ stats_json.c stats_json.h hostid.c hostid.h openioc.c \ |
|
884 |
+ openioc.h bignum.h bignum_fast.h tomsfastmath/addsub/fp_add.c \ |
|
885 | 885 |
tomsfastmath/addsub/fp_add_d.c tomsfastmath/addsub/fp_addmod.c \ |
886 | 886 |
tomsfastmath/addsub/fp_cmp.c tomsfastmath/addsub/fp_cmp_d.c \ |
887 | 887 |
tomsfastmath/addsub/fp_cmp_mag.c tomsfastmath/addsub/fp_sub.c \ |
... | ... |
@@ -1293,6 +1293,7 @@ distclean-compile: |
1293 | 1293 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-wwunpack.Plo@am__quote@ |
1294 | 1294 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-www.Plo@am__quote@ |
1295 | 1295 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-xar.Plo@am__quote@ |
1296 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-xdp.Plo@am__quote@ |
|
1296 | 1297 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-xz_iface.Plo@am__quote@ |
1297 | 1298 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-yc.Plo@am__quote@ |
1298 | 1299 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_nocxx_la-bytecode_nojit.Plo@am__quote@ |
... | ... |
@@ -2125,6 +2126,13 @@ libclamav_la-xar.lo: xar.c |
2125 | 2125 |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
2126 | 2126 |
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-xar.lo `test -f 'xar.c' || echo '$(srcdir)/'`xar.c |
2127 | 2127 |
|
2128 |
+libclamav_la-xdp.lo: xdp.c |
|
2129 |
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-xdp.lo -MD -MP -MF $(DEPDIR)/libclamav_la-xdp.Tpo -c -o libclamav_la-xdp.lo `test -f 'xdp.c' || echo '$(srcdir)/'`xdp.c |
|
2130 |
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-xdp.Tpo $(DEPDIR)/libclamav_la-xdp.Plo |
|
2131 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xdp.c' object='libclamav_la-xdp.lo' libtool=yes @AMDEPBACKSLASH@ |
|
2132 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
2133 |
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-xdp.lo `test -f 'xdp.c' || echo '$(srcdir)/'`xdp.c |
|
2134 |
+ |
|
2128 | 2135 |
libclamav_la-mbr.lo: mbr.c |
2129 | 2136 |
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-mbr.lo -MD -MP -MF $(DEPDIR)/libclamav_la-mbr.Tpo -c -o libclamav_la-mbr.lo `test -f 'mbr.c' || echo '$(srcdir)/'`mbr.c |
2130 | 2137 |
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-mbr.Tpo $(DEPDIR)/libclamav_la-mbr.Plo |
... | ... |
@@ -52,7 +52,7 @@ int cli_scanapm(cli_ctx *ctx) |
52 | 52 |
struct apm_driver_desc_map ddm; |
53 | 53 |
struct apm_partition_info aptable, apentry; |
54 | 54 |
int ret = CL_CLEAN, detection = CL_CLEAN, old_school = 0; |
55 |
- size_t sectorsize, maplen, partsize, sectorcheck; |
|
55 |
+ size_t sectorsize, maplen, partsize; |
|
56 | 56 |
off_t pos = 0, partoff = 0; |
57 | 57 |
unsigned i; |
58 | 58 |
uint32_t max_prtns = 0; |
... | ... |
@@ -1044,7 +1044,7 @@ static int asn1_parse_mscat(fmap_t *map, size_t offset, unsigned int size, crtmg |
1044 | 1044 |
break; |
1045 | 1045 |
|
1046 | 1046 |
cl_update_hash(ctx, "\x31", 1); |
1047 |
- cl_update_hash(ctx, attrs + 1, attrs_size - 1); |
|
1047 |
+ cl_update_hash(ctx, (void *)(attrs + 1), attrs_size - 1); |
|
1048 | 1048 |
cl_finish_hash(ctx, sha1); |
1049 | 1049 |
|
1050 | 1050 |
if(!fmap_need_ptr_once(map, asn1.content, asn1.size)) { |
... | ... |
@@ -1288,7 +1288,7 @@ static int asn1_parse_mscat(fmap_t *map, size_t offset, unsigned int size, crtmg |
1288 | 1288 |
break; |
1289 | 1289 |
|
1290 | 1290 |
cl_update_hash(ctx, "\x31", 1); |
1291 |
- cl_update_hash(ctx, attrs + 1, attrs_size - 1); |
|
1291 |
+ cl_update_hash(ctx, (void *)(attrs + 1), attrs_size - 1); |
|
1292 | 1292 |
cl_finish_hash(ctx, sha1); |
1293 | 1293 |
} else { |
1294 | 1294 |
ctx = cl_hash_init("md5"); |
... | ... |
@@ -1296,7 +1296,7 @@ static int asn1_parse_mscat(fmap_t *map, size_t offset, unsigned int size, crtmg |
1296 | 1296 |
break; |
1297 | 1297 |
|
1298 | 1298 |
cl_update_hash(ctx, "\x31", 1); |
1299 |
- cl_update_hash(ctx, attrs + 1, attrs_size - 1); |
|
1299 |
+ cl_update_hash(ctx, (void *)(attrs + 1), attrs_size - 1); |
|
1300 | 1300 |
cl_finish_hash(ctx, sha1); |
1301 | 1301 |
} |
1302 | 1302 |
|
... | ... |
@@ -18,8 +18,6 @@ |
18 | 18 |
* MA 02110-1301, USA. |
19 | 19 |
*/ |
20 | 20 |
|
21 |
-static char const rcsid[] = "$Id: blob.c,v 1.64 2007/02/12 22:25:14 njh Exp $"; |
|
22 |
- |
|
23 | 21 |
#if HAVE_CONFIG_H |
24 | 22 |
#include "clamav-config.h" |
25 | 23 |
#endif |
... | ... |
@@ -144,6 +142,8 @@ blobSetFilename(blob *b, const char *dir, const char *filename) |
144 | 144 |
assert(b->magic == BLOBCLASS); |
145 | 145 |
assert(filename != NULL); |
146 | 146 |
|
147 |
+ UNUSEDPARAM(dir); |
|
148 |
+ |
|
147 | 149 |
cli_dbgmsg("blobSetFilename: %s\n", filename); |
148 | 150 |
|
149 | 151 |
if(b->name) |
... | ... |
@@ -474,6 +474,8 @@ fileblobDestroy(fileblob *fb) |
474 | 474 |
void |
475 | 475 |
fileblobPartialSet(fileblob *fb, const char *fullname, const char *arg) |
476 | 476 |
{ |
477 |
+ UNUSEDPARAM(arg); |
|
478 |
+ |
|
477 | 479 |
if(fb->b.name) |
478 | 480 |
return; |
479 | 481 |
|
... | ... |
@@ -363,6 +363,10 @@ int cli_bytecode_context_setparam_int(struct cli_bc_ctx *ctx, unsigned i, uint64 |
363 | 363 |
|
364 | 364 |
int cli_bytecode_context_setparam_ptr(struct cli_bc_ctx *ctx, unsigned i, void *data, unsigned datalen) |
365 | 365 |
{ |
366 |
+ UNUSEDPARAM(ctx); |
|
367 |
+ UNUSEDPARAM(i); |
|
368 |
+ UNUSEDPARAM(data); |
|
369 |
+ UNUSEDPARAM(datalen); |
|
366 | 370 |
cli_errmsg("Pointer parameters are not implemented yet!\n"); |
367 | 371 |
return CL_EARG; |
368 | 372 |
} |
... | ... |
@@ -1401,7 +1405,7 @@ static int parseBB(struct cli_bc *bc, unsigned func, unsigned bb, unsigned char |
1401 | 1401 |
} |
1402 | 1402 |
bcfunc->dbgnodes = cli_malloc(num*sizeof(*bcfunc->dbgnodes)); |
1403 | 1403 |
if (!bcfunc->dbgnodes) { |
1404 |
- cli_errmsg("Unable to allocate memory for dbg nodes: %s\n", num*sizeof(*bcfunc->dbgnodes)); |
|
1404 |
+ cli_errmsg("Unable to allocate memory for dbg nodes: %u\n", num*sizeof(*bcfunc->dbgnodes)); |
|
1405 | 1405 |
return CL_EMEM; |
1406 | 1406 |
} |
1407 | 1407 |
for (i=0;i<num;i++) { |
... | ... |
@@ -2270,7 +2274,7 @@ static int cli_bytecode_prepare_interpreter(struct cli_bc *bc) |
2270 | 2270 |
MAP(inst->u.three[1]); |
2271 | 2271 |
MAP(inst->u.three[2]); |
2272 | 2272 |
inst->u.three[0] = get_geptypesize(bc, inst->u.three[0]); |
2273 |
- if (inst->u.three[0] == -1) |
|
2273 |
+ if ((int)(inst->u.three[0]) == -1) |
|
2274 | 2274 |
ret = CL_EBYTECODE; |
2275 | 2275 |
break; |
2276 | 2276 |
case OP_BC_GEPZ: |
... | ... |
@@ -2644,7 +2648,7 @@ int cli_bytecode_prepare2(struct cl_engine *engine, struct cli_all_bc *bcs, unsi |
2644 | 2644 |
rc = cli_bytecode_context_getresult_int(ctx); |
2645 | 2645 |
/* check magic number, don't use 0 here because it is too easy for a |
2646 | 2646 |
* buggy bytecode to return 0 */ |
2647 |
- if (rc != 0xda7aba5e) { |
|
2647 |
+ if ((unsigned int)rc != (unsigned int)0xda7aba5e) { |
|
2648 | 2648 |
cli_warnmsg("Bytecode: selftest failed with code %08x. Please report to http://bugs.clamav.net\n", |
2649 | 2649 |
rc); |
2650 | 2650 |
if (engine->bytecode_mode == CL_BYTECODE_MODE_TEST) |
... | ... |
@@ -3012,7 +3016,7 @@ void cli_bytecode_describe(const struct cli_bc *bc) |
3012 | 3012 |
unsigned len = strlen(cli_apicalls[i].name); |
3013 | 3013 |
if (had) |
3014 | 3014 |
printf(","); |
3015 |
- if (len > cols) { |
|
3015 |
+ if (len > (unsigned int)cols) { |
|
3016 | 3016 |
printf("\n\t"); |
3017 | 3017 |
cols = 72; |
3018 | 3018 |
} |
... | ... |
@@ -3023,3 +3027,489 @@ void cli_bytecode_describe(const struct cli_bc *bc) |
3023 | 3023 |
} |
3024 | 3024 |
printf("\n"); |
3025 | 3025 |
} |
3026 |
+ |
|
3027 |
+const char *bc_tystr[] = { |
|
3028 |
+ "DFunctionType", |
|
3029 |
+ "DPointerType", |
|
3030 |
+ "DStructType", |
|
3031 |
+ "DPackedStructType", |
|
3032 |
+ "DArrayType" |
|
3033 |
+}; |
|
3034 |
+ |
|
3035 |
+const char *bc_opstr[] = { |
|
3036 |
+ "OP_BC_NULL", |
|
3037 |
+ "OP_BC_ADD", /* =1*/ |
|
3038 |
+ "OP_BC_SUB", |
|
3039 |
+ "OP_BC_MUL", |
|
3040 |
+ "OP_BC_UDIV", |
|
3041 |
+ "OP_BC_SDIV", |
|
3042 |
+ "OP_BC_UREM", |
|
3043 |
+ "OP_BC_SREM", |
|
3044 |
+ "OP_BC_SHL", |
|
3045 |
+ "OP_BC_LSHR", |
|
3046 |
+ "OP_BC_ASHR", |
|
3047 |
+ "OP_BC_AND", |
|
3048 |
+ "OP_BC_OR", |
|
3049 |
+ "OP_BC_XOR", |
|
3050 |
+ |
|
3051 |
+ "OP_BC_TRUNC", |
|
3052 |
+ "OP_BC_SEXT", |
|
3053 |
+ "OP_BC_ZEXT", |
|
3054 |
+ |
|
3055 |
+ "OP_BC_BRANCH", |
|
3056 |
+ "OP_BC_JMP", |
|
3057 |
+ "OP_BC_RET", |
|
3058 |
+ "OP_BC_RET_VOID", |
|
3059 |
+ |
|
3060 |
+ "OP_BC_ICMP_EQ", |
|
3061 |
+ "OP_BC_ICMP_NE", |
|
3062 |
+ "OP_BC_ICMP_UGT", |
|
3063 |
+ "OP_BC_ICMP_UGE", |
|
3064 |
+ "OP_BC_ICMP_ULT", |
|
3065 |
+ "OP_BC_ICMP_ULE", |
|
3066 |
+ "OP_BC_ICMP_SGT", |
|
3067 |
+ "OP_BC_ICMP_SGE", |
|
3068 |
+ "OP_BC_ICMP_SLE", |
|
3069 |
+ "OP_BC_ICMP_SLT", |
|
3070 |
+ "OP_BC_SELECT", |
|
3071 |
+ "OP_BC_CALL_DIRECT", |
|
3072 |
+ "OP_BC_CALL_API", |
|
3073 |
+ "OP_BC_COPY", |
|
3074 |
+ "OP_BC_GEP1", |
|
3075 |
+ "OP_BC_GEPZ", |
|
3076 |
+ "OP_BC_GEPN", |
|
3077 |
+ "OP_BC_STORE", |
|
3078 |
+ "OP_BC_LOAD", |
|
3079 |
+ "OP_BC_MEMSET", |
|
3080 |
+ "OP_BC_MEMCPY", |
|
3081 |
+ "OP_BC_MEMMOVE", |
|
3082 |
+ "OP_BC_MEMCMP", |
|
3083 |
+ "OP_BC_ISBIGENDIAN", |
|
3084 |
+ "OP_BC_ABORT", |
|
3085 |
+ "OP_BC_BSWAP16", |
|
3086 |
+ "OP_BC_BSWAP32", |
|
3087 |
+ "OP_BC_BSWAP64", |
|
3088 |
+ "OP_BC_PTRDIFF32", |
|
3089 |
+ "OP_BC_PTRTOINT64", |
|
3090 |
+ "OP_BC_INVALID" /* last */ |
|
3091 |
+}; |
|
3092 |
+ |
|
3093 |
+extern unsigned cli_numapicalls; |
|
3094 |
+static void cli_bytetype_helper(const struct cli_bc *bc, unsigned tid) |
|
3095 |
+{ |
|
3096 |
+ unsigned i, j; |
|
3097 |
+ const struct cli_bc_type *ty = &bc->types[i]; |
|
3098 |
+ |
|
3099 |
+ |
|
3100 |
+ if (tid & 0x8000) { |
|
3101 |
+ printf("alloc "); |
|
3102 |
+ tid &= 0x7fff; |
|
3103 |
+ } |
|
3104 |
+ |
|
3105 |
+ if (tid < 65) { |
|
3106 |
+ printf("i%d", tid); |
|
3107 |
+ return; |
|
3108 |
+ } |
|
3109 |
+ |
|
3110 |
+ i = tid - 65; |
|
3111 |
+ |
|
3112 |
+ switch (ty->kind) { |
|
3113 |
+ case DFunctionType: |
|
3114 |
+ cli_bytetype_helper(bc, ty->containedTypes[0]); |
|
3115 |
+ printf(" func ( "); |
|
3116 |
+ for (j = 1; j < ty->numElements; ++j) { |
|
3117 |
+ cli_bytetype_helper(bc, ty->containedTypes[0]); |
|
3118 |
+ printf(" "); |
|
3119 |
+ } |
|
3120 |
+ printf(")"); |
|
3121 |
+ break; |
|
3122 |
+ case DPointerType: |
|
3123 |
+ cli_bytetype_helper(bc, ty->containedTypes[0]); |
|
3124 |
+ printf("*"); |
|
3125 |
+ break; |
|
3126 |
+ case DStructType: |
|
3127 |
+ case DPackedStructType: |
|
3128 |
+ printf("{ "); |
|
3129 |
+ for (j = 0; j < ty->numElements; ++j) { |
|
3130 |
+ cli_bytetype_helper(bc, ty->containedTypes[0]); |
|
3131 |
+ printf(" "); |
|
3132 |
+ } |
|
3133 |
+ printf("}"); |
|
3134 |
+ break; |
|
3135 |
+ case DArrayType: |
|
3136 |
+ printf("["); |
|
3137 |
+ printf("%d x ", ty->numElements); |
|
3138 |
+ cli_bytetype_helper(bc, ty->containedTypes[0]); |
|
3139 |
+ printf("]"); |
|
3140 |
+ break; |
|
3141 |
+ default: |
|
3142 |
+ printf("unhandled type kind %d, cannot parse", ty->kind); |
|
3143 |
+ break; |
|
3144 |
+ } |
|
3145 |
+ |
|
3146 |
+} |
|
3147 |
+ |
|
3148 |
+void cli_bytetype_describe(const struct cli_bc *bc) |
|
3149 |
+{ |
|
3150 |
+ unsigned i, tid; |
|
3151 |
+ |
|
3152 |
+ printf("found %d extra types of %d total, starting at tid %d\n", |
|
3153 |
+ bc->num_types, 64+bc->num_types, bc->start_tid); |
|
3154 |
+ |
|
3155 |
+ printf("TID KIND INTERNAL\n"); |
|
3156 |
+ printf("------------------------------------------------------------------------\n"); |
|
3157 |
+ for (i = 0, tid = 65; i < bc->num_types-1; ++i, ++tid) { |
|
3158 |
+ printf("%3d: %-20s", tid, bc_tystr[bc->types[i].kind]); |
|
3159 |
+ cli_bytetype_helper(bc, tid); |
|
3160 |
+ printf("\n"); |
|
3161 |
+ } |
|
3162 |
+ printf("------------------------------------------------------------------------\n"); |
|
3163 |
+} |
|
3164 |
+ |
|
3165 |
+void cli_bytevalue_describe(const struct cli_bc *bc, unsigned funcid) |
|
3166 |
+{ |
|
3167 |
+ unsigned i, j, total = 0; |
|
3168 |
+ const struct cli_bc_func *func; |
|
3169 |
+ |
|
3170 |
+ if (funcid >= bc->num_func) { |
|
3171 |
+ printf("bytecode diagnostic: funcid [%u] outside byecode numfuncs [%u]\n", |
|
3172 |
+ funcid, bc->num_func); |
|
3173 |
+ return; |
|
3174 |
+ } |
|
3175 |
+ // globals |
|
3176 |
+ printf("found a total of %d globals\n", bc->num_globals); |
|
3177 |
+ printf("GID ID VALUE\n"); |
|
3178 |
+ printf("------------------------------------------------------------------------\n"); |
|
3179 |
+ for (i = 0; i < bc->num_globals; ++i) { |
|
3180 |
+ printf("%3u [%3u]: ", i, i); |
|
3181 |
+ cli_bytetype_helper(bc, bc->globaltys[i]); |
|
3182 |
+ printf(" unknown\n"); |
|
3183 |
+ } |
|
3184 |
+ printf("------------------------------------------------------------------------\n"); |
|
3185 |
+ |
|
3186 |
+ // arguments and local values |
|
3187 |
+ func = &bc->funcs[funcid]; |
|
3188 |
+ printf("found %d values with %d arguments and %d locals\n", |
|
3189 |
+ func->numValues, func->numArgs, func->numLocals); |
|
3190 |
+ printf("VID ID VALUE\n"); |
|
3191 |
+ printf("------------------------------------------------------------------------\n"); |
|
3192 |
+ for (i = 0; i < func->numValues; ++i) { |
|
3193 |
+ printf("%3u [%3u]: ", i, total++); |
|
3194 |
+ cli_bytetype_helper(bc, func->types[i]); |
|
3195 |
+ if (i < func->numArgs) |
|
3196 |
+ printf("argument"); |
|
3197 |
+ printf("\n"); |
|
3198 |
+ } |
|
3199 |
+ printf("------------------------------------------------------------------------\n"); |
|
3200 |
+ |
|
3201 |
+ // constants |
|
3202 |
+ printf("found a total of %d constants\n", func->numConstants); |
|
3203 |
+ printf("CID ID VALUE\n"); |
|
3204 |
+ printf("------------------------------------------------------------------------\n"); |
|
3205 |
+ for (i = 0; i < func->numConstants; ++i) { |
|
3206 |
+ printf("%3u [%3u]: %llu(0x%llx)\n", i, total++, func->constants[i], func->constants[i]); |
|
3207 |
+ } |
|
3208 |
+ printf("------------------------------------------------------------------------\n"); |
|
3209 |
+ printf("found a total of %u total values\n", total); |
|
3210 |
+ printf("------------------------------------------------------------------------\n"); |
|
3211 |
+ return; |
|
3212 |
+} |
|
3213 |
+ |
|
3214 |
+void cli_byteinst_describe(const struct cli_bc_inst *inst, unsigned *bbnum) |
|
3215 |
+{ |
|
3216 |
+ unsigned j; |
|
3217 |
+ char inst_str[256]; |
|
3218 |
+ const struct cli_apicall *api; |
|
3219 |
+ |
|
3220 |
+ if (inst->opcode > OP_BC_INVALID) { |
|
3221 |
+ printf("opcode %u[%u] of type %u is not implemented yet!", |
|
3222 |
+ inst->opcode, inst->interp_op/5, inst->interp_op%5); |
|
3223 |
+ return; |
|
3224 |
+ } |
|
3225 |
+ |
|
3226 |
+ snprintf(inst_str, 256, "%-20s[%-3d/%3d/%3d]", bc_opstr[inst->opcode], |
|
3227 |
+ inst->opcode, inst->interp_op, inst->interp_op%inst->opcode); |
|
3228 |
+ printf("%-35s", inst_str); |
|
3229 |
+ switch (inst->opcode) { |
|
3230 |
+ // binary operations |
|
3231 |
+ case OP_BC_ADD: |
|
3232 |
+ printf("%d = %d + %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3233 |
+ break; |
|
3234 |
+ case OP_BC_SUB: |
|
3235 |
+ printf("%d = %d - %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3236 |
+ break; |
|
3237 |
+ case OP_BC_MUL: |
|
3238 |
+ printf("%d = %d * %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3239 |
+ break; |
|
3240 |
+ case OP_BC_UDIV: |
|
3241 |
+ printf("%d = %d / %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3242 |
+ break; |
|
3243 |
+ case OP_BC_SDIV: |
|
3244 |
+ printf("%d = %d / %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3245 |
+ break; |
|
3246 |
+ case OP_BC_UREM: |
|
3247 |
+ printf("%d = %d %% %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3248 |
+ break; |
|
3249 |
+ case OP_BC_SREM: |
|
3250 |
+ printf("%d = %d %% %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3251 |
+ break; |
|
3252 |
+ case OP_BC_SHL: |
|
3253 |
+ printf("%d = %d << %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3254 |
+ break; |
|
3255 |
+ case OP_BC_LSHR: |
|
3256 |
+ printf("%d = %d >> %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3257 |
+ break; |
|
3258 |
+ case OP_BC_ASHR: |
|
3259 |
+ printf("%d = %d >> %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3260 |
+ break; |
|
3261 |
+ case OP_BC_AND: |
|
3262 |
+ printf("%d = %d & %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3263 |
+ break; |
|
3264 |
+ case OP_BC_OR: |
|
3265 |
+ printf("%d = %d | %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3266 |
+ break; |
|
3267 |
+ case OP_BC_XOR: |
|
3268 |
+ printf("%d = %d ^ %d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3269 |
+ break; |
|
3270 |
+ |
|
3271 |
+ // casting operations |
|
3272 |
+ case OP_BC_TRUNC: |
|
3273 |
+ printf("%d = %d trunc %llx", inst->dest, inst->u.cast.source, inst->u.cast.mask); |
|
3274 |
+ break; |
|
3275 |
+ case OP_BC_SEXT: |
|
3276 |
+ printf("%d = %d sext %llx", inst->dest, inst->u.cast.source, inst->u.cast.mask); |
|
3277 |
+ break; |
|
3278 |
+ case OP_BC_ZEXT: |
|
3279 |
+ printf("%d = %d zext %llx", inst->dest, inst->u.cast.source, inst->u.cast.mask); |
|
3280 |
+ break; |
|
3281 |
+ |
|
3282 |
+ // control operations (termination instructions) |
|
3283 |
+ case OP_BC_BRANCH: |
|
3284 |
+ printf("br %d ? bb.%d : bb.%d", inst->u.branch.condition, |
|
3285 |
+ inst->u.branch.br_true, inst->u.branch.br_false); |
|
3286 |
+ (*bbnum)++; |
|
3287 |
+ break; |
|
3288 |
+ case OP_BC_JMP: |
|
3289 |
+ printf("jmp bb.%d", inst->u.jump); |
|
3290 |
+ (*bbnum)++; |
|
3291 |
+ break; |
|
3292 |
+ case OP_BC_RET: |
|
3293 |
+ printf("ret %d", inst->u.unaryop); |
|
3294 |
+ (*bbnum)++; |
|
3295 |
+ break; |
|
3296 |
+ case OP_BC_RET_VOID: |
|
3297 |
+ printf("ret void"); |
|
3298 |
+ (*bbnum)++; |
|
3299 |
+ break; |
|
3300 |
+ |
|
3301 |
+ // comparison operations |
|
3302 |
+ case OP_BC_ICMP_EQ: |
|
3303 |
+ printf("%d = (%d == %d)", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3304 |
+ break; |
|
3305 |
+ case OP_BC_ICMP_NE: |
|
3306 |
+ printf("%d = (%d != %d)", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3307 |
+ break; |
|
3308 |
+ case OP_BC_ICMP_UGT: |
|
3309 |
+ printf("%d = (%d > %d)", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3310 |
+ break; |
|
3311 |
+ case OP_BC_ICMP_UGE: |
|
3312 |
+ printf("%d = (%d >= %d)", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3313 |
+ break; |
|
3314 |
+ case OP_BC_ICMP_ULT: |
|
3315 |
+ printf("%d = (%d > %d)", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3316 |
+ break; |
|
3317 |
+ case OP_BC_ICMP_ULE: |
|
3318 |
+ printf("%d = (%d >= %d)", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3319 |
+ break; |
|
3320 |
+ case OP_BC_ICMP_SGT: |
|
3321 |
+ printf("%d = (%d > %d)", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3322 |
+ break; |
|
3323 |
+ case OP_BC_ICMP_SGE: |
|
3324 |
+ printf("%d = (%d >= %d)", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3325 |
+ break; |
|
3326 |
+ case OP_BC_ICMP_SLE: |
|
3327 |
+ printf("%d = (%d <= %d)", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3328 |
+ break; |
|
3329 |
+ case OP_BC_ICMP_SLT: |
|
3330 |
+ printf("%d = (%d < %d)", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3331 |
+ break; |
|
3332 |
+ case OP_BC_SELECT: |
|
3333 |
+ printf("%d = %d ? %d : %d)", inst->dest, inst->u.three[0], |
|
3334 |
+ inst->u.three[1], inst->u.three[2]); |
|
3335 |
+ break; |
|
3336 |
+ |
|
3337 |
+ // function calling |
|
3338 |
+ case OP_BC_CALL_DIRECT: |
|
3339 |
+ printf("%d = call F.%d (", inst->dest, inst->u.ops.funcid); |
|
3340 |
+ for (j = 0; j < inst->u.ops.numOps; ++j) { |
|
3341 |
+ if (j == inst->u.ops.numOps-1) { |
|
3342 |
+ printf("%d", inst->u.ops.ops[j]); |
|
3343 |
+ } |
|
3344 |
+ else { |
|
3345 |
+ printf("%d, ", inst->u.ops.ops[j]); |
|
3346 |
+ } |
|
3347 |
+ } |
|
3348 |
+ printf(")"); |
|
3349 |
+ break; |
|
3350 |
+ case OP_BC_CALL_API: |
|
3351 |
+ { |
|
3352 |
+ if (inst->u.ops.funcid > cli_numapicalls) { |
|
3353 |
+ printf("apicall FID %d not yet implemented!\n", inst->u.ops.funcid); |
|
3354 |
+ break; |
|
3355 |
+ } |
|
3356 |
+ api = &cli_apicalls[inst->u.ops.funcid]; |
|
3357 |
+ switch (api->kind) { |
|
3358 |
+ case 0: |
|
3359 |
+ printf("%d = %s[%d] (%d, %d)", inst->dest, api->name, |
|
3360 |
+ inst->u.ops.funcid, inst->u.ops.ops[0], inst->u.ops.ops[1]); |
|
3361 |
+ break; |
|
3362 |
+ case 1: |
|
3363 |
+ printf("%d = %s[%d] (p.%d, %d)", inst->dest, api->name, |
|
3364 |
+ inst->u.ops.funcid, inst->u.ops.ops[0], inst->u.ops.ops[1]); |
|
3365 |
+ break; |
|
3366 |
+ case 2: |
|
3367 |
+ printf("%d = %s[%d] (%d)", inst->dest, api->name, |
|
3368 |
+ inst->u.ops.funcid, inst->u.ops.ops[0]); |
|
3369 |
+ break; |
|
3370 |
+ case 3: |
|
3371 |
+ printf("p.%d = %s[%d] (%d)", inst->dest, api->name, |
|
3372 |
+ inst->u.ops.funcid, inst->u.ops.ops[0]); |
|
3373 |
+ break; |
|
3374 |
+ case 4: |
|
3375 |
+ printf("%d = %s[%d] (p.%d, %d, %d, %d, %d)", inst->dest, api->name, |
|
3376 |
+ inst->u.ops.funcid, inst->u.ops.ops[0], inst->u.ops.ops[1], |
|
3377 |
+ inst->u.ops.ops[2], inst->u.ops.ops[3], inst->u.ops.ops[4]); |
|
3378 |
+ break; |
|
3379 |
+ case 5: |
|
3380 |
+ printf("%d = %s[%d] ()", inst->dest, api->name, |
|
3381 |
+ inst->u.ops.funcid); |
|
3382 |
+ break; |
|
3383 |
+ case 6: |
|
3384 |
+ printf("p.%d = %s[%d] (%d, %d)", inst->dest, api->name, |
|
3385 |
+ inst->u.ops.funcid, inst->u.ops.ops[0], inst->u.ops.ops[1]); |
|
3386 |
+ break; |
|
3387 |
+ case 7: |
|
3388 |
+ printf("%d = %s[%d] (%d, %d, %d)", inst->dest, api->name, |
|
3389 |
+ inst->u.ops.funcid, inst->u.ops.ops[0], inst->u.ops.ops[1], |
|
3390 |
+ inst->u.ops.ops[2]); |
|
3391 |
+ break; |
|
3392 |
+ case 8: |
|
3393 |
+ printf("%d = %s[%d] (p.%d, %d, p.%d, %d)", inst->dest, api->name, |
|
3394 |
+ inst->u.ops.funcid, inst->u.ops.ops[0], inst->u.ops.ops[1], |
|
3395 |
+ inst->u.ops.ops[2], inst->u.ops.ops[3]); |
|
3396 |
+ break; |
|
3397 |
+ case 9: |
|
3398 |
+ printf("%d = %s[%d] (p.%d, %d, %d)", inst->dest, api->name, |
|
3399 |
+ inst->u.ops.funcid, inst->u.ops.ops[0], inst->u.ops.ops[1], |
|
3400 |
+ inst->u.ops.ops[2]); |
|
3401 |
+ break; |
|
3402 |
+ default: |
|
3403 |
+ printf("type %u apicalls not yet implemented!\n", api->kind); |
|
3404 |
+ break; |
|
3405 |
+ } |
|
3406 |
+ } |
|
3407 |
+ break; |
|
3408 |
+ |
|
3409 |
+ // memory operations |
|
3410 |
+ case OP_BC_COPY: |
|
3411 |
+ printf("cp %d -> %d", inst->u.binop[0], inst->u.binop[1]); |
|
3412 |
+ break; |
|
3413 |
+ case OP_BC_GEP1: |
|
3414 |
+ printf("%d = gep1 p.%d + (%d * %d)", inst->dest, inst->u.three[1], |
|
3415 |
+ inst->u.three[2], inst->u.three[0]); |
|
3416 |
+ break; |
|
3417 |
+ case OP_BC_GEPZ: |
|
3418 |
+ printf("%d = gepz p.%d + (%d)", inst->dest, |
|
3419 |
+ inst->u.three[1], inst->u.three[2]); |
|
3420 |
+ break; |
|
3421 |
+ case OP_BC_GEPN: |
|
3422 |
+ printf("illegal opcode, impossible"); |
|
3423 |
+ break; |
|
3424 |
+ case OP_BC_STORE: |
|
3425 |
+ printf("store %d -> p.%d", inst->u.binop[0], inst->u.binop[1]); |
|
3426 |
+ break; |
|
3427 |
+ case OP_BC_LOAD: |
|
3428 |
+ printf("load %d <- p.%d", inst->dest, inst->u.unaryop); |
|
3429 |
+ break; |
|
3430 |
+ |
|
3431 |
+ // llvm instrinsics |
|
3432 |
+ case OP_BC_MEMSET: |
|
3433 |
+ printf("%d = memset (p.%d, %d, %d)", inst->dest, inst->u.three[0], |
|
3434 |
+ inst->u.three[1], inst->u.three[2]); |
|
3435 |
+ break; |
|
3436 |
+ case OP_BC_MEMCPY: |
|
3437 |
+ printf("%d = memcpy (p.%d, p.%d, %d)", inst->dest, inst->u.three[0], |
|
3438 |
+ inst->u.three[1], inst->u.three[2]); |
|
3439 |
+ break; |
|
3440 |
+ case OP_BC_MEMMOVE: |
|
3441 |
+ printf("%d = memmove (p.%d, p.%d, %d)", inst->dest, inst->u.three[0], |
|
3442 |
+ inst->u.three[1], inst->u.three[2]); |
|
3443 |
+ break; |
|
3444 |
+ case OP_BC_MEMCMP: |
|
3445 |
+ printf("%d = memcmp (p.%d, p.%d, %d)", inst->dest, inst->u.three[0], |
|
3446 |
+ inst->u.three[1], inst->u.three[2]); |
|
3447 |
+ break; |
|
3448 |
+ |
|
3449 |
+ // utility operations |
|
3450 |
+ case OP_BC_ISBIGENDIAN: |
|
3451 |
+ printf("%d = isbigendian()", inst->dest); |
|
3452 |
+ break; |
|
3453 |
+ case OP_BC_ABORT: |
|
3454 |
+ printf("ABORT!!"); |
|
3455 |
+ break; |
|
3456 |
+ case OP_BC_BSWAP16: |
|
3457 |
+ printf("%d = bswap16 %d", inst->dest, inst->u.unaryop); |
|
3458 |
+ break; |
|
3459 |
+ case OP_BC_BSWAP32: |
|
3460 |
+ printf("%d = bswap32 %d", inst->dest, inst->u.unaryop); |
|
3461 |
+ break; |
|
3462 |
+ case OP_BC_BSWAP64: |
|
3463 |
+ printf("%d = bswap64 %d", inst->dest, inst->u.unaryop); |
|
3464 |
+ break; |
|
3465 |
+ case OP_BC_PTRDIFF32: |
|
3466 |
+ printf("%d = ptrdiff32 p.%d p.%d", inst->dest, inst->u.binop[0], inst->u.binop[1]); |
|
3467 |
+ break; |
|
3468 |
+ case OP_BC_PTRTOINT64: |
|
3469 |
+ printf("%d = ptrtoint64 p.%d", inst->dest, inst->u.unaryop); |
|
3470 |
+ break; |
|
3471 |
+ case OP_BC_INVALID: /* last */ |
|
3472 |
+ printf("INVALID!!"); |
|
3473 |
+ break; |
|
3474 |
+ |
|
3475 |
+ default: |
|
3476 |
+ // redundant check |
|
3477 |
+ printf("opcode %u[%u] of type %u is not implemented yet!", |
|
3478 |
+ inst->opcode, inst->interp_op/5, inst->interp_op%5); |
|
3479 |
+ break; |
|
3480 |
+ } |
|
3481 |
+} |
|
3482 |
+ |
|
3483 |
+void cli_bytefunc_describe(const struct cli_bc *bc, unsigned funcid) |
|
3484 |
+{ |
|
3485 |
+ unsigned i, bbnum, bbpre; |
|
3486 |
+ const struct cli_bc_func *func; |
|
3487 |
+ |
|
3488 |
+ if (funcid >= bc->num_func) { |
|
3489 |
+ printf("bytecode diagnostic: funcid [%u] outside byecode numfuncs [%u]\n", |
|
3490 |
+ funcid, bc->num_func); |
|
3491 |
+ return; |
|
3492 |
+ } |
|
3493 |
+ |
|
3494 |
+ func = &bc->funcs[funcid]; |
|
3495 |
+ |
|
3496 |
+ printf("FUNCTION ID: F.%d -> NUMINSTS %d\n", funcid, func->numInsts); |
|
3497 |
+ printf("BB IDX OPCODE [ID /IID/MOD] INST\n"); |
|
3498 |
+ printf("------------------------------------------------------------------------\n"); |
|
3499 |
+ bbpre = 0; bbnum = 0; |
|
3500 |
+ for (i = 0; i < func->numInsts; ++i) { |
|
3501 |
+ if (bbpre != bbnum) { |
|
3502 |
+ printf("\n"); |
|
3503 |
+ bbpre = bbnum; |
|
3504 |
+ } |
|
3505 |
+ |
|
3506 |
+ printf("%3d %3d ", bbnum, i); |
|
3507 |
+ cli_byteinst_describe(&func->allinsts[i], &bbnum); |
|
3508 |
+ printf("\n"); |
|
3509 |
+ } |
|
3510 |
+ printf("------------------------------------------------------------------------\n"); |
|
3511 |
+} |
... | ... |
@@ -114,7 +114,14 @@ int cli_bytecode_prepare2(struct cl_engine *engine, struct cli_all_bc *allbc, un |
114 | 114 |
int cli_bytecode_run(const struct cli_all_bc *bcs, const struct cli_bc *bc, struct cli_bc_ctx *ctx); |
115 | 115 |
void cli_bytecode_destroy(struct cli_bc *bc); |
116 | 116 |
int cli_bytecode_done(struct cli_all_bc *allbc); |
117 |
+ |
|
118 |
+/* Bytecode IR descriptions */ |
|
117 | 119 |
void cli_bytecode_describe(const struct cli_bc *bc); |
120 |
+void cli_bytetype_describe(const struct cli_bc *bc); |
|
121 |
+void cli_bytevalue_describe(const struct cli_bc *bc, unsigned funcid); |
|
122 |
+void cli_byteinst_describe(const struct cli_bc_inst *inst, unsigned *bbnum); |
|
123 |
+void cli_bytefunc_describe(const struct cli_bc *bc, unsigned funcid); |
|
124 |
+ |
|
118 | 125 |
|
119 | 126 |
/* Hooks */ |
120 | 127 |
struct cli_exe_info; |
... | ... |
@@ -63,11 +63,13 @@ |
63 | 63 |
|
64 | 64 |
uint32_t cli_bcapi_test1(struct cli_bc_ctx *ctx, uint32_t a, uint32_t b) |
65 | 65 |
{ |
66 |
+ UNUSEDPARAM(ctx); |
|
66 | 67 |
return (a==0xf00dbeef && b==0xbeeff00d) ? 0x12345678 : 0x55; |
67 | 68 |
} |
68 | 69 |
|
69 | 70 |
uint32_t cli_bcapi_test2(struct cli_bc_ctx *ctx, uint32_t a) |
70 | 71 |
{ |
72 |
+ UNUSEDPARAM(ctx); |
|
71 | 73 |
return a == 0xf00d ? 0xd00f : 0x5555; |
72 | 74 |
} |
73 | 75 |
|
... | ... |
@@ -131,6 +133,7 @@ int32_t cli_bcapi_seek(struct cli_bc_ctx* ctx, int32_t pos, uint32_t whence) |
131 | 131 |
|
132 | 132 |
uint32_t cli_bcapi_debug_print_str(struct cli_bc_ctx *ctx, const uint8_t *str, uint32_t len) |
133 | 133 |
{ |
134 |
+ UNUSEDPARAM(len); |
|
134 | 135 |
cli_event_fastdata(EV, BCEV_DBG_STR, str, strlen((const char*)str)); |
135 | 136 |
cli_dbgmsg("bytecode debug: %s\n", str); |
136 | 137 |
return 0; |
... | ... |
@@ -151,6 +154,7 @@ uint32_t cli_bcapi_debug_print_uint(struct cli_bc_ctx *ctx, uint32_t a) |
151 | 151 |
* executing */ |
152 | 152 |
uint32_t cli_bcapi_setvirusname(struct cli_bc_ctx* ctx, const uint8_t *name, uint32_t len) |
153 | 153 |
{ |
154 |
+ UNUSEDPARAM(len); |
|
154 | 155 |
ctx->virname = (const char*)name; |
155 | 156 |
return 0; |
156 | 157 |
} |
... | ... |
@@ -160,7 +164,8 @@ uint32_t cli_bcapi_disasm_x86(struct cli_bc_ctx *ctx, struct DISASM_RESULT *res, |
160 | 160 |
int n; |
161 | 161 |
const unsigned char *buf; |
162 | 162 |
const unsigned char* next; |
163 |
- if (!res || !ctx->fmap || ctx->off >= ctx->fmap->len) { |
|
163 |
+ UNUSEDPARAM(len); |
|
164 |
+ if (!res || !ctx->fmap || (size_t)(ctx->off) >= ctx->fmap->len) { |
|
164 | 165 |
API_MISUSE(); |
165 | 166 |
return -1; |
166 | 167 |
} |
... | ... |
@@ -255,6 +260,7 @@ uint32_t cli_bcapi_trace_scope(struct cli_bc_ctx *ctx, const uint8_t *scope, uin |
255 | 255 |
|
256 | 256 |
uint32_t cli_bcapi_trace_directory(struct cli_bc_ctx *ctx, const uint8_t* dir, uint32_t dummy) |
257 | 257 |
{ |
258 |
+ UNUSEDPARAM(dummy); |
|
258 | 259 |
if (LIKELY(!ctx->trace_level)) |
259 | 260 |
return 0; |
260 | 261 |
ctx->directory = (const char*)dir ? (const char*)dir : ""; |
... | ... |
@@ -314,6 +320,7 @@ uint32_t cli_bcapi_trace_value(struct cli_bc_ctx *ctx, const uint8_t* name, uint |
314 | 314 |
|
315 | 315 |
uint32_t cli_bcapi_trace_ptr(struct cli_bc_ctx *ctx, const uint8_t* ptr, uint32_t dummy) |
316 | 316 |
{ |
317 |
+ UNUSEDPARAM(dummy); |
|
317 | 318 |
if (LIKELY(ctx->trace_level < trace_val)) |
318 | 319 |
return 0; |
319 | 320 |
if (ctx->trace_level&0x80) { |
... | ... |
@@ -395,7 +402,7 @@ int32_t cli_bcapi_file_find_limit(struct cli_bc_ctx *ctx , const uint8_t* data, |
395 | 395 |
for (;;) { |
396 | 396 |
const char *p; |
397 | 397 |
int32_t readlen = sizeof(buf); |
398 |
- if (off + readlen > limit) { |
|
398 |
+ if (off + readlen > (unsigned int)limit) { |
|
399 | 399 |
readlen = limit - off; |
400 | 400 |
if (readlen < 0) |
401 | 401 |
return -1; |
... | ... |
@@ -463,6 +470,7 @@ int32_t cli_bcapi_fill_buffer(struct cli_bc_ctx *ctx, uint8_t* buf, |
463 | 463 |
uint32_t pos, uint32_t fill) |
464 | 464 |
{ |
465 | 465 |
int32_t res, remaining, tofill; |
466 |
+ UNUSEDPARAM(fill); |
|
466 | 467 |
if (!buf || !buflen || buflen > CLI_MAX_ALLOCATION || filled > buflen) { |
467 | 468 |
cli_dbgmsg("fill_buffer1\n"); |
468 | 469 |
API_MISUSE(); |
... | ... |
@@ -586,7 +594,7 @@ int32_t cli_bcapi_hashset_new(struct cli_bc_ctx *ctx ) |
586 | 586 |
|
587 | 587 |
static struct cli_hashset *get_hashset(struct cli_bc_ctx *ctx, int32_t id) |
588 | 588 |
{ |
589 |
- if (id < 0 || id >= ctx->nhashsets || !ctx->hashsets) { |
|
589 |
+ if (id < 0 || (unsigned int)id >= ctx->nhashsets || !ctx->hashsets) { |
|
590 | 590 |
API_MISUSE(); |
591 | 591 |
return NULL; |
592 | 592 |
} |
... | ... |
@@ -629,7 +637,7 @@ int32_t cli_bcapi_hashset_done(struct cli_bc_ctx *ctx , int32_t id) |
629 | 629 |
if (!s) |
630 | 630 |
return -1; |
631 | 631 |
cli_hashset_destroy(s); |
632 |
- if (id == ctx->nhashsets-1) { |
|
632 |
+ if ((unsigned int)id == ctx->nhashsets-1) { |
|
633 | 633 |
ctx->nhashsets--; |
634 | 634 |
if (!ctx->nhashsets) { |
635 | 635 |
free(ctx->hashsets); |
... | ... |
@@ -693,7 +701,7 @@ int32_t cli_bcapi_buffer_pipe_new_fromfile(struct cli_bc_ctx *ctx , uint32_t at) |
693 | 693 |
|
694 | 694 |
static struct bc_buffer *get_buffer(struct cli_bc_ctx *ctx, int32_t id) |
695 | 695 |
{ |
696 |
- if (!ctx->buffers || id < 0 || id >= ctx->nbuffers) { |
|
696 |
+ if (!ctx->buffers || id < 0 || (unsigned int)id >= ctx->nbuffers) { |
|
697 | 697 |
cli_dbgmsg("bytecode api: invalid buffer id %u\n", id); |
698 | 698 |
return NULL; |
699 | 699 |
} |
... | ... |
@@ -839,7 +847,7 @@ int32_t cli_bcapi_inflate_init(struct cli_bc_ctx *ctx, int32_t from, int32_t to, |
839 | 839 |
|
840 | 840 |
static struct bc_inflate *get_inflate(struct cli_bc_ctx *ctx, int32_t id) |
841 | 841 |
{ |
842 |
- if (id < 0 || id >= ctx->ninflates || !ctx->inflates) |
|
842 |
+ if (id < 0 || (unsigned int)id >= ctx->ninflates || !ctx->inflates) |
|
843 | 843 |
return NULL; |
844 | 844 |
return &ctx->inflates[id]; |
845 | 845 |
} |
... | ... |
@@ -921,6 +929,7 @@ int32_t cli_bcapi_bytecode_rt_error(struct cli_bc_ctx *ctx , int32_t id) |
921 | 921 |
{ |
922 | 922 |
int32_t line = id >> 8; |
923 | 923 |
int32_t col = id&0xff; |
924 |
+ UNUSEDPARAM(ctx); |
|
924 | 925 |
cli_warnmsg("Bytecode runtime error at line %u, col %u\n", line, col); |
925 | 926 |
return 0; |
926 | 927 |
} |
... | ... |
@@ -963,7 +972,7 @@ int32_t cli_bcapi_jsnorm_init(struct cli_bc_ctx *ctx, int32_t from) |
963 | 963 |
|
964 | 964 |
static struct bc_jsnorm *get_jsnorm(struct cli_bc_ctx *ctx, int32_t id) |
965 | 965 |
{ |
966 |
- if (id < 0 || id >= ctx->njsnorms || !ctx->jsnorms) |
|
966 |
+ if (id < 0 || (unsigned int)id >= ctx->njsnorms || !ctx->jsnorms) |
|
967 | 967 |
return NULL; |
968 | 968 |
return &ctx->jsnorms[id]; |
969 | 969 |
} |
... | ... |
@@ -1013,6 +1022,7 @@ static inline double myround(double a) |
1013 | 1013 |
int32_t cli_bcapi_ilog2(struct cli_bc_ctx *ctx, uint32_t a, uint32_t b) |
1014 | 1014 |
{ |
1015 | 1015 |
double f; |
1016 |
+ UNUSEDPARAM(ctx); |
|
1016 | 1017 |
if (!b) |
1017 | 1018 |
return 0x7fffffff; |
1018 | 1019 |
/* log(a/b) is -32..32, so 2^26*32=2^31 covers the entire range of int32 */ |
... | ... |
@@ -1022,6 +1032,7 @@ int32_t cli_bcapi_ilog2(struct cli_bc_ctx *ctx, uint32_t a, uint32_t b) |
1022 | 1022 |
|
1023 | 1023 |
int32_t cli_bcapi_ipow(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c) |
1024 | 1024 |
{ |
1025 |
+ UNUSEDPARAM(ctx); |
|
1025 | 1026 |
if (!a && b < 0) |
1026 | 1027 |
return 0x7fffffff; |
1027 | 1028 |
return (int32_t)myround(c*pow(a,b)); |
... | ... |
@@ -1030,6 +1041,7 @@ int32_t cli_bcapi_ipow(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c) |
1030 | 1030 |
uint32_t cli_bcapi_iexp(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c) |
1031 | 1031 |
{ |
1032 | 1032 |
double f; |
1033 |
+ UNUSEDPARAM(ctx); |
|
1033 | 1034 |
if (!b) |
1034 | 1035 |
return 0x7fffffff; |
1035 | 1036 |
f= c*exp((double)a/b); |
... | ... |
@@ -1039,6 +1051,7 @@ uint32_t cli_bcapi_iexp(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c) |
1039 | 1039 |
int32_t cli_bcapi_isin(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c) |
1040 | 1040 |
{ |
1041 | 1041 |
double f; |
1042 |
+ UNUSEDPARAM(ctx); |
|
1042 | 1043 |
if (!b) |
1043 | 1044 |
return 0x7fffffff; |
1044 | 1045 |
f = c*sin((double)a/b); |
... | ... |
@@ -1048,6 +1061,7 @@ int32_t cli_bcapi_isin(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c) |
1048 | 1048 |
int32_t cli_bcapi_icos(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c) |
1049 | 1049 |
{ |
1050 | 1050 |
double f; |
1051 |
+ UNUSEDPARAM(ctx); |
|
1051 | 1052 |
if (!b) |
1052 | 1053 |
return 0x7fffffff; |
1053 | 1054 |
f = c*cos((double)a/b); |
... | ... |
@@ -1074,6 +1088,8 @@ int32_t cli_bcapi_hex2ui(struct cli_bc_ctx *ctx, uint32_t ah, uint32_t bh) |
1074 | 1074 |
{ |
1075 | 1075 |
char result = 0; |
1076 | 1076 |
unsigned char in[2]; |
1077 |
+ UNUSEDPARAM(ctx); |
|
1078 |
+ |
|
1077 | 1079 |
in[0] = ah; |
1078 | 1080 |
in[1] = bh; |
1079 | 1081 |
|
... | ... |
@@ -1086,6 +1102,8 @@ int32_t cli_bcapi_atoi(struct cli_bc_ctx *ctx, const uint8_t* str, int32_t len) |
1086 | 1086 |
{ |
1087 | 1087 |
int32_t number = 0; |
1088 | 1088 |
const uint8_t *end = str + len; |
1089 |
+ UNUSEDPARAM(ctx); |
|
1090 |
+ |
|
1089 | 1091 |
while (isspace(*str) && str < end) str++; |
1090 | 1092 |
if (str == end) |
1091 | 1093 |
return -1;/* all spaces */ |
... | ... |
@@ -1104,6 +1122,8 @@ int32_t cli_bcapi_atoi(struct cli_bc_ctx *ctx, const uint8_t* str, int32_t len) |
1104 | 1104 |
|
1105 | 1105 |
uint32_t cli_bcapi_debug_print_str_start(struct cli_bc_ctx *ctx , const uint8_t* s, uint32_t len) |
1106 | 1106 |
{ |
1107 |
+ UNUSEDPARAM(ctx); |
|
1108 |
+ |
|
1107 | 1109 |
if (!s || len <= 0) |
1108 | 1110 |
return -1; |
1109 | 1111 |
cli_event_fastdata(EV, BCEV_DBG_STR, s, len); |
... | ... |
@@ -1113,6 +1133,8 @@ uint32_t cli_bcapi_debug_print_str_start(struct cli_bc_ctx *ctx , const uint8_t* |
1113 | 1113 |
|
1114 | 1114 |
uint32_t cli_bcapi_debug_print_str_nonl(struct cli_bc_ctx *ctx , const uint8_t* s, uint32_t len) |
1115 | 1115 |
{ |
1116 |
+ UNUSEDPARAM(ctx); |
|
1117 |
+ |
|
1116 | 1118 |
if (!s || len <= 0) |
1117 | 1119 |
return -1; |
1118 | 1120 |
if (!cli_debug_flag) |
... | ... |
@@ -1123,14 +1145,16 @@ uint32_t cli_bcapi_debug_print_str_nonl(struct cli_bc_ctx *ctx , const uint8_t* |
1123 | 1123 |
uint32_t cli_bcapi_entropy_buffer(struct cli_bc_ctx *ctx , uint8_t* s, int32_t len) |
1124 | 1124 |
{ |
1125 | 1125 |
uint32_t probTable[256]; |
1126 |
- unsigned i; |
|
1126 |
+ unsigned int i; |
|
1127 | 1127 |
double entropy = 0; |
1128 | 1128 |
double log2 = log(2); |
1129 | 1129 |
|
1130 |
+ UNUSEDPARAM(ctx); |
|
1131 |
+ |
|
1130 | 1132 |
if (!s || len <= 0) |
1131 | 1133 |
return -1; |
1132 | 1134 |
memset(probTable, 0, sizeof(probTable)); |
1133 |
- for (i=0;i<len;i++) { |
|
1135 |
+ for (i=0;i<(unsigned int)len;i++) { |
|
1134 | 1136 |
probTable[s[i]]++; |
1135 | 1137 |
} |
1136 | 1138 |
for (i=0;i<256;i++) { |
... | ... |
@@ -1162,7 +1186,7 @@ int32_t cli_bcapi_map_new(struct cli_bc_ctx *ctx, int32_t keysize, int32_t value |
1162 | 1162 |
|
1163 | 1163 |
static struct cli_map *get_hashtab(struct cli_bc_ctx *ctx, int32_t id) |
1164 | 1164 |
{ |
1165 |
- if (id < 0 || id >= ctx->nmaps || !ctx->maps) |
|
1165 |
+ if (id < 0 || (unsigned int)id >= ctx->nmaps || !ctx->maps) |
|
1166 | 1166 |
return NULL; |
1167 | 1167 |
return &ctx->maps[id]; |
1168 | 1168 |
} |
... | ... |
@@ -1223,7 +1247,7 @@ int32_t cli_bcapi_map_done(struct cli_bc_ctx *ctx , int32_t id) |
1223 | 1223 |
if (!s) |
1224 | 1224 |
return -1; |
1225 | 1225 |
cli_map_delete(s); |
1226 |
- if (id == ctx->nmaps-1) { |
|
1226 |
+ if ((unsigned int)id == ctx->nmaps-1) { |
|
1227 | 1227 |
ctx->nmaps--; |
1228 | 1228 |
if (!ctx->nmaps) { |
1229 | 1229 |
free(ctx->maps); |
... | ... |
@@ -1239,11 +1263,13 @@ int32_t cli_bcapi_map_done(struct cli_bc_ctx *ctx , int32_t id) |
1239 | 1239 |
|
1240 | 1240 |
uint32_t cli_bcapi_engine_functionality_level(struct cli_bc_ctx *ctx) |
1241 | 1241 |
{ |
1242 |
+ UNUSEDPARAM(ctx); |
|
1242 | 1243 |
return cl_retflevel(); |
1243 | 1244 |
} |
1244 | 1245 |
|
1245 | 1246 |
uint32_t cli_bcapi_engine_dconf_level(struct cli_bc_ctx *ctx) |
1246 | 1247 |
{ |
1248 |
+ UNUSEDPARAM(ctx); |
|
1247 | 1249 |
return CL_FLEVEL_DCONF; |
1248 | 1250 |
} |
1249 | 1251 |
|
... | ... |
@@ -1270,7 +1296,7 @@ int32_t cli_bcapi_extract_set_container(struct cli_bc_ctx *ctx, uint32_t ftype) |
1270 | 1270 |
int32_t cli_bcapi_input_switch(struct cli_bc_ctx *ctx , int32_t extracted_file) |
1271 | 1271 |
{ |
1272 | 1272 |
fmap_t *map; |
1273 |
- if (ctx->extracted_file_input == extracted_file) |
|
1273 |
+ if (ctx->extracted_file_input == (unsigned int)extracted_file) |
|
1274 | 1274 |
return 0; |
1275 | 1275 |
if (!extracted_file) { |
1276 | 1276 |
cli_dbgmsg("bytecode api: input switched back to main file\n"); |
... | ... |
@@ -1304,6 +1330,7 @@ uint32_t cli_bcapi_get_environment(struct cli_bc_ctx *ctx , struct cli_environme |
1304 | 1304 |
|
1305 | 1305 |
uint32_t cli_bcapi_disable_bytecode_if(struct cli_bc_ctx *ctx , const int8_t* reason, uint32_t len, uint32_t cond) |
1306 | 1306 |
{ |
1307 |
+ UNUSEDPARAM(len); |
|
1307 | 1308 |
if (ctx->bc->kind != BC_STARTUP) { |
1308 | 1309 |
cli_dbgmsg("Bytecode must be BC_STARTUP to call disable_bytecode_if\n"); |
1309 | 1310 |
return -1; |
... | ... |
@@ -1320,6 +1347,7 @@ uint32_t cli_bcapi_disable_bytecode_if(struct cli_bc_ctx *ctx , const int8_t* re |
1320 | 1320 |
|
1321 | 1321 |
uint32_t cli_bcapi_disable_jit_if(struct cli_bc_ctx *ctx , const int8_t* reason, uint32_t len, uint32_t cond) |
1322 | 1322 |
{ |
1323 |
+ UNUSEDPARAM(len); |
|
1323 | 1324 |
if (ctx->bc->kind != BC_STARTUP) { |
1324 | 1325 |
cli_dbgmsg("Bytecode must be BC_STARTUP to call disable_jit_if\n"); |
1325 | 1326 |
return -1; |
... | ... |
@@ -1340,6 +1368,7 @@ int32_t cli_bcapi_version_compare(struct cli_bc_ctx *ctx , const uint8_t* lhs, u |
1340 | 1340 |
{ |
1341 | 1341 |
unsigned i = 0, j = 0; |
1342 | 1342 |
unsigned long li=0, ri=0; |
1343 |
+ UNUSEDPARAM(ctx); |
|
1343 | 1344 |
do { |
1344 | 1345 |
while (i < lhs_len && j < rhs_len && lhs[i] == rhs[j] && |
1345 | 1346 |
!isdigit(lhs[i]) && !isdigit(rhs[j])) { |
... | ... |
@@ -1451,11 +1480,11 @@ int32_t cli_bcapi_pdf_lookupobj(struct cli_bc_ctx *ctx , uint32_t objid) |
1451 | 1451 |
uint32_t cli_bcapi_pdf_getobjsize(struct cli_bc_ctx *ctx , int32_t objidx) |
1452 | 1452 |
{ |
1453 | 1453 |
if (!ctx->pdf_phase || |
1454 |
- objidx >= ctx->pdf_nobjs || |
|
1454 |
+ (uint32_t)objidx >= ctx->pdf_nobjs || |
|
1455 | 1455 |
ctx->pdf_phase == PDF_PHASE_POSTDUMP /* map is obj itself, no access to pdf anymore */ |
1456 | 1456 |
) |
1457 | 1457 |
return 0; |
1458 |
- if (objidx + 1 == ctx->pdf_nobjs) |
|
1458 |
+ if ((uint32_t)(objidx + 1) == ctx->pdf_nobjs) |
|
1459 | 1459 |
return ctx->pdf_size - ctx->pdf_objs[objidx].start; |
1460 | 1460 |
return ctx->pdf_objs[objidx+1].start - ctx->pdf_objs[objidx].start - 4; |
1461 | 1461 |
} |
... | ... |
@@ -1471,7 +1500,7 @@ const uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t objidx, uin |
1471 | 1471 |
int32_t cli_bcapi_pdf_getobjid(struct cli_bc_ctx *ctx , int32_t objidx) |
1472 | 1472 |
{ |
1473 | 1473 |
if (!ctx->pdf_phase || |
1474 |
- objidx >= ctx->pdf_nobjs) |
|
1474 |
+ (uint32_t)objidx >= ctx->pdf_nobjs) |
|
1475 | 1475 |
return -1; |
1476 | 1476 |
return ctx->pdf_objs[objidx].id; |
1477 | 1477 |
} |
... | ... |
@@ -1479,7 +1508,7 @@ int32_t cli_bcapi_pdf_getobjid(struct cli_bc_ctx *ctx , int32_t objidx) |
1479 | 1479 |
int32_t cli_bcapi_pdf_getobjflags(struct cli_bc_ctx *ctx , int32_t objidx) |
1480 | 1480 |
{ |
1481 | 1481 |
if (!ctx->pdf_phase || |
1482 |
- objidx >= ctx->pdf_nobjs) |
|
1482 |
+ (uint32_t)objidx >= ctx->pdf_nobjs) |
|
1483 | 1483 |
return -1; |
1484 | 1484 |
return ctx->pdf_objs[objidx].flags; |
1485 | 1485 |
} |
... | ... |
@@ -1487,7 +1516,7 @@ int32_t cli_bcapi_pdf_getobjflags(struct cli_bc_ctx *ctx , int32_t objidx) |
1487 | 1487 |
int32_t cli_bcapi_pdf_setobjflags(struct cli_bc_ctx *ctx , int32_t objidx, int32_t flags) |
1488 | 1488 |
{ |
1489 | 1489 |
if (!ctx->pdf_phase || |
1490 |
- objidx >= ctx->pdf_nobjs) |
|
1490 |
+ (uint32_t)objidx >= ctx->pdf_nobjs) |
|
1491 | 1491 |
return -1; |
1492 | 1492 |
cli_dbgmsg("cli_pdf: bytecode setobjflags %08x -> %08x\n", |
1493 | 1493 |
ctx->pdf_objs[objidx].flags, |
... | ... |
@@ -1499,7 +1528,7 @@ int32_t cli_bcapi_pdf_setobjflags(struct cli_bc_ctx *ctx , int32_t objidx, int32 |
1499 | 1499 |
int32_t cli_bcapi_pdf_get_offset(struct cli_bc_ctx *ctx , int32_t objidx) |
1500 | 1500 |
{ |
1501 | 1501 |
if (!ctx->pdf_phase || |
1502 |
- objidx >= ctx->pdf_nobjs) |
|
1502 |
+ (uint32_t)objidx >= ctx->pdf_nobjs) |
|
1503 | 1503 |
return -1; |
1504 | 1504 |
return ctx->pdf_startoff + ctx->pdf_objs[objidx].start; |
1505 | 1505 |
} |
... | ... |
@@ -1536,6 +1565,7 @@ int32_t cli_bcapi_json_is_active(struct cli_bc_ctx *ctx ) |
1536 | 1536 |
return 1; |
1537 | 1537 |
} |
1538 | 1538 |
#else |
1539 |
+ UNUSEDPARAM(ctx); |
|
1539 | 1540 |
cli_dbgmsg("bytecode api: libjson is not enabled!\n"); |
1540 | 1541 |
#endif |
1541 | 1542 |
return 0; |
... | ... |
@@ -1558,6 +1588,7 @@ static int32_t cli_bcapi_json_objs_init(struct cli_bc_ctx *ctx) { |
1558 | 1558 |
|
1559 | 1559 |
return 0; |
1560 | 1560 |
#else |
1561 |
+ UNUSEDPARAM(ctx); |
|
1561 | 1562 |
return -1; |
1562 | 1563 |
#endif |
1563 | 1564 |
} |
... | ... |
@@ -1580,7 +1611,7 @@ int32_t cli_bcapi_json_get_object(struct cli_bc_ctx *ctx, const int8_t* name, in |
1580 | 1580 |
|
1581 | 1581 |
INIT_JSON_OBJS(ctx); |
1582 | 1582 |
jobjs = ((json_object **)(ctx->jsonobjs)); |
1583 |
- if (objid < 0 || objid >= ctx->njsonobjs) { |
|
1583 |
+ if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) { |
|
1584 | 1584 |
cli_dbgmsg("bytecode api[json_get_object]: invalid json objid requested\n"); |
1585 | 1585 |
return -1; |
1586 | 1586 |
} |
... | ... |
@@ -1619,6 +1650,10 @@ int32_t cli_bcapi_json_get_object(struct cli_bc_ctx *ctx, const int8_t* name, in |
1619 | 1619 |
free(namep); |
1620 | 1620 |
return n-1; |
1621 | 1621 |
#else |
1622 |
+ UNUSEDPARAM(ctx); |
|
1623 |
+ UNUSEDPARAM(name); |
|
1624 |
+ UNUSEDPARAM(name_len); |
|
1625 |
+ UNUSEDPARAM(objid); |
|
1622 | 1626 |
cli_dbgmsg("bytecode api: libjson is not enabled!\n"); |
1623 | 1627 |
return -1; |
1624 | 1628 |
#endif |
... | ... |
@@ -1632,7 +1667,7 @@ int32_t cli_bcapi_json_get_type(struct cli_bc_ctx *ctx, int32_t objid) |
1632 | 1632 |
|
1633 | 1633 |
INIT_JSON_OBJS(ctx); |
1634 | 1634 |
jobjs = ((json_object **)(ctx->jsonobjs)); |
1635 |
- if (objid < 0 || objid >= ctx->njsonobjs) { |
|
1635 |
+ if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) { |
|
1636 | 1636 |
cli_dbgmsg("bytecode api[json_get_type]: invalid json objid requested\n"); |
1637 | 1637 |
return -1; |
1638 | 1638 |
} |
... | ... |
@@ -1658,6 +1693,8 @@ int32_t cli_bcapi_json_get_type(struct cli_bc_ctx *ctx, int32_t objid) |
1658 | 1658 |
} |
1659 | 1659 |
|
1660 | 1660 |
#else |
1661 |
+ UNUSEDPARAM(ctx); |
|
1662 |
+ UNUSEDPARAM(objid); |
|
1661 | 1663 |
cli_dbgmsg("bytecode api: libjson is not enabled!\n"); |
1662 | 1664 |
#endif |
1663 | 1665 |
return -1; |
... | ... |
@@ -1671,7 +1708,7 @@ int32_t cli_bcapi_json_get_array_length(struct cli_bc_ctx *ctx, int32_t objid) |
1671 | 1671 |
|
1672 | 1672 |
INIT_JSON_OBJS(ctx); |
1673 | 1673 |
jobjs = (json_object **)(ctx->jsonobjs); |
1674 |
- if (objid < 0 || objid >= ctx->njsonobjs) { |
|
1674 |
+ if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) { |
|
1675 | 1675 |
cli_dbgmsg("bytecode api[json_array_get_length]: invalid json objid requested\n"); |
1676 | 1676 |
return -1; |
1677 | 1677 |
} |
... | ... |
@@ -1683,6 +1720,8 @@ int32_t cli_bcapi_json_get_array_length(struct cli_bc_ctx *ctx, int32_t objid) |
1683 | 1683 |
|
1684 | 1684 |
return json_object_array_length(jobjs[objid]); |
1685 | 1685 |
#else |
1686 |
+ UNUSEDPARAM(ctx); |
|
1687 |
+ UNUSEDPARAM(objid); |
|
1686 | 1688 |
cli_dbgmsg("bytecode api: libjson is not enabled!\n"); |
1687 | 1689 |
return -1; |
1688 | 1690 |
#endif |
... | ... |
@@ -1698,7 +1737,7 @@ int32_t cli_bcapi_json_get_array_idx(struct cli_bc_ctx *ctx, int32_t idx, int32_ |
1698 | 1698 |
|
1699 | 1699 |
INIT_JSON_OBJS(ctx); |
1700 | 1700 |
jobjs = (json_object **)(ctx->jsonobjs); |
1701 |
- if (objid < 0 || objid >= ctx->njsonobjs) { |
|
1701 |
+ if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) { |
|
1702 | 1702 |
cli_dbgmsg("bytecode api[json_array_get_idx]: invalid json objid requested\n"); |
1703 | 1703 |
return -1; |
1704 | 1704 |
} |
... | ... |
@@ -1736,6 +1775,9 @@ int32_t cli_bcapi_json_get_array_idx(struct cli_bc_ctx *ctx, int32_t idx, int32_ |
1736 | 1736 |
|
1737 | 1737 |
return 0; |
1738 | 1738 |
#else |
1739 |
+ UNUSEDPARAM(ctx); |
|
1740 |
+ UNUSEDPARAM(idx); |
|
1741 |
+ UNUSEDPARAM(objid); |
|
1739 | 1742 |
cli_dbgmsg("bytecode api: libjson is not enabled!\n"); |
1740 | 1743 |
return -1; |
1741 | 1744 |
#endif |
... | ... |
@@ -1751,7 +1793,7 @@ int32_t cli_bcapi_json_get_string_length(struct cli_bc_ctx *ctx, int32_t objid) |
1751 | 1751 |
|
1752 | 1752 |
INIT_JSON_OBJS(ctx); |
1753 | 1753 |
jobjs = (json_object **)(ctx->jsonobjs); |
1754 |
- if (objid < 0 || objid >= ctx->njsonobjs) { |
|
1754 |
+ if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) { |
|
1755 | 1755 |
cli_dbgmsg("bytecode api[json_get_string_length]: invalid json objid requested\n"); |
1756 | 1756 |
return -1; |
1757 | 1757 |
} |
... | ... |
@@ -1771,6 +1813,8 @@ int32_t cli_bcapi_json_get_string_length(struct cli_bc_ctx *ctx, int32_t objid) |
1771 | 1771 |
|
1772 | 1772 |
return len; |
1773 | 1773 |
#else |
1774 |
+ UNUSEDPARAM(ctx); |
|
1775 |
+ UNUSEDPARAM(objid); |
|
1774 | 1776 |
cli_dbgmsg("bytecode api: libjson is not enabled!\n"); |
1775 | 1777 |
return -1; |
1776 | 1778 |
#endif |
... | ... |
@@ -1786,7 +1830,7 @@ int32_t cli_bcapi_json_get_string(struct cli_bc_ctx *ctx, int8_t* str, int32_t s |
1786 | 1786 |
|
1787 | 1787 |
INIT_JSON_OBJS(ctx); |
1788 | 1788 |
jobjs = (json_object **)(ctx->jsonobjs); |
1789 |
- if (objid < 0 || objid >= ctx->njsonobjs) { |
|
1789 |
+ if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) { |
|
1790 | 1790 |
cli_dbgmsg("bytecode api[json_get_string]: invalid json objid requested\n"); |
1791 | 1791 |
return -1; |
1792 | 1792 |
} |
... | ... |
@@ -1806,17 +1850,21 @@ int32_t cli_bcapi_json_get_string(struct cli_bc_ctx *ctx, int8_t* str, int32_t s |
1806 | 1806 |
|
1807 | 1807 |
if (len+1 > str_len) { |
1808 | 1808 |
/* limit on str-len */ |
1809 |
- strncpy(str, jstr, str_len-1); |
|
1809 |
+ strncpy((char *)str, jstr, str_len-1); |
|
1810 | 1810 |
str[str_len-1] = '\0'; |
1811 | 1811 |
return str_len; |
1812 | 1812 |
} |
1813 | 1813 |
else { |
1814 | 1814 |
/* limit on len+1 */ |
1815 |
- strncpy(str, jstr, len); |
|
1815 |
+ strncpy((char *)str, jstr, len); |
|
1816 | 1816 |
str[len] = '\0'; |
1817 | 1817 |
return len+1; |
1818 | 1818 |
} |
1819 | 1819 |
#else |
1820 |
+ UNUSEDPARAM(ctx); |
|
1821 |
+ UNUSEDPARAM(str); |
|
1822 |
+ UNUSEDPARAM(str_len); |
|
1823 |
+ UNUSEDPARAM(objid); |
|
1820 | 1824 |
cli_dbgmsg("bytecode api: libjson is not enabled!\n"); |
1821 | 1825 |
return -1; |
1822 | 1826 |
#endif |
... | ... |
@@ -1829,7 +1877,7 @@ int32_t cli_bcapi_json_get_boolean(struct cli_bc_ctx *ctx, int32_t objid) |
1829 | 1829 |
|
1830 | 1830 |
INIT_JSON_OBJS(ctx); |
1831 | 1831 |
jobjs = (json_object **)(ctx->jsonobjs); |
1832 |
- if (objid < 0 || objid >= ctx->njsonobjs) { |
|
1832 |
+ if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) { |
|
1833 | 1833 |
cli_dbgmsg("bytecode api[json_get_boolean]: invalid json objid requested\n"); |
1834 | 1834 |
return -1; |
1835 | 1835 |
} |
... | ... |
@@ -1837,6 +1885,8 @@ int32_t cli_bcapi_json_get_boolean(struct cli_bc_ctx *ctx, int32_t objid) |
1837 | 1837 |
jobj = jobjs[objid]; |
1838 | 1838 |
return json_object_get_boolean(jobj); |
1839 | 1839 |
#else |
1840 |
+ UNUSEDPARAM(ctx); |
|
1841 |
+ UNUSEDPARAM(objid); |
|
1840 | 1842 |
cli_dbgmsg("bytecode api: libjson is not enabled!\n"); |
1841 | 1843 |
return 0; |
1842 | 1844 |
#endif |
... | ... |
@@ -1849,7 +1899,7 @@ int32_t cli_bcapi_json_get_int(struct cli_bc_ctx *ctx, int32_t objid) |
1849 | 1849 |
|
1850 | 1850 |
INIT_JSON_OBJS(ctx); |
1851 | 1851 |
jobjs = (json_object **)(ctx->jsonobjs); |
1852 |
- if (objid < 0 || objid >= ctx->njsonobjs) { |
|
1852 |
+ if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) { |
|
1853 | 1853 |
cli_dbgmsg("bytecode api[json_get_int]: invalid json objid requested\n"); |
1854 | 1854 |
return -1; |
1855 | 1855 |
} |
... | ... |
@@ -1857,6 +1907,8 @@ int32_t cli_bcapi_json_get_int(struct cli_bc_ctx *ctx, int32_t objid) |
1857 | 1857 |
jobj = jobjs[objid]; |
1858 | 1858 |
return json_object_get_int(jobj); |
1859 | 1859 |
#else |
1860 |
+ UNUSEDPARAM(ctx); |
|
1861 |
+ UNUSEDPARAM(objid); |
|
1860 | 1862 |
cli_dbgmsg("bytecode api: libjson is not enabled!\n"); |
1861 | 1863 |
return 0; |
1862 | 1864 |
#endif |
... | ... |
@@ -214,8 +214,8 @@ const struct cli_bc_type cli_apicall_types[]={ |
214 | 214 |
{DArrayType, cli_tmp29, 3, 0, 0}, |
215 | 215 |
{DArrayType, cli_tmp30, 10, 0, 0} |
216 | 216 |
}; |
217 |
- |
|
218 | 217 |
const unsigned cli_apicall_maxtypes=sizeof(cli_apicall_types)/sizeof(cli_apicall_types[0]); |
218 |
+ |
|
219 | 219 |
const struct cli_apicall cli_apicalls[]={ |
220 | 220 |
/* Bytecode APIcalls BEGIN */ |
221 | 221 |
{"test1", 10, 0, 0}, |
... | ... |
@@ -320,6 +320,8 @@ const struct cli_apicall cli_apicalls[]={ |
320 | 320 |
{"json_get_int", 8, 33, 2} |
321 | 321 |
/* Bytecode APIcalls END */ |
322 | 322 |
}; |
323 |
+const unsigned cli_numapicalls=sizeof(cli_apicalls)/sizeof(cli_apicalls[0]); |
|
324 |
+ |
|
323 | 325 |
const cli_apicall_int2 cli_apicalls0[] = { |
324 | 326 |
(cli_apicall_int2)cli_bcapi_test1, |
325 | 327 |
(cli_apicall_int2)cli_bcapi_seek, |
... | ... |
@@ -47,21 +47,30 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs) |
47 | 47 |
|
48 | 48 |
int cli_vm_execute_jit(const struct cli_all_bc *bcs, struct cli_bc_ctx *ctx, const struct cli_bc_func *func) |
49 | 49 |
{ |
50 |
+ UNUSEDPARAM(bcs); |
|
51 |
+ UNUSEDPARAM(ctx); |
|
52 |
+ UNUSEDPARAM(func); |
|
50 | 53 |
return CL_EBYTECODE; |
51 | 54 |
} |
52 | 55 |
|
53 | 56 |
int cli_bytecode_init_jit(struct cli_all_bc *allbc, unsigned dconfmask) |
54 | 57 |
{ |
58 |
+ UNUSEDPARAM(allbc); |
|
59 |
+ UNUSEDPARAM(dconfmask); |
|
55 | 60 |
return CL_SUCCESS; |
56 | 61 |
} |
57 | 62 |
|
58 | 63 |
int cli_bytecode_done_jit(struct cli_all_bc *allbc, int partial) |
59 | 64 |
{ |
65 |
+ UNUSEDPARAM(allbc); |
|
66 |
+ UNUSEDPARAM(partial); |
|
60 | 67 |
return CL_SUCCESS; |
61 | 68 |
} |
62 | 69 |
|
63 | 70 |
void cli_bytecode_debug(int argc, char **argv) { |
64 | 71 |
/* Empty */ |
72 |
+ UNUSEDPARAM(argc); |
|
73 |
+ UNUSEDPARAM(argv); |
|
65 | 74 |
} |
66 | 75 |
|
67 | 76 |
int bytecode_init(void) |
... | ... |
@@ -71,6 +80,7 @@ int bytecode_init(void) |
71 | 71 |
|
72 | 72 |
void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) { |
73 | 73 |
/* Empty */ |
74 |
+ UNUSEDPARAM(ctx); |
|
74 | 75 |
} |
75 | 76 |
void cli_bytecode_printversion(void) { |
76 | 77 |
printf("LLVM not compiled in\n"); |
... | ... |
@@ -83,4 +93,5 @@ void cli_printcxxver() |
83 | 83 |
void cli_detect_env_jit(struct cli_environment *env) |
84 | 84 |
{ |
85 | 85 |
/* Empty */ |
86 |
+ UNUSEDPARAM(env); |
|
86 | 87 |
} |
... | ... |
@@ -555,13 +555,6 @@ static inline int64_t ptr_register_glob(struct ptr_infos *infos, |
555 | 555 |
return ptr_register_glob_fixedid(infos, values, size, infos->nglobs+1); |
556 | 556 |
} |
557 | 557 |
|
558 |
-static inline int64_t ptr_index(int64_t ptr, uint32_t off) |
|
559 |
-{ |
|
560 |
- int32_t ptrid = ptr >> 32; |
|
561 |
- uint32_t ptroff = (uint32_t)ptr; |
|
562 |
- return ptr_compose(ptrid, ptroff+off); |
|
563 |
-} |
|
564 |
- |
|
565 | 558 |
static inline void* ptr_torealptr(const struct ptr_infos *infos, int64_t ptr, |
566 | 559 |
uint32_t read_size) |
567 | 560 |
{ |
... | ... |
@@ -575,14 +568,14 @@ static inline void* ptr_torealptr(const struct ptr_infos *infos, int64_t ptr, |
575 | 575 |
} |
576 | 576 |
if (ptrid < 0) { |
577 | 577 |
ptrid = -ptrid-1; |
578 |
- if (UNLIKELY(ptrid >= infos->nstacks)) { |
|
578 |
+ if (UNLIKELY((const unsigned int)ptrid >= infos->nstacks)) { |
|
579 | 579 |
(void)bcfail("ptr", ptrid, infos->nstacks, __FILE__, __LINE__); |
580 | 580 |
return NULL; |
581 | 581 |
} |
582 | 582 |
info = &infos->stack_infos[ptrid]; |
583 | 583 |
} else { |
584 | 584 |
ptrid--; |
585 |
- if (UNLIKELY(ptrid >= infos->nglobs)) { |
|
585 |
+ if (UNLIKELY((const unsigned int)ptrid >= infos->nglobs)) { |
|
586 | 586 |
(void)bcfail("ptr", ptrid, infos->nglobs, __FILE__, __LINE__); |
587 | 587 |
return NULL; |
588 | 588 |
} |
... | ... |
@@ -2,8 +2,10 @@ |
2 | 2 |
* Compile LLVM bytecode to ClamAV bytecode. |
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2009-2013 Sourcefire, Inc. |
5 |
+ * Copyright (C) 2014 Cisco Systems, Inc. and/or its affiliates. |
|
6 |
+ * All rights reserved. |
|
5 | 7 |
* |
6 |
- * Authors: Török Edvin |
|
8 |
+ * Authors: Török Edvin, Kevin Lin |
|
7 | 9 |
* |
8 | 10 |
* This program is free software; you can redistribute it and/or modify |
9 | 11 |
* it under the terms of the GNU General Public License version 2 as |
... | ... |
@@ -22,661 +24,779 @@ |
22 | 22 |
#define DEBUG_TYPE "clambc-rtcheck" |
23 | 23 |
#include "ClamBCModule.h" |
24 | 24 |
#include "ClamBCDiagnostics.h" |
25 |
+#include "llvm30_compat.h" /* libclamav-specific */ |
|
25 | 26 |
#include "llvm/ADT/DenseSet.h" |
26 | 27 |
#include "llvm/ADT/PostOrderIterator.h" |
27 | 28 |
#include "llvm/ADT/SCCIterator.h" |
28 | 29 |
#include "llvm/Analysis/CallGraph.h" |
29 | 30 |
#include "llvm/Analysis/Verifier.h" |
31 |
+#if LLVM_VERSION < 32 |
|
30 | 32 |
#include "llvm/Analysis/DebugInfo.h" |
33 |
+#else |
|
34 |
+#include "llvm/DebugInfo.h" |
|
35 |
+#endif |
|
31 | 36 |
#include "llvm/Analysis/Dominators.h" |
32 | 37 |
#include "llvm/Analysis/ConstantFolding.h" |
33 |
-//#include "llvm/Analysis/LiveValues.h" |
|
34 |
-// |
|
35 |
-#ifdef LLVM29 |
|
36 |
-#include "llvm/Analysis/ValueTracking.h" |
|
37 |
-#include "PointerTracking.h" |
|
38 |
-#else |
|
38 |
+#if LLVM_VERSION < 29 |
|
39 |
+//#include "llvm/Analysis/LiveValues.h" (unused) |
|
39 | 40 |
#include "llvm/Analysis/PointerTracking.h" |
41 |
+#else |
|
42 |
+#include "llvm/Analysis/ValueTracking.h" |
|
43 |
+#include "PointerTracking.h" /* included from old LLVM source */ |
|
40 | 44 |
#endif |
41 | 45 |
#include "llvm/Analysis/ScalarEvolution.h" |
42 | 46 |
#include "llvm/Analysis/ScalarEvolutionExpressions.h" |
43 | 47 |
#include "llvm/Analysis/ScalarEvolutionExpander.h" |
44 | 48 |
#include "llvm/Config/config.h" |
45 |
-#include "llvm/DerivedTypes.h" |
|
46 |
-#include "llvm/Instructions.h" |
|
47 |
-#include "llvm/IntrinsicInst.h" |
|
48 |
-#include "llvm/Intrinsics.h" |
|
49 |
-#include "llvm/LLVMContext.h" |
|
50 |
-#include "llvm/Module.h" |
|
51 | 49 |
#include "llvm/Pass.h" |
52 | 50 |
#include "llvm/Support/CommandLine.h" |
53 | 51 |
#include "llvm/Support/DataFlow.h" |
54 | 52 |
#include "llvm/Support/InstIterator.h" |
55 |
-#include "llvm/Support/InstVisitor.h" |
|
56 | 53 |
#include "llvm/Support/GetElementPtrTypeIterator.h" |
57 | 54 |
#include "llvm/ADT/DepthFirstIterator.h" |
58 |
-#include "llvm/Target/TargetData.h" |
|
59 | 55 |
#include "llvm/Transforms/Scalar.h" |
60 | 56 |
#include "llvm/Transforms/Utils/BasicBlockUtils.h" |
61 | 57 |
#include "llvm/Support/Debug.h" |
62 |
-#include "llvm30_compat.h" |
|
63 |
- |
|
64 |
-#ifndef LLVM28 |
|
65 |
-#define LLVM28 |
|
58 |
+#if LLVM_VERSION < 32 |
|
59 |
+#include "llvm/Target/TargetData.h" |
|
60 |
+#elif LLVM_VERSION < 33 |
|
61 |
+#include "llvm/DataLayout.h" |
|
62 |
+#else |
|
63 |
+#include "llvm/IR/DataLayout.h" |
|
66 | 64 |
#endif |
67 |
-#ifdef LLVM28 |
|
68 |
-#define DEFINEPASS(passname) passname() : FunctionPass(ID) |
|
65 |
+#if LLVM_VERSION < 33 |
|
66 |
+#include "llvm/DerivedTypes.h" |
|
67 |
+#include "llvm/Instructions.h" |
|
68 |
+#include "llvm/IntrinsicInst.h" |
|
69 |
+#include "llvm/Intrinsics.h" |
|
70 |
+#include "llvm/LLVMContext.h" |
|
71 |
+#include "llvm/Module.h" |
|
72 |
+#include "llvm/Support/InstVisitor.h" |
|
69 | 73 |
#else |
70 |
-#define DEFINEPASS(passname) passname() : FunctionPass(&ID) |
|
74 |
+#include "llvm/IR/DerivedTypes.h" |
|
75 |
+#include "llvm/IR/Instructions.h" |
|
76 |
+#include "llvm/IR/IntrinsicInst.h" |
|
77 |
+#include "llvm/IR/Intrinsics.h" |
|
78 |
+#include "llvm/IR/LLVMContext.h" |
|
79 |
+#include "llvm/IR/Module.h" |
|
80 |
+#include "llvm/InstVisitor.h" |
|
71 | 81 |
#endif |
72 | 82 |
|
83 |
+#define DEFINEPASS(passname) passname() : FunctionPass(ID) |
|
84 |
+ |
|
73 | 85 |
using namespace llvm; |
74 |
-#ifndef LLVM29 |
|
86 |
+#if LLVM_VERSION < 29 |
|
87 |
+/* function is succeeded in later LLVM with LLVM correspoding standalone */ |
|
75 | 88 |
static Value *GetUnderlyingObject(Value *P, TargetData *TD) |
76 | 89 |
{ |
77 | 90 |
return P->getUnderlyingObject(); |
78 | 91 |
} |
79 | 92 |
#endif |
80 |
-namespace llvm { |
|
81 |
- class PtrVerifier; |
|
82 | 93 |
|
83 |
-#ifdef LLVM30 |
|
94 |
+namespace llvm { |
|
95 |
+ class PtrVerifier; |
|
96 |
+#if LLVM_VERSION >= 30 |
|
84 | 97 |
void initializePtrVerifierPass(PassRegistry&); |
85 | 98 |
#endif |
86 | 99 |
|
87 | 100 |
class PtrVerifier : public FunctionPass { |
88 | 101 |
private: |
89 |
- DenseSet<Function*> badFunctions; |
|
90 |
- CallGraphNode *rootNode; |
|
102 |
+ DenseSet<Function*> badFunctions; |
|
103 |
+ std::vector<Instruction*> delInst; |
|
104 |
+ CallGraphNode *rootNode; |
|
91 | 105 |
public: |
92 |
- static char ID; |
|
93 |
- DEFINEPASS(PtrVerifier), rootNode(0), PT(), TD(), SE(), DT(), |
|
94 |
- AbrtBB(), EP() { |
|
95 |
-#ifdef LLVM30 |
|
96 |
- initializePtrVerifierPass(*PassRegistry::getPassRegistry()); |
|
106 |
+ static char ID; |
|
107 |
+ DEFINEPASS(PtrVerifier), rootNode(0), PT(), TD(), SE(), DT(), |
|
108 |
+ AbrtBB(), Changed(false), valid(false), EP() { |
|
109 |
+#if LLVM_VERSION >= 30 |
|
110 |
+ initializePtrVerifierPass(*PassRegistry::getPassRegistry()); |
|
97 | 111 |
#endif |
98 |
- Changed = false; |
|
99 |
- valid = false; |
|
100 |
- } |
|
101 |
- |
|
102 |
- virtual bool runOnFunction(Function &F) { |
|
103 |
- DEBUG(errs() << "Running on " << F.getName() << "\n"); |
|
104 |
- DEBUG(F.dump()); |
|
105 |
- Changed = false; |
|
106 |
- BaseMap.clear(); |
|
107 |
- BoundsMap.clear(); |
|
108 |
- AbrtBB = 0; |
|
109 |
- valid = true; |
|
110 |
- |
|
111 |
- if (!rootNode) { |
|
112 |
- rootNode = getAnalysis<CallGraph>().getRoot(); |
|
113 |
- // No recursive functions for now. |
|
114 |
- // In the future we may insert runtime checks for stack depth. |
|
115 |
- for (scc_iterator<CallGraphNode*> SCCI = scc_begin(rootNode), |
|
116 |
- E = scc_end(rootNode); SCCI != E; ++SCCI) { |
|
117 |
- const std::vector<CallGraphNode*> &nextSCC = *SCCI; |
|
118 |
- if (nextSCC.size() > 1 || SCCI.hasLoop()) { |
|
119 |
- errs() << "INVALID: Recursion detected, callgraph SCC components: "; |
|
120 |
- for (std::vector<CallGraphNode*>::const_iterator I = nextSCC.begin(), |
|
121 |
- E = nextSCC.end(); I != E; ++I) { |
|
122 |
- Function *FF = (*I)->getFunction(); |
|
123 |
- if (FF) { |
|
124 |
- errs() << FF->getName() << ", "; |
|
125 |
- badFunctions.insert(FF); |
|
126 |
- } |
|
127 |
- } |
|
128 |
- if (SCCI.hasLoop()) |
|
129 |
- errs() << "(self-loop)"; |
|
130 |
- errs() << "\n"; |
|
131 |
- } |
|
132 |
- // we could also have recursion via function pointers, but we don't |
|
133 |
- // allow calls to unknown functions, see runOnFunction() below |
|
134 |
- } |
|
135 | 112 |
} |
136 | 113 |
|
137 |
- BasicBlock::iterator It = F.getEntryBlock().begin(); |
|
138 |
- while (isa<AllocaInst>(It) || isa<PHINode>(It)) ++It; |
|
139 |
- EP = &*It; |
|
140 |
- |
|
141 |
- TD = &getAnalysis<TargetData>(); |
|
142 |
- SE = &getAnalysis<ScalarEvolution>(); |
|
143 |
- PT = &getAnalysis<PointerTracking>(); |
|
144 |
- DT = &getAnalysis<DominatorTree>(); |
|
145 |
- |
|
146 |
- std::vector<Instruction*> insns; |
|
147 |
- |
|
148 |
- BasicBlock *LastBB = 0; |
|
149 |
- bool skip = false; |
|
150 |
- for (inst_iterator I=inst_begin(F),E=inst_end(F); I != E;++I) { |
|
151 |
- Instruction *II = &*I; |
|
152 |
- if (II->getParent() != LastBB) { |
|
153 |
- LastBB = II->getParent(); |
|
154 |
- skip = DT->getNode(LastBB) == 0; |
|
155 |
- } |
|
156 |
- if (skip) |
|
157 |
- continue; |
|
158 |
- if (isa<LoadInst>(II) || isa<StoreInst>(II) || isa<MemIntrinsic>(II)) |
|
159 |
- insns.push_back(II); |
|
160 |
- if (CallInst *CI = dyn_cast<CallInst>(II)) { |
|
161 |
- Value *V = CI->getCalledValue()->stripPointerCasts(); |
|
162 |
- Function *F = dyn_cast<Function>(V); |
|
163 |
- if (!F) { |
|
164 |
- printLocation(CI, true); |
|
165 |
- errs() << "Could not determine call target\n"; |
|
166 |
- valid = 0; |
|
167 |
- continue; |
|
168 |
- } |
|
169 |
- if (!F->isDeclaration()) |
|
170 |
- continue; |
|
171 |
- insns.push_back(CI); |
|
172 |
- } |
|
173 |
- } |
|
174 |
- while (!insns.empty()) { |
|
175 |
- Instruction *II = insns.back(); |
|
176 |
- insns.pop_back(); |
|
177 |
- DEBUG(dbgs() << "checking " << *II << "\n"); |
|
178 |
- if (LoadInst *LI = dyn_cast<LoadInst>(II)) { |
|
179 |
- constType *Ty = LI->getType(); |
|
180 |
- valid &= validateAccess(LI->getPointerOperand(), |
|
181 |
- TD->getTypeAllocSize(Ty), LI); |
|
182 |
- } else if (StoreInst *SI = dyn_cast<StoreInst>(II)) { |
|
183 |
- constType *Ty = SI->getOperand(0)->getType(); |
|
184 |
- valid &= validateAccess(SI->getPointerOperand(), |
|
185 |
- TD->getTypeAllocSize(Ty), SI); |
|
186 |
- } else if (MemIntrinsic *MI = dyn_cast<MemIntrinsic>(II)) { |
|
187 |
- valid &= validateAccess(MI->getDest(), MI->getLength(), MI); |
|
188 |
- if (MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI)) { |
|
189 |
- valid &= validateAccess(MTI->getSource(), MI->getLength(), MI); |
|
190 |
- } |
|
191 |
- } else if (CallInst *CI = dyn_cast<CallInst>(II)) { |
|
192 |
- Value *V = CI->getCalledValue()->stripPointerCasts(); |
|
193 |
- Function *F = cast<Function>(V); |
|
194 |
- const FunctionType *FTy = F->getFunctionType(); |
|
195 |
- CallSite CS(CI); |
|
196 |
- |
|
197 |
- if (F->getName().equals("memcmp") && FTy->getNumParams() == 3) { |
|
198 |
- valid &= validateAccess(CS.getArgument(0), CS.getArgument(2), CI); |
|
199 |
- valid &= validateAccess(CS.getArgument(1), CS.getArgument(2), CI); |
|
200 |
- continue; |
|
201 |
- } |
|
202 |
- unsigned i; |
|
114 |
+ virtual bool runOnFunction(Function &F) { |
|
115 |
+ /* |
|
116 |
+#ifndef CLAMBC_COMPILER |
|
117 |
+ // Bytecode was already verified and had stack protector applied. |
|
118 |
+ // We get called again because ALL bytecode functions loaded are part of |
|
119 |
+ // the same module. |
|
120 |
+ if (F.hasFnAttr(Attribute::StackProtectReq)) |
|
121 |
+ return false; |
|
122 |
+#endif |
|
123 |
+ */ |
|
124 |
+ |
|
125 |
+ DEBUG(errs() << "Running on " << F.getName() << "\n"); |
|
126 |
+ DEBUG(F.dump()); |
|
127 |
+ Changed = false; |
|
128 |
+ BaseMap.clear(); |
|
129 |
+ BoundsMap.clear(); |
|
130 |
+ delInst.clear(); |
|
131 |
+ AbrtBB = 0; |
|
132 |
+ valid = true; |
|
133 |
+ |
|
134 |
+ if (!rootNode) { |
|
135 |
+ rootNode = getAnalysis<CallGraph>().getRoot(); |
|
136 |
+ // No recursive functions for now. |
|
137 |
+ // In the future we may insert runtime checks for stack depth. |
|
138 |
+ for (scc_iterator<CallGraphNode*> SCCI = scc_begin(rootNode), |
|
139 |
+ E = scc_end(rootNode); SCCI != E; ++SCCI) { |
|
140 |
+ const std::vector<CallGraphNode*> &nextSCC = *SCCI; |
|
141 |
+ if (nextSCC.size() > 1 || SCCI.hasLoop()) { |
|
142 |
+ errs() << "INVALID: Recursion detected, callgraph SCC components: "; |
|
143 |
+ for (std::vector<CallGraphNode*>::const_iterator I = nextSCC.begin(), |
|
144 |
+ E = nextSCC.end(); I != E; ++I) { |
|
145 |
+ Function *FF = (*I)->getFunction(); |
|
146 |
+ if (FF) { |
|
147 |
+ errs() << FF->getName() << ", "; |
|
148 |
+ badFunctions.insert(FF); |
|
149 |
+ } |
|
150 |
+ } |
|
151 |
+ if (SCCI.hasLoop()) |
|
152 |
+ errs() << "(self-loop)"; |
|
153 |
+ errs() << "\n"; |
|
154 |
+ } |
|
155 |
+ // we could also have recursion via function pointers, but we don't |
|
156 |
+ // allow calls to unknown functions, see runOnFunction() below |
|
157 |
+ } |
|
158 |
+ } |
|
159 |
+ |
|
160 |
+ BasicBlock::iterator It = F.getEntryBlock().begin(); |
|
161 |
+ while (isa<AllocaInst>(It) || isa<PHINode>(It)) ++It; |
|
162 |
+ EP = &*It; |
|
163 |
+#if LLVM_VERSION < 32 |
|
164 |
+ TD = &getAnalysis<TargetData>(); |
|
165 |
+#else |
|
166 |
+ TD = &getAnalysis<DataLayout>(); |
|
167 |
+#endif |
|
168 |
+ SE = &getAnalysis<ScalarEvolution>(); |
|
169 |
+ PT = &getAnalysis<PointerTracking>(); |
|
170 |
+ DT = &getAnalysis<DominatorTree>(); |
|
171 |
+ expander = new SCEVExpander(*SE OPT("SCEVexpander")); |
|
172 |
+ |
|
173 |
+ std::vector<Instruction*> insns; |
|
174 |
+ |
|
175 |
+ BasicBlock *LastBB = 0; |
|
176 |
+ for (inst_iterator I=inst_begin(F),E=inst_end(F); I != E;++I) { |
|
177 |
+ Instruction *II = &*I; |
|
178 |
+ /* only appears in the libclamav version */ |
|
179 |
+ if (II->getParent() != LastBB) { |
|
180 |
+ LastBB = II->getParent(); |
|
181 |
+ if (DT->getNode(LastBB) == 0) |
|
182 |
+ continue; |
|
183 |
+ } |
|
184 |
+ /* end-block */ |
|
185 |
+ if (isa<LoadInst>(II) || isa<StoreInst>(II) || isa<MemIntrinsic>(II)) |
|
186 |
+ insns.push_back(II); |
|
187 |
+ else if (CallInst *CI = dyn_cast<CallInst>(II)) { |
|
188 |
+ Value *V = CI->getCalledValue()->stripPointerCasts(); |
|
189 |
+ Function *F = dyn_cast<Function>(V); |
|
190 |
+ if (!F) { |
|
191 |
+ printLocation(CI, true); |
|
192 |
+ errs() << "Could not determine call target\n"; |
|
193 |
+ valid = 0; |
|
194 |
+ continue; |
|
195 |
+ } |
|
196 |
+ // this statement disable checks on user-defined CallInst |
|
197 |
+ //if (!F->isDeclaration()) |
|
198 |
+ //continue; |
|
199 |
+ insns.push_back(CI); |
|
200 |
+ } |
|
201 |
+ } |
|
202 |
+ |
|
203 |
+ for (unsigned Idx = 0; Idx < insns.size(); ++Idx) { |
|
204 |
+ Instruction *II = insns[Idx]; |
|
205 |
+ DEBUG(dbgs() << "checking " << *II << "\n"); |
|
206 |
+ if (LoadInst *LI = dyn_cast<LoadInst>(II)) { |
|
207 |
+ constType *Ty = LI->getType(); |
|
208 |
+ valid &= validateAccess(LI->getPointerOperand(), |
|
209 |
+ TD->getTypeAllocSize(Ty), LI); |
|
210 |
+ } else if (StoreInst *SI = dyn_cast<StoreInst>(II)) { |
|
211 |
+ constType *Ty = SI->getOperand(0)->getType(); |
|
212 |
+ valid &= validateAccess(SI->getPointerOperand(), |
|
213 |
+ TD->getTypeAllocSize(Ty), SI); |
|
214 |
+ } else if (MemIntrinsic *MI = dyn_cast<MemIntrinsic>(II)) { |
|
215 |
+ valid &= validateAccess(MI->getDest(), MI->getLength(), MI); |
|
216 |
+ if (MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI)) { |
|
217 |
+ valid &= validateAccess(MTI->getSource(), MI->getLength(), MI); |
|
218 |
+ } |
|
219 |
+ } else if (CallInst *CI = dyn_cast<CallInst>(II)) { |
|
220 |
+ Value *V = CI->getCalledValue()->stripPointerCasts(); |
|
221 |
+ Function *F = cast<Function>(V); |
|
222 |
+ constFunctionType *FTy = F->getFunctionType(); |
|
223 |
+ CallSite CS(CI); |
|
224 |
+ if (F->getName().equals("memcmp") && FTy->getNumParams() == 3) { |
|
225 |
+ valid &= validateAccess(CS.getArgument(0), CS.getArgument(2), CI); |
|
226 |
+ valid &= validateAccess(CS.getArgument(1), CS.getArgument(2), CI); |
|
227 |
+ continue; |
|
228 |
+ } |
|
229 |
+ unsigned i; |
|
203 | 230 |
#ifdef CLAMBC_COMPILER |
204 |
- i = 0; |
|
231 |
+ i = 0; |
|
205 | 232 |
#else |
206 |
- i = 1;// skip hidden ctx* |
|
233 |
+ i = 1;// skip hidden ctx* |
|
207 | 234 |
#endif |
208 |
- for (;i<FTy->getNumParams();i++) { |
|
209 |
- if (isa<PointerType>(FTy->getParamType(i))) { |
|
210 |
- Value *Ptr = CS.getArgument(i); |
|
211 |
- if (i+1 >= FTy->getNumParams()) { |
|
212 |
- printLocation(CI, false); |
|
213 |
- errs() << "Call to external function with pointer parameter last cannot be analyzed\n"; |
|
214 |
- errs() << *CI << "\n"; |
|
215 |
- valid = 0; |
|
216 |
- break; |
|
235 |
+ for (;i<FTy->getNumParams();i++) { |
|
236 |
+ if (isa<PointerType>(FTy->getParamType(i))) { |
|
237 |
+ Value *Ptr = CS.getArgument(i); |
|
238 |
+ if (i+1 >= FTy->getNumParams()) { |
|
239 |
+ printLocation(CI, false); |
|
240 |
+ errs() << "Call to external function with pointer parameter last" |
|
241 |
+ " cannot be analyzed\n"; |
|
242 |
+ errs() << *CI << "\n"; |
|
243 |
+ valid = 0; |
|
244 |
+ break; |
|
245 |
+ } |
|
246 |
+ Value *Size = CS.getArgument(i+1); |
|
247 |
+ if (!Size->getType()->isIntegerTy()) { |
|
248 |
+ printLocation(CI, false); |
|
249 |
+ errs() << "Pointer argument must be followed by integer argument" |
|
250 |
+ " representing its size\n"; |
|
251 |
+ errs() << *CI << "\n"; |
|
252 |
+ valid = 0; |
|
253 |
+ break; |
|
254 |
+ } |
|
255 |
+ valid &= validateAccess(Ptr, Size, CI); |
|
256 |
+ } |
|
257 |
+ } |
|
217 | 258 |
} |
218 |
- Value *Size = CS.getArgument(i+1); |
|
219 |
- if (!Size->getType()->isIntegerTy()) { |
|
220 |
- printLocation(CI, false); |
|
221 |
- errs() << "Pointer argument must be followed by integer argument representing its size\n"; |
|
222 |
- errs() << *CI << "\n"; |
|
223 |
- valid = 0; |
|
224 |
- break; |
|
259 |
+ } |
|
260 |
+ if (badFunctions.count(&F)) |
|
261 |
+ valid = 0; |
|
262 |
+ |
|
263 |
+ if (!valid) { |
|
264 |
+ DEBUG(F.dump()); |
|
265 |
+ ClamBCModule::stop("Verification found errors!", &F); |
|
266 |
+ // replace function with call to abort |
|
267 |
+ std::vector<constType*>args; |
|
268 |
+ FunctionType* abrtTy = FunctionType::get(Type::getVoidTy(F.getContext()),args,false); |
|
269 |
+ Constant *func_abort = F.getParent()->getOrInsertFunction("abort", abrtTy); |
|
270 |
+ |
|
271 |
+ BasicBlock *BB = &F.getEntryBlock(); |
|
272 |
+ Instruction *I = &*BB->begin(); |
|
273 |
+ Instruction *UI = new UnreachableInst(F.getContext(), I); |
|
274 |
+ CallInst *AbrtC = CallInst::Create(func_abort, "", UI); |
|
275 |
+ AbrtC->setCallingConv(CallingConv::C); |
|
276 |
+ AbrtC->setTailCall(true); |
|
277 |
+#if LLVM_VERSION < 32 |
|
278 |
+ AbrtC->setDoesNotReturn(true); |
|
279 |
+ AbrtC->setDoesNotThrow(true); |
|
280 |
+#else |
|
281 |
+ AbrtC->setDoesNotReturn(); |
|
282 |
+ AbrtC->setDoesNotThrow(); |
|
283 |
+#endif |
|
284 |
+ // remove all instructions from entry |
|
285 |
+ BasicBlock::iterator BBI = I, BBE=BB->end(); |
|
286 |
+ while (BBI != BBE) { |
|
287 |
+ if (!BBI->use_empty()) |
|
288 |
+ BBI->replaceAllUsesWith(UndefValue::get(BBI->getType())); |
|
289 |
+ BB->getInstList().erase(BBI++); |
|
225 | 290 |
} |
226 |
- valid &= validateAccess(Ptr, Size, CI); |
|
227 |
- } |
|
228 | 291 |
} |
229 |
- } |
|
230 |
- } |
|
231 |
- if (badFunctions.count(&F)) |
|
232 |
- valid = 0; |
|
233 |
- |
|
234 |
- if (!valid) { |
|
235 |
- DEBUG(F.dump()); |
|
236 |
- ClamBCModule::stop("Verification found errors!", &F); |
|
237 |
- // replace function with call to abort |
|
238 |
- std::vector<constType*>args; |
|
239 |
- FunctionType* abrtTy = FunctionType::get( |
|
240 |
- Type::getVoidTy(F.getContext()),args,false); |
|
241 |
- Constant *func_abort = |
|
242 |
- F.getParent()->getOrInsertFunction("abort", abrtTy); |
|
243 |
- |
|
244 |
- BasicBlock *BB = &F.getEntryBlock(); |
|
245 |
- Instruction *I = &*BB->begin(); |
|
246 |
- Instruction *UI = new UnreachableInst(F.getContext(), I); |
|
247 |
- CallInst *AbrtC = CallInst::Create(func_abort, "", UI); |
|
248 |
- AbrtC->setCallingConv(CallingConv::C); |
|
249 |
- AbrtC->setTailCall(true); |
|
250 |
- AbrtC->setDoesNotReturn(true); |
|
251 |
- AbrtC->setDoesNotThrow(true); |
|
252 |
- // remove all instructions from entry |
|
253 |
- BasicBlock::iterator BBI = I, BBE=BB->end(); |
|
254 |
- while (BBI != BBE) { |
|
255 |
- if (!BBI->use_empty()) |
|
256 |
- BBI->replaceAllUsesWith(UndefValue::get(BBI->getType())); |
|
257 |
- BB->getInstList().erase(BBI++); |
|
258 |
- } |
|
259 |
- } |
|
260 |
- return Changed; |
|
261 |
- } |
|
262 |
- |
|
263 |
- virtual void releaseMemory() { |
|
264 |
- badFunctions.clear(); |
|
265 |
- } |
|
266 |
- |
|
267 |
- virtual void getAnalysisUsage(AnalysisUsage &AU) const { |
|
268 |
- AU.addRequired<TargetData>(); |
|
269 |
- AU.addRequired<DominatorTree>(); |
|
270 |
- AU.addRequired<ScalarEvolution>(); |
|
271 |
- AU.addRequired<PointerTracking>(); |
|
272 |
- AU.addRequired<CallGraph>(); |
|
273 |
- } |
|
274 |
- |
|
275 |
- bool isValid() const { return valid; } |
|
276 |
- private: |
|
277 |
- PointerTracking *PT; |
|
278 |
- TargetData *TD; |
|
279 |
- ScalarEvolution *SE; |
|
280 |
- DominatorTree *DT; |
|
281 |
- DenseMap<Value*, Value*> BaseMap; |
|
282 |
- DenseMap<Value*, Value*> BoundsMap; |
|
283 |
- BasicBlock *AbrtBB; |
|
284 |
- bool Changed; |
|
285 |
- bool valid; |
|
286 |
- Instruction *EP; |
|
287 |
- |
|
288 |
- Instruction *getInsertPoint(Value *V) |
|
289 |
- { |
|
290 |
- BasicBlock::iterator It = EP; |
|
291 |
- if (Instruction *I = dyn_cast<Instruction>(V)) { |
|
292 |
- It = I; |
|
293 |
- ++It; |
|
292 |
+ |
|
293 |
+ // bb#9967 - deleting obsolete termination instructions |
|
294 |
+ for (unsigned i = 0; i < delInst.size(); ++i) |
|
295 |
+ delInst[i]->eraseFromParent(); |
|
296 |
+ |
|
297 |
+ delete expander; |
|
298 |
+ return Changed; |
|
294 | 299 |
} |
295 |
- return &*It; |
|
296 |
- } |
|
297 |
- |
|
298 |
- Value *getPointerBase(Value *Ptr) |
|
299 |
- { |
|
300 |
- if (BaseMap.count(Ptr)) |
|
301 |
- return BaseMap[Ptr]; |
|
302 |
- Value *P = Ptr->stripPointerCasts(); |
|
303 |
- if (BaseMap.count(P)) { |
|
304 |
- return BaseMap[Ptr] = BaseMap[P]; |
|
300 |
+ |
|
301 |
+ virtual void releaseMemory() { |
|
302 |
+ badFunctions.clear(); |
|
305 | 303 |
} |
306 |
- Value *P2 = GetUnderlyingObject(P, TD); |
|
307 |
- if (P2 != P) { |
|
308 |
- Value *V = getPointerBase(P2); |
|
309 |
- return BaseMap[Ptr] = V; |
|
304 |
+ |
|
305 |
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const { |
|
306 |
+#if LLVM_VERSION < 32 |
|
307 |
+ AU.addRequired<TargetData>(); |
|
308 |
+#else |
|
309 |
+ AU.addRequired<DataLayout>(); |
|
310 |
+#endif |
|
311 |
+ AU.addRequired<DominatorTree>(); |
|
312 |
+ AU.addRequired<ScalarEvolution>(); |
|
313 |
+ AU.addRequired<PointerTracking>(); |
|
314 |
+ AU.addRequired<CallGraph>(); |
|
310 | 315 |
} |
311 | 316 |
|
312 |
- constType *P8Ty = |
|
313 |
- PointerType::getUnqual(Type::getInt8Ty(Ptr->getContext())); |
|
314 |
- if (PHINode *PN = dyn_cast<PHINode>(Ptr)) { |
|
315 |
- BasicBlock::iterator It = PN; |
|
316 |
- ++It; |
|
317 |
- PHINode *newPN = PHINode::Create(P8Ty, HINT(PN->getNumIncomingValues()) ".verif.base", &*It); |
|
318 |
- Changed = true; |
|
319 |
- BaseMap[Ptr] = newPN; |
|
320 |
- |
|
321 |
- for (unsigned i=0;i<PN->getNumIncomingValues();i++) { |
|
322 |
- Value *Inc = PN->getIncomingValue(i); |
|
323 |
- Value *V = getPointerBase(Inc); |
|
324 |
- newPN->addIncoming(V, PN->getIncomingBlock(i)); |
|
325 |
- } |
|
326 |
- return newPN; |
|
317 |
+ bool isValid() const { return valid; } |
|
318 |
+ private: |
|
319 |
+ PointerTracking *PT; |
|
320 |
+#if LLVM_VERSION < 32 |
|
321 |
+ TargetData *TD; |
|
322 |
+#else |
|
323 |
+ DataLayout *TD; |
|
324 |
+#endif |
|
325 |
+ ScalarEvolution *SE; |
|
326 |
+ SCEVExpander *expander; |
|
327 |
+ DominatorTree *DT; |
|
328 |
+ DenseMap<Value*, Value*> BaseMap; |
|
329 |
+ DenseMap<Value*, Value*> BoundsMap; |
|
330 |
+ BasicBlock *AbrtBB; |
|
331 |
+ bool Changed; |
|
332 |
+ bool valid; |
|
333 |
+ Instruction *EP; |
|
334 |
+ |
|
335 |
+ Instruction *getInsertPoint(Value *V) |
|
336 |
+ { |
|
337 |
+ BasicBlock::iterator It = EP; |
|
338 |
+ if (Instruction *I = dyn_cast<Instruction>(V)) { |
|
339 |
+ It = I; |
|
340 |
+ ++It; |
|
341 |
+ } |
|
342 |
+ return &*It; |
|
327 | 343 |
} |
328 |
- if (SelectInst *SI = dyn_cast<SelectInst>(Ptr)) { |
|
329 |
- BasicBlock::iterator It = SI; |
|
330 |
- ++It; |
|
331 |
- Value *TrueB = getPointerBase(SI->getTrueValue()); |
|
332 |
- Value *FalseB = getPointerBase(SI->getFalseValue()); |
|
333 |
- if (TrueB && FalseB) { |
|
334 |
- SelectInst *NewSI = SelectInst::Create(SI->getCondition(), TrueB, |
|
335 |
- FalseB, ".select.base", &*It); |
|
336 |
- Changed = true; |
|
337 |
- return BaseMap[Ptr] = NewSI; |
|
338 |
- } |
|
344 |
+ |
|
345 |
+ Value *getPointerBase(Value *Ptr) |
|
346 |
+ { |
|
347 |
+ if (BaseMap.count(Ptr)) |
|
348 |
+ return BaseMap[Ptr]; |
|
349 |
+ Value *P = Ptr->stripPointerCasts(); |
|
350 |
+ if (BaseMap.count(P)) { |
|
351 |
+ return BaseMap[Ptr] = BaseMap[P]; |
|
352 |
+ } |
|
353 |
+ Value *P2 = GetUnderlyingObject(P, TD); |
|
354 |
+ if (P2 != P) { |
|
355 |
+ Value *V = getPointerBase(P2); |
|
356 |
+ return BaseMap[Ptr] = V; |
|
357 |
+ } |
|
358 |
+ |
|
359 |
+ constType *P8Ty = |
|
360 |
+ PointerType::getUnqual(Type::getInt8Ty(Ptr->getContext())); |
|
361 |
+ if (PHINode *PN = dyn_cast<PHINode>(Ptr)) { |
|
362 |
+ BasicBlock::iterator It = PN; |
|
363 |
+ ++It; |
|
364 |
+ PHINode *newPN = PHINode::Create(P8Ty, HINT(PN->getNumIncomingValues()) ".verif.base", &*It); |
|
365 |
+ Changed = true; |
|
366 |
+ BaseMap[Ptr] = newPN; |
|
367 |
+ |
|
368 |
+ for (unsigned i=0;i<PN->getNumIncomingValues();i++) { |
|
369 |
+ Value *Inc = PN->getIncomingValue(i); |
|
370 |
+ Value *V = getPointerBase(Inc); |
|
371 |
+ newPN->addIncoming(V, PN->getIncomingBlock(i)); |
|
372 |
+ } |
|
373 |
+ return newPN; |
|
374 |
+ } |
|
375 |
+ if (SelectInst *SI = dyn_cast<SelectInst>(Ptr)) { |
|
376 |
+ BasicBlock::iterator It = SI; |
|
377 |
+ ++It; |
|
378 |
+ Value *TrueB = getPointerBase(SI->getTrueValue()); |
|
379 |
+ Value *FalseB = getPointerBase(SI->getFalseValue()); |
|
380 |
+ if (TrueB && FalseB) { |
|
381 |
+ SelectInst *NewSI = SelectInst::Create(SI->getCondition(), TrueB, |
|
382 |
+ FalseB, ".select.base", &*It); |
|
383 |
+ Changed = true; |
|
384 |
+ return BaseMap[Ptr] = NewSI; |
|
385 |
+ } |
|
386 |
+ } |
|
387 |
+ if (Ptr->getType() != P8Ty) { |
|
388 |
+ if (Constant *C = dyn_cast<Constant>(Ptr)) |
|
389 |
+ Ptr = ConstantExpr::getPointerCast(C, P8Ty); |
|
390 |
+ else { |
|
391 |
+ Instruction *I = getInsertPoint(Ptr); |
|
392 |
+ Ptr = new BitCastInst(Ptr, P8Ty, "", I); |
|
393 |
+ } |
|
394 |
+ } |
|
395 |
+ return BaseMap[Ptr] = Ptr; |
|
339 | 396 |
} |
340 |
- if (Ptr->getType() != P8Ty) { |
|
341 |
- if (Constant *C = dyn_cast<Constant>(Ptr)) |
|
342 |
- Ptr = ConstantExpr::getPointerCast(C, P8Ty); |
|
343 |
- else { |
|
344 |
- Instruction *I = getInsertPoint(Ptr); |
|
345 |
- Ptr = new BitCastInst(Ptr, P8Ty, "", I); |
|
346 |
- } |
|
397 |
+ |
|
398 |
+ Value* getValAtIdx(Function *F, unsigned Idx) { |
|
399 |
+ Value *Val= NULL; |
|
400 |
+ |
|
401 |
+ // check if accessed Idx is within function parameter list |
|
402 |
+ if (Idx < F->arg_size()) { |
|
403 |
+ Function::arg_iterator It = F->arg_begin(); |
|
404 |
+ Function::arg_iterator ItEnd = F->arg_end(); |
|
405 |
+ for (unsigned i = 0; i < Idx; ++i, ++It) { |
|
406 |
+ // redundant check, should not be possible |
|
407 |
+ if (It == ItEnd) { |
|
408 |
+ // Houston, the impossible has become possible |
|
409 |
+ //printDiagnostic("Idx is outside of Function parameters", F); |
|
410 |
+ errs() << "Idx is outside of Function parameters\n"; |
|
411 |
+ errs() << *F << "\n"; |
|
412 |
+ //valid = 0; |
|
413 |
+ break; |
|
414 |
+ } |
|
415 |
+ } |
|
416 |
+ // retrieve value ptr of argument of F at Idx |
|
417 |
+ Val = &(*It); |
|
418 |
+ } |
|
419 |
+ else { |
|
420 |
+ // Idx is outside function parameter list |
|
421 |
+ //printDiagnostic("Idx is outside of Function parameters", F); |
|
422 |
+ errs() << "Idx is outside of Function parameters\n"; |
|
423 |
+ errs() << *F << "\n"; |
|
424 |
+ //valid = 0; |
|
425 |
+ } |
|
426 |
+ return Val; |
|
347 | 427 |
} |
348 |
- return BaseMap[Ptr] = Ptr; |
|
349 |
- } |
|
350 | 428 |
|
351 |
- Value* getPointerBounds(Value *Base) { |
|
352 |
- if (BoundsMap.count(Base)) |
|
353 |
- return BoundsMap[Base]; |
|
354 |
- constType *I64Ty = |
|
355 |
- Type::getInt64Ty(Base->getContext()); |
|
429 |
+ Value* getPointerBounds(Value *Base) { |
|
430 |
+ if (BoundsMap.count(Base)) |
|
431 |
+ return BoundsMap[Base]; |
|
432 |
+ constType *I64Ty = |
|
433 |
+ Type::getInt64Ty(Base->getContext()); |
|
434 |
+ |
|
435 |
+ if (Base->getType()->isPointerTy()) { |
|
436 |
+ if (Argument *A = dyn_cast<Argument>(Base)) { |
|
437 |
+ Function *F = A->getParent(); |
|
438 |
+ const FunctionType *FT = F->getFunctionType(); |
|
439 |
+ |
|
440 |
+ bool checks = true; |
|
441 |
+ // last argument check |
|
442 |
+ if (A->getArgNo() == (FT->getNumParams()-1)) { |
|
443 |
+ //printDiagnostic("pointer argument cannot be last argument", F); |
|
444 |
+ errs() << "pointer argument cannot be last argument\n"; |
|
445 |
+ errs() << *F << "\n"; |
|
446 |
+ checks = false; |
|
447 |
+ } |
|
448 |
+ |
|
449 |
+ // argument after pointer MUST be a integer (unsigned probably too) |
|
450 |
+ if (checks && !FT->getParamType(A->getArgNo()+1)->isIntegerTy()) { |
|
451 |
+ //printDiagnostic("argument following pointer argument is not an integer", F); |
|
452 |
+ errs() << "argument following pointer argument is not an integer\n"; |
|
453 |
+ errs() << *F << "\n"; |
|
454 |
+ checks = false; |
|
455 |
+ } |
|
456 |
+ |
|
457 |
+ if (checks) |
|
458 |
+ return BoundsMap[Base] = getValAtIdx(F, A->getArgNo()+1); |
|
459 |
+ } |
|
460 |
+ } |
|
461 |
+ |
|
356 | 462 |
#ifndef CLAMBC_COMPILER |
357 |
- // first arg is hidden ctx |
|
358 |
- if (Argument *A = dyn_cast<Argument>(Base)) { |
|
359 |
- if (A->getArgNo() == 0) { |
|
360 |
- constType *Ty = cast<PointerType>(A->getType())->getElementType(); |
|
361 |
- return ConstantInt::get(I64Ty, TD->getTypeAllocSize(Ty)); |
|
362 |
- } |
|
363 |
- } |
|
364 |
- if (LoadInst *LI = dyn_cast<LoadInst>(Base)) { |
|
365 |
- Value *V = GetUnderlyingObject(LI->getPointerOperand()->stripPointerCasts(), TD); |
|
366 |
- if (Argument *A = dyn_cast<Argument>(V)) { |
|
367 |
- if (A->getArgNo() == 0) { |
|
368 |
- // pointers from hidden ctx are trusted to be at least the |
|
369 |
- // size they say they are |
|
370 |
- constType *Ty = cast<PointerType>(LI->getType())->getElementType(); |
|
371 |
- return ConstantInt::get(I64Ty, TD->getTypeAllocSize(Ty)); |
|
372 |
- } |
|
373 |
- } |
|
374 |
- } |
|
463 |
+ // first arg is hidden ctx |
|
464 |
+ if (Argument *A = dyn_cast<Argument>(Base)) { |
|
465 |
+ if (A->getArgNo() == 0) { |
|
466 |
+ constType *Ty = cast<PointerType>(A->getType())->getElementType(); |
|
467 |
+ return ConstantInt::get(I64Ty, TD->getTypeAllocSize(Ty)); |
|
468 |
+ } |
|
469 |
+ } |
|
470 |
+ if (LoadInst *LI = dyn_cast<LoadInst>(Base)) { |
|
471 |
+ Value *V = GetUnderlyingObject(LI->getPointerOperand()->stripPointerCasts(), TD); |
|
472 |
+ if (Argument *A = dyn_cast<Argument>(V)) { |
|
473 |
+ if (A->getArgNo() == 0) { |
|
474 |
+ // pointers from hidden ctx are trusted to be at least the |
|
475 |
+ // size they say they are |
|
476 |
+ constType *Ty = cast<PointerType>(LI->getType())->getElementType(); |
|
477 |
+ return ConstantInt::get(I64Ty, TD->getTypeAllocSize(Ty)); |
|
478 |
+ } |
|
479 |
+ } |
|
480 |
+ } |
|
375 | 481 |
#endif |
376 |
- if (PHINode *PN = dyn_cast<PHINode>(Base)) { |
|
377 |
- BasicBlock::iterator It = PN; |
|
378 |
- ++It; |
|
379 |
- PHINode *newPN = PHINode::Create(I64Ty, HINT(PN->getNumIncomingValues()) ".verif.bounds", &*It); |
|
380 |
- Changed = true; |
|
381 |
- BoundsMap[Base] = newPN; |
|
382 |
- |
|
383 |
- bool good = true; |
|
384 |
- for (unsigned i=0;i<PN->getNumIncomingValues();i++) { |
|
385 |
- Value *Inc = PN->getIncomingValue(i); |
|
386 |
- Value *B = getPointerBounds(Inc); |
|
387 |
- if (!B) { |
|
388 |
- good = false; |
|
389 |
- B = ConstantInt::get(newPN->getType(), 0); |
|
390 |
- DEBUG(dbgs() << "bounds not found while solving phi node: " << *Inc |
|
391 |
- << "\n"); |
|
392 |
- } |
|
393 |
- newPN->addIncoming(B, PN->getIncomingBlock(i)); |
|
394 |
- } |
|
395 |
- if (!good) |
|
396 |
- newPN = 0; |
|
397 |
- return BoundsMap[Base] = newPN; |
|
398 |
- } |
|
399 |
- if (SelectInst *SI = dyn_cast<SelectInst>(Base)) { |
|
400 |
- BasicBlock::iterator It = SI; |
|
401 |
- ++It; |
|
402 |
- Value *TrueB = getPointerBounds(SI->getTrueValue()); |
|
403 |
- Value *FalseB = getPointerBounds(SI->getFalseValue()); |
|
404 |
- if (TrueB && FalseB) { |
|
405 |
- SelectInst *NewSI = SelectInst::Create(SI->getCondition(), TrueB, |
|
406 |
- FalseB, ".select.bounds", &*It); |
|
407 |
- Changed = true; |
|
408 |
- return BoundsMap[Base] = NewSI; |
|
409 |
- } |
|
410 |
- } |
|
482 |
+ if (PHINode *PN = dyn_cast<PHINode>(Base)) { |
|
483 |
+ BasicBlock::iterator It = PN; |
|
484 |
+ ++It; |
|
485 |
+ PHINode *newPN = PHINode::Create(I64Ty, HINT(PN->getNumIncomingValues()) ".verif.bounds", &*It); |
|
486 |
+ Changed = true; |
|
487 |
+ BoundsMap[Base] = newPN; |
|
488 |
+ |
|
489 |
+ bool good = true; |
|
490 |
+ for (unsigned i=0;i<PN->getNumIncomingValues();i++) { |
|
491 |
+ Value *Inc = PN->getIncomingValue(i); |
|
492 |
+ Value *B = getPointerBounds(Inc); |
|
493 |
+ if (!B) { |
|
494 |
+ good = false; |
|
495 |
+ B = ConstantInt::get(newPN->getType(), 0); |
|
496 |
+ DEBUG(dbgs() << "bounds not found while solving phi node: " << *Inc |
|
497 |
+ << "\n"); |
|
498 |
+ } |
|
499 |
+ newPN->addIncoming(B, PN->getIncomingBlock(i)); |
|
500 |
+ } |
|
501 |
+ if (!good) |
|
502 |
+ newPN = 0; |
|
503 |
+ return BoundsMap[Base] = newPN; |
|
504 |
+ } |
|
505 |
+ if (SelectInst *SI = dyn_cast<SelectInst>(Base)) { |
|
506 |
+ BasicBlock::iterator It = SI; |
|
507 |
+ ++It; |
|
508 |
+ Value *TrueB = getPointerBounds(SI->getTrueValue()); |
|
509 |
+ Value *FalseB = getPointerBounds(SI->getFalseValue()); |
|
510 |
+ if (TrueB && FalseB) { |
|
511 |
+ SelectInst *NewSI = SelectInst::Create(SI->getCondition(), TrueB, |
|
512 |
+ FalseB, ".select.bounds", &*It); |
|
513 |
+ Changed = true; |
|
514 |
+ return BoundsMap[Base] = NewSI; |
|
515 |
+ } |
|
516 |
+ } |
|
411 | 517 |
|
412 |
- constType *Ty; |
|
413 |
- Value *V = PT->computeAllocationCountValue(Base, Ty); |
|
414 |
- if (!V) { |
|
415 |
- Base = Base->stripPointerCasts(); |
|
416 |
- if (CallInst *CI = dyn_cast<CallInst>(Base)) { |
|
417 |
- Function *F = CI->getCalledFunction(); |
|
418 |
- const FunctionType *FTy = F->getFunctionType(); |
|
419 |
- // last operand is always size for this API call kind |
|
420 |
- if (F->isDeclaration() && FTy->getNumParams() > 0) { |
|
421 |
- CallSite CS(CI); |
|
422 |
- if (FTy->getParamType(FTy->getNumParams()-1)->isIntegerTy()) |
|
423 |
- V = CS.getArgument(FTy->getNumParams()-1); |
|
518 |
+ constType *Ty; |
|
519 |
+ Value *V = PT->computeAllocationCountValue(Base, Ty); |
|
520 |
+ if (!V) { |
|
521 |
+ Base = Base->stripPointerCasts(); |
|
522 |
+ if (CallInst *CI = dyn_cast<CallInst>(Base)) { |
|
523 |
+ Function *F = CI->getCalledFunction(); |
|
524 |
+ constFunctionType *FTy = F->getFunctionType(); |
|
525 |
+ // last operand is always size for this API call kind |
|
526 |
+ if (F->isDeclaration() && FTy->getNumParams() > 0) { |
|
527 |
+ CallSite CS(CI); |
|
528 |
+ if (FTy->getParamType(FTy->getNumParams()-1)->isIntegerTy()) |
|
529 |
+ V = CS.getArgument(FTy->getNumParams()-1); |
|
530 |
+ } |
|
424 | 531 |
} |
425 |
- } |
|
426 |
- if (!V) |
|
427 |
- return BoundsMap[Base] = 0; |
|
428 |
- } else { |
|
429 |
- unsigned size = TD->getTypeAllocSize(Ty); |
|
430 |
- if (size > 1) { |
|
431 |
- Constant *C = cast<Constant>(V); |
|
432 |
- C = ConstantExpr::getMul(C, |
|
433 |
- ConstantInt::get(Type::getInt32Ty(C->getContext()), |
|
434 |
- size)); |
|
435 |
- V = C; |
|
436 |
- } |
|
437 |
- } |
|
438 |
- if (V->getType() != I64Ty) { |
|
439 |
- if (Constant *C = dyn_cast<Constant>(V)) |
|
440 |
- V = ConstantExpr::getZExt(C, I64Ty); |
|
441 |
- else { |
|
442 |
- Instruction *I = getInsertPoint(V); |
|
443 |
- V = new ZExtInst(V, I64Ty, "", I); |
|
444 |
- } |
|
445 |
- } |
|
446 |
- return BoundsMap[Base] = V; |
|
447 |
- } |
|
448 |
- |
|
449 |
- MDNode *getLocation(Instruction *I, bool &Approximate, unsigned MDDbgKind) |
|
450 |
- { |
|
451 |
- Approximate = false; |
|
452 |
- if (MDNode *Dbg = I->getMetadata(MDDbgKind)) |
|
453 |
- return Dbg; |
|
454 |
- if (!MDDbgKind) |
|
455 |
- return 0; |
|
456 |
- Approximate = true; |
|
457 |
- BasicBlock::iterator It = I; |
|
458 |
- while (It != I->getParent()->begin()) { |
|
459 |
- --It; |
|
460 |
- if (MDNode *Dbg = It->getMetadata(MDDbgKind)) |
|
461 |
- return Dbg; |
|
462 |
- } |
|
463 |
- BasicBlock *BB = I->getParent(); |
|
464 |
- while ((BB = BB->getUniquePredecessor())) { |
|
465 |
- It = BB->end(); |
|
466 |
- while (It != BB->begin()) { |
|
467 |
- --It; |
|
468 |
- if (MDNode *Dbg = It->getMetadata(MDDbgKind)) |
|
469 |
- return Dbg; |
|
470 |
- } |
|
471 |
- } |
|
472 |
- return 0; |
|
473 |
- } |
|
474 |
- |
|
475 |
- bool insertCheck(const SCEV *Idx, const SCEV *Limit, Instruction *I, |
|
476 |
- bool strict) |
|
477 |
- { |
|
478 |
- if (isa<SCEVCouldNotCompute>(Idx) && isa<SCEVCouldNotCompute>(Limit)) { |
|
479 |
- errs() << "Could not compute the index and the limit!: \n" << *I << "\n"; |
|
480 |
- return false; |
|
481 |
- } |
|
482 |
- if (isa<SCEVCouldNotCompute>(Idx)) { |
|
483 |
- errs() << "Could not compute index: \n" << *I << "\n"; |
|
484 |
- return false; |
|
485 |
- } |
|
486 |
- if (isa<SCEVCouldNotCompute>(Limit)) { |
|
487 |
- errs() << "Could not compute limit: " << *I << "\n"; |
|
488 |
- return false; |
|
532 |
+ if (!V) |
|
533 |
+ return BoundsMap[Base] = 0; |
|
534 |
+ } else { |
|
535 |
+ unsigned size = TD->getTypeAllocSize(Ty); |
|
536 |
+ if (size > 1) { |
|
537 |
+ Constant *C = cast<Constant>(V); |
|
538 |
+ C = ConstantExpr::getMul(C, |
|
539 |
+ ConstantInt::get(Type::getInt32Ty(C->getContext()), |
|
540 |
+ size)); |
|
541 |
+ V = C; |
|
542 |
+ } |
|
543 |
+ } |
|
544 |
+ if (V->getType() != I64Ty) { |
|
545 |
+ if (Constant *C = dyn_cast<Constant>(V)) |
|
546 |
+ V = ConstantExpr::getZExt(C, I64Ty); |
|
547 |
+ else { |
|
548 |
+ Instruction *I = getInsertPoint(V); |
|
549 |
+ V = new ZExtInst(V, I64Ty, "", I); |
|
550 |
+ } |
|
551 |
+ } |
|
552 |
+ return BoundsMap[Base] = V; |
|
489 | 553 |
} |
490 |
- BasicBlock *BB = I->getParent(); |
|
491 |
- BasicBlock::iterator It = I; |
|
492 |
- BasicBlock *newBB = SplitBlock(BB, &*It, this); |
|
493 |
- PHINode *PN; |
|
494 |
- unsigned MDDbgKind = I->getContext().getMDKindID("dbg"); |
|
495 |
- //verifyFunction(*BB->getParent()); |
|
496 |
- if (!AbrtBB) { |
|
497 |
- std::vector<constType*>args; |
|
498 |
- FunctionType* abrtTy = FunctionType::get( |
|
499 |
- Type::getVoidTy(BB->getContext()),args,false); |
|
500 |
- args.push_back(Type::getInt32Ty(BB->getContext())); |
|
501 |
- FunctionType* rterrTy = FunctionType::get( |
|
502 |
- Type::getInt32Ty(BB->getContext()),args,false); |
|
503 |
- Constant *func_abort = |
|
504 |
- BB->getParent()->getParent()->getOrInsertFunction("abort", abrtTy); |
|
505 |
- Constant *func_rterr = |
|
506 |
- BB->getParent()->getParent()->getOrInsertFunction("bytecode_rt_error", rterrTy); |
|
507 |
- AbrtBB = BasicBlock::Create(BB->getContext(), "", BB->getParent()); |
|
508 |
- PN = PHINode::Create(Type::getInt32Ty(BB->getContext()),HINT(1) "", |
|
509 |
- AbrtBB); |
|
510 |
- if (MDDbgKind) { |
|
511 |
- CallInst *RtErrCall = CallInst::Create(func_rterr, PN, "", AbrtBB); |
|
512 |
- RtErrCall->setCallingConv(CallingConv::C); |
|
513 |
- RtErrCall->setTailCall(true); |
|
514 |
- RtErrCall->setDoesNotThrow(true); |
|
515 |
- } |
|
516 |
- CallInst* AbrtC = CallInst::Create(func_abort, "", AbrtBB); |
|
517 |
- AbrtC->setCallingConv(CallingConv::C); |
|
518 |
- AbrtC->setTailCall(true); |
|
519 |
- AbrtC->setDoesNotReturn(true); |
|
520 |
- AbrtC->setDoesNotThrow(true); |
|
521 |
- new UnreachableInst(BB->getContext(), AbrtBB); |
|
522 |
- DT->addNewBlock(AbrtBB, BB); |
|
523 |
- //verifyFunction(*BB->getParent()); |
|
524 |
- } else { |
|
525 |
- PN = cast<PHINode>(AbrtBB->begin()); |
|
554 |
+ |
|
555 |
+ MDNode *getLocation(Instruction *I, bool &Approximate, unsigned MDDbgKind) |
|
556 |
+ { |
|
557 |
+ Approximate = false; |
|
558 |
+ if (MDNode *Dbg = I->getMetadata(MDDbgKind)) |
|
559 |
+ return Dbg; |
|
560 |
+ if (!MDDbgKind) |
|
561 |
+ return 0; |
|
562 |
+ Approximate = true; |
|
563 |
+ BasicBlock::iterator It = I; |
|
564 |
+ while (It != I->getParent()->begin()) { |
|
565 |
+ --It; |
|
566 |
+ if (MDNode *Dbg = It->getMetadata(MDDbgKind)) |
|
567 |
+ return Dbg; |
|
568 |
+ } |
|
569 |
+ BasicBlock *BB = I->getParent(); |
|
570 |
+ while ((BB = BB->getUniquePredecessor())) { |
|
571 |
+ It = BB->end(); |
|
572 |
+ while (It != BB->begin()) { |
|
573 |
+ --It; |
|
574 |
+ if (MDNode *Dbg = It->getMetadata(MDDbgKind)) |
|
575 |
+ return Dbg; |
|
576 |
+ } |
|
577 |
+ } |
|
578 |
+ return 0; |
|
526 | 579 |
} |
527 |
- unsigned locationid = 0; |
|
528 |
- bool Approximate; |
|
529 |
- if (MDNode *Dbg = getLocation(I, Approximate, MDDbgKind)) { |
|
530 |
- DILocation Loc(Dbg); |
|
531 |
- locationid = Loc.getLineNumber() << 8; |
|
532 |
- unsigned col = Loc.getColumnNumber(); |
|
533 |
- if (col > 254) |
|
534 |
- col = 254; |
|
535 |
- if (Approximate) |
|
536 |
- col = 255; |
|
537 |
- locationid |= col; |
|
538 |
-// Loc.getFilename(); |
|
539 |
- } else { |
|
540 |
- static int wcounters = 100000; |
|
541 |
- locationid = (wcounters++)<<8; |
|
542 |
- /*errs() << "fake location: " << (locationid>>8) << "\n"; |
|
543 |
- I->dump(); |
|
544 |
- I->getParent()->dump();*/ |
|
580 |
+ |
|
581 |
+ bool insertCheck(const SCEV *Idx, const SCEV *Limit, Instruction *I, |
|
582 |
+ bool strict) |
|
583 |
+ { |
|
584 |
+ if (isa<SCEVCouldNotCompute>(Idx) && isa<SCEVCouldNotCompute>(Limit)) { |
|
585 |
+ errs() << "Could not compute the index and the limit!: \n" << *I << "\n"; |
|
586 |
+ return false; |
|
587 |
+ } |
|
588 |
+ if (isa<SCEVCouldNotCompute>(Idx)) { |
|
589 |
+ errs() << "Could not compute index: \n" << *I << "\n"; |
|
590 |
+ return false; |
|
591 |
+ } |
|
592 |
+ if (isa<SCEVCouldNotCompute>(Limit)) { |
|
593 |
+ errs() << "Could not compute limit: " << *I << "\n"; |
|
594 |
+ return false; |
|
595 |
+ } |
|
596 |
+ BasicBlock *BB = I->getParent(); |
|
597 |
+ BasicBlock::iterator It = I; |
|
598 |
+ BasicBlock *newBB = SplitBlock(BB, &*It, this); |
|
599 |
+ PHINode *PN; |
|
600 |
+ unsigned MDDbgKind = I->getContext().getMDKindID("dbg"); |
|
601 |
+ //verifyFunction(*BB->getParent()); |
|
602 |
+ if (!AbrtBB) { |
|
603 |
+ std::vector<constType*>args; |
|
604 |
+ FunctionType* abrtTy = FunctionType::get(Type::getVoidTy(BB->getContext()),args,false); |
|
605 |
+ args.push_back(Type::getInt32Ty(BB->getContext())); |
|
606 |
+ FunctionType* rterrTy = FunctionType::get(Type::getInt32Ty(BB->getContext()),args,false); |
|
607 |
+ Constant *func_abort = BB->getParent()->getParent()->getOrInsertFunction("abort", abrtTy); |
|
608 |
+ Constant *func_rterr = BB->getParent()->getParent()->getOrInsertFunction("bytecode_rt_error", |
|
609 |
+ rterrTy); |
|
610 |
+ AbrtBB = BasicBlock::Create(BB->getContext(), "rterr.trig", BB->getParent()); |
|
611 |
+ |
|
612 |
+ PN = PHINode::Create(Type::getInt32Ty(BB->getContext()),HINT(1) "", |
|
613 |
+ AbrtBB); |
|
614 |
+ if (MDDbgKind) { |
|
615 |
+ CallInst *RtErrCall = CallInst::Create(func_rterr, PN, "", AbrtBB); |
|
616 |
+ RtErrCall->setCallingConv(CallingConv::C); |
|
617 |
+ RtErrCall->setTailCall(true); |
|
618 |
+#if LLVM_VERSION < 32 |
|
619 |
+ RtErrCall->setDoesNotThrow(true); |
|
620 |
+#else |
|
621 |
+ RtErrCall->setDoesNotThrow(); |
|
622 |
+#endif |
|
623 |
+ } |
|
624 |
+ CallInst* AbrtC = CallInst::Create(func_abort, "", AbrtBB); |
|
625 |
+ AbrtC->setCallingConv(CallingConv::C); |
|
626 |
+ AbrtC->setTailCall(true); |
|
627 |
+#if LLVM_VERSION < 32 |
|
628 |
+ AbrtC->setDoesNotReturn(true); |
|
629 |
+ AbrtC->setDoesNotThrow(true); |
|
630 |
+#else |
|
631 |
+ AbrtC->setDoesNotReturn(); |
|
632 |
+ AbrtC->setDoesNotThrow(); |
|
633 |
+#endif |
|
634 |
+ new UnreachableInst(BB->getContext(), AbrtBB); |
|
635 |
+ DT->addNewBlock(AbrtBB, BB); |
|
636 |
+ //verifyFunction(*BB->getParent()); |
|
637 |
+ } else { |
|
638 |
+ PN = cast<PHINode>(AbrtBB->begin()); |
|
639 |
+ } |
|
640 |
+ unsigned locationid = 0; |
|
641 |
+ bool Approximate; |
|
642 |
+ if (MDNode *Dbg = getLocation(I, Approximate, MDDbgKind)) { |
|
643 |
+ DILocation Loc(Dbg); |
|
644 |
+ locationid = Loc.getLineNumber() << 8; |
|
645 |
+ unsigned col = Loc.getColumnNumber(); |
|
646 |
+ if (col > 254) |
|
647 |
+ col = 254; |
|
648 |
+ if (Approximate) |
|
649 |
+ col = 255; |
|
650 |
+ locationid |= col; |
|
651 |
+ } |
|
652 |
+ PN->addIncoming(ConstantInt::get(Type::getInt32Ty(BB->getContext()), |
|
653 |
+ locationid), BB); |
|
654 |
+ TerminatorInst *TI = BB->getTerminator(); |
|
655 |
+ Value *IdxV = expander->expandCodeFor(Idx, Limit->getType(), TI); |
|
656 |
+ Value *LimitV = expander->expandCodeFor(Limit, Limit->getType(), TI); |
|
657 |
+ if (isa<Instruction>(IdxV) && |
|
658 |
+ !DT->dominates(cast<Instruction>(IdxV)->getParent(),I->getParent())) { |
|
659 |
+ printLocation(I, true); |
|
660 |
+ errs() << "basic block with value [ " << IdxV->getName(); |
|
661 |
+ errs() << " ] with limit [ " << LimitV->getName(); |
|
662 |
+ errs() << " ] does not dominate" << *I << "\n"; |
|
663 |
+ return false; |
|
664 |
+ } |
|
665 |
+ if (isa<Instruction>(LimitV) && |
|
666 |
+ !DT->dominates(cast<Instruction>(LimitV)->getParent(),I->getParent())) { |
|
667 |
+ printLocation(I, true); |
|
668 |
+ errs() << "basic block with limit [" << LimitV->getName(); |
|
669 |
+ errs() << " ] on value [ " << IdxV->getName(); |
|
670 |
+ errs() << " ] does not dominate" << *I << "\n"; |
|
671 |
+ return false; |
|
672 |
+ } |
|
673 |
+ Value *Cond = new ICmpInst(TI, strict ? |
|
674 |
+ ICmpInst::ICMP_ULT : |
|
675 |
+ ICmpInst::ICMP_ULE, IdxV, LimitV); |
|
676 |
+ BranchInst::Create(newBB, AbrtBB, Cond, TI); |
|
677 |
+ //TI->eraseFromParent(); |
|
678 |
+ delInst.push_back(TI); |
|
679 |
+ // Update dominator info |
|
680 |
+ BasicBlock *DomBB = |
|
681 |
+ DT->findNearestCommonDominator(BB, DT->getNode(AbrtBB)->getIDom()->getBlock()); |
|
682 |
+ DT->changeImmediateDominator(AbrtBB, DomBB); |
|
683 |
+ return true; |
|
545 | 684 |
} |
546 |
- PN->addIncoming(ConstantInt::get(Type::getInt32Ty(BB->getContext()), |
|
547 |
- locationid), BB); |
|
548 |
- |
|
549 |
- TerminatorInst *TI = BB->getTerminator(); |
|
550 |
- SCEVExpander expander(*SE OPT("SCEVexpander")); |
|
551 |
- Value *IdxV = expander.expandCodeFor(Idx, Limit->getType(), TI); |
|
552 |
-/* if (isa<PointerType>(IdxV->getType())) { |
|
553 |
- IdxV = new PtrToIntInst(IdxV, Idx->getType(), "", TI); |
|
554 |
- }*/ |
|
555 |
- //verifyFunction(*BB->getParent()); |
|
556 |
- Value *LimitV = expander.expandCodeFor(Limit, Limit->getType(), TI); |
|
557 |
- //verifyFunction(*BB->getParent()); |
|
558 |
- Value *Cond = new ICmpInst(TI, strict ? |
|
559 |
- ICmpInst::ICMP_ULT : |
|
560 |
- ICmpInst::ICMP_ULE, IdxV, LimitV); |
|
561 |
- //verifyFunction(*BB->getParent()); |
|
562 |
- BranchInst::Create(newBB, AbrtBB, Cond, TI); |
|
563 |
- TI->eraseFromParent(); |
|
564 |
- // Update dominator info |
|
565 |
- BasicBlock *DomBB = |
|
566 |
- DT->findNearestCommonDominator(BB, |
|
567 |
- DT->getNode(AbrtBB)->getIDom()->getBlock()); |
|
568 |
- DT->changeImmediateDominator(AbrtBB, DomBB); |
|
569 |
- //verifyFunction(*BB->getParent()); |
|
570 |
- return true; |
|
571 |
- } |
|
572 |
- |
|
573 |
- static void MakeCompatible(ScalarEvolution *SE, const SCEV*& LHS, const SCEV*& RHS) |
|
574 |
- { |
|
575 |
- if (const SCEVZeroExtendExpr *ZL = dyn_cast<SCEVZeroExtendExpr>(LHS)) |
|
576 |
- LHS = ZL->getOperand(); |
|
577 |
- if (const SCEVZeroExtendExpr *ZR = dyn_cast<SCEVZeroExtendExpr>(RHS)) |
|
578 |
- RHS = ZR->getOperand(); |
|
579 |
- |
|
580 |
- constType* LTy = SE->getEffectiveSCEVType(LHS->getType()); |
|
581 |
- constType *RTy = SE->getEffectiveSCEVType(RHS->getType()); |
|
582 |
- if (SE->getTypeSizeInBits(RTy) > SE->getTypeSizeInBits(LTy)) |
|
583 |
- LTy = RTy; |
|
584 |
- LHS = SE->getNoopOrZeroExtend(LHS, LTy); |
|
585 |
- RHS = SE->getNoopOrZeroExtend(RHS, LTy); |
|
586 |
- } |
|
587 |
- bool checkCond(Instruction *ICI, Instruction *I, bool equal) |
|
588 |
- { |
|
589 |
- for (Value::use_iterator JU=ICI->use_begin(),JUE=ICI->use_end(); |
|
590 |
- JU != JUE; ++JU) { |
|
591 |
- Value *JU_V = *JU; |
|
592 |
- if (BranchInst *BI = dyn_cast<BranchInst>(JU_V)) { |
|
593 |
- if (!BI->isConditional()) |
|
594 |
- continue; |
|
595 |
- BasicBlock *S = BI->getSuccessor(equal); |
|
596 |
- if (DT->dominates(S, I->getParent())) |
|
597 |
- return true; |
|
598 |
- } |
|
599 |
- if (BinaryOperator *BI = dyn_cast<BinaryOperator>(JU_V)) { |
|
600 |
- if (BI->getOpcode() == Instruction::Or && |
|
601 |
- checkCond(BI, I, equal)) |
|
602 |
- return true; |
|
603 |
- if (BI->getOpcode() == Instruction::And && |
|
604 |
- checkCond(BI, I, !equal)) |
|
605 |
- return true; |
|
606 |
- } |
|
685 |
+ |
|
686 |
+ static void MakeCompatible(ScalarEvolution *SE, const SCEV*& LHS, const SCEV*& RHS) |
|
687 |
+ { |
|
688 |
+ if (const SCEVZeroExtendExpr *ZL = dyn_cast<SCEVZeroExtendExpr>(LHS)) |
|
689 |
+ LHS = ZL->getOperand(); |
|
690 |
+ if (const SCEVZeroExtendExpr *ZR = dyn_cast<SCEVZeroExtendExpr>(RHS)) |
|
691 |
+ RHS = ZR->getOperand(); |
|
692 |
+ |
|
693 |
+ constType* LTy = SE->getEffectiveSCEVType(LHS->getType()); |
|
694 |
+ constType *RTy = SE->getEffectiveSCEVType(RHS->getType()); |
|
695 |
+ if (SE->getTypeSizeInBits(RTy) > SE->getTypeSizeInBits(LTy)) |
|
696 |
+ LTy = RTy; |
|
697 |
+ LHS = SE->getNoopOrZeroExtend(LHS, LTy); |
|
698 |
+ RHS = SE->getNoopOrZeroExtend(RHS, LTy); |
|
607 | 699 |
} |
608 |
- return false; |
|
609 |
- } |
|
610 |
- |
|
611 |
- bool checkCondition(Instruction *CI, Instruction *I) |
|
612 |
- { |
|
613 |
- for (Value::use_iterator U=CI->use_begin(),UE=CI->use_end(); |
|
614 |
- U != UE; ++U) { |
|
615 |
- Value *U_V = *U; |
|
616 |
- if (ICmpInst *ICI = dyn_cast<ICmpInst>(U_V)) { |
|
617 |
- if (ICI->getOperand(0)->stripPointerCasts() == CI && |
|
618 |
- isa<ConstantPointerNull>(ICI->getOperand(1))) { |
|
619 |
- if (checkCond(ICI, I, ICI->getPredicate() == ICmpInst::ICMP_EQ)) |
|
620 |
- return true; |
|
621 |
- } |
|
622 |
- } |
|
700 |
+ |
|
701 |
+ bool checkCond(Instruction *ICI, Instruction *I, bool equal) |
|
702 |
+ { |
|
703 |
+ for (Value::use_iterator JU=ICI->use_begin(),JUE=ICI->use_end(); |
|
704 |
+ JU != JUE; ++JU) { |
|
705 |
+ Value *JU_V = *JU; |
|
706 |
+ if (BranchInst *BI = dyn_cast<BranchInst>(JU_V)) { |
|
707 |
+ if (!BI->isConditional()) |
|
708 |
+ continue; |
|
709 |
+ BasicBlock *S = BI->getSuccessor(equal); |
|
710 |
+ if (DT->dominates(S, I->getParent())) |
|
711 |
+ return true; |
|
712 |
+ } |
|
713 |
+ if (BinaryOperator *BI = dyn_cast<BinaryOperator>(JU_V)) { |
|
714 |
+ if (BI->getOpcode() == Instruction::Or && |
|
715 |
+ checkCond(BI, I, equal)) |
|
716 |
+ return true; |
|
717 |
+ if (BI->getOpcode() == Instruction::And && |
|
718 |
+ checkCond(BI, I, !equal)) |
|
719 |
+ return true; |
|
720 |
+ } |
|
721 |
+ } |
|
722 |
+ return false; |
|
623 | 723 |
} |
624 |
- return false; |
|
625 |
- } |
|
626 |
- |
|
627 |
- bool validateAccess(Value *Pointer, Value *Length, Instruction *I) |
|
628 |
- { |
|
629 |
- // get base |
|
630 |
- Value *Base = getPointerBase(Pointer); |
|
631 |
- |
|
632 |
- Value *SBase = Base->stripPointerCasts(); |
|
633 |
- // get bounds |
|
634 |
- Value *Bounds = getPointerBounds(SBase); |
|
635 |
- if (!Bounds) { |
|
636 |
- printLocation(I, true); |
|
637 |
- errs() << "no bounds for base "; |
|
638 |
- printValue(SBase); |
|
639 |
- errs() << " while checking access to "; |
|
640 |
- printValue(Pointer); |
|
641 |
- errs() << " of length "; |
|
642 |
- printValue(Length); |
|
643 |
- errs() << "\n"; |
|
644 | 724 |
|
725 |
+ bool checkCondition(Instruction *CI, Instruction *I) |
|
726 |
+ { |
|
727 |
+ for (Value::use_iterator U=CI->use_begin(),UE=CI->use_end(); |
|
728 |
+ U != UE; ++U) { |
|
729 |
+ Value *U_V = *U; |
|
730 |
+ if (ICmpInst *ICI = dyn_cast<ICmpInst>(U_V)) { |
|
731 |
+ if (ICI->getOperand(0)->stripPointerCasts() == CI && |
|
732 |
+ isa<ConstantPointerNull>(ICI->getOperand(1))) { |
|
733 |
+ if (checkCond(ICI, I, ICI->getPredicate() == ICmpInst::ICMP_EQ)) |
|
734 |
+ return true; |
|
735 |
+ } |
|
736 |
+ } |
|
737 |
+ } |
|
645 | 738 |
return false; |
646 |
- } |
|
647 |
- |
|
648 |
- if (CallInst *CI = dyn_cast<CallInst>(Base->stripPointerCasts())) { |
|
649 |
- if (I->getParent() == CI->getParent()) { |
|
650 |
- printLocation(I, true); |
|
651 |
- errs() << "no null pointer check of pointer "; |
|
652 |
- printValue(Base, false, true); |
|
653 |
- errs() << " obtained by function call"; |
|
654 |
- errs() << " before use in same block\n"; |
|
655 |
- return false; |
|
656 |
- } |
|
657 |
- if (!checkCondition(CI, I)) { |
|
658 |
- printLocation(I, true); |
|
659 |
- errs() << "no null pointer check of pointer "; |
|
660 |
- printValue(Base, false, true); |
|
661 |
- errs() << " obtained by function call"; |
|
662 |
- errs() << " before use\n"; |
|
663 |
- return false; |
|
664 |
- } |
|
665 |
- } |
|
666 |
- |
|
667 |
- constType *I64Ty = |
|
739 |
+ } |
|
740 |
+ |
|
741 |
+ bool validateAccess(Value *Pointer, Value *Length, Instruction *I) |
|
742 |
+ { |
|
743 |
+ // get base |
|
744 |
+ Value *Base = getPointerBase(Pointer); |
|
745 |
+ |
|
746 |
+ Value *SBase = Base->stripPointerCasts(); |
|
747 |
+ // get bounds |
|
748 |
+ Value *Bounds = getPointerBounds(SBase); |
|
749 |
+ if (!Bounds) { |
|
750 |
+ printLocation(I, true); |
|
751 |
+ errs() << "no bounds for base "; |
|
752 |
+ printValue(SBase); |
|
753 |
+ errs() << " while checking access to "; |
|
754 |
+ printValue(Pointer); |
|
755 |
+ errs() << " of length "; |
|
756 |
+ printValue(Length); |
|
757 |
+ errs() << "\n"; |
|
758 |
+ |
|
759 |
+ return false; |
|
760 |
+ } |
|
761 |
+ |
|
762 |
+ // checks if a NULL pointer check (returned from function) is made: |
|
763 |
+ if (CallInst *CI = dyn_cast<CallInst>(Base->stripPointerCasts())) { |
|
764 |
+ // by checking if use is in the same block (i.e. no branching decisions) |
|
765 |
+ if (I->getParent() == CI->getParent()) { |
|
766 |
+ printLocation(I, true); |
|
767 |
+ errs() << "no null pointer check of pointer "; |
|
768 |
+ printValue(Base, false, true); |
|
769 |
+ errs() << " obtained by function call"; |
|
770 |
+ errs() << " before use in same block\n"; |
|
771 |
+ return false; |
|
772 |
+ } |
|
773 |
+ // by checking if a conditional contains the values in question somewhere |
|
774 |
+ // between their usage |
|
775 |
+ if (!checkCondition(CI, I)) { |
|
776 |
+ printLocation(I, true); |
|
777 |
+ errs() << "no null pointer check of pointer "; |
|
778 |
+ printValue(Base, false, true); |
|
779 |
+ errs() << " obtained by function call"; |
|
780 |
+ errs() << " before use\n"; |
|
781 |
+ return false; |
|
782 |
+ } |
|
783 |
+ } |
|
784 |
+ |
|
785 |
+ constType *I64Ty = |
|
668 | 786 |
Type::getInt64Ty(Base->getContext()); |
669 |
- const SCEV *SLen = SE->getSCEV(Length); |
|
670 |
- const SCEV *OffsetP = SE->getMinusSCEV(SE->getSCEV(Pointer), |
|
671 |
- SE->getSCEV(Base)); |
|
672 |
- SLen = SE->getNoopOrZeroExtend(SLen, I64Ty); |
|
673 |
- OffsetP = SE->getNoopOrZeroExtend(OffsetP, I64Ty); |
|
674 |
- const SCEV *Limit = SE->getSCEV(Bounds); |
|
675 |
- Limit = SE->getNoopOrZeroExtend(Limit, I64Ty); |
|
676 |
- |
|
677 |
- DEBUG(dbgs() << "Checking access to " << *Pointer << " of length " << |
|
678 |
- *Length << "\n"); |
|
679 |
- if (OffsetP == Limit) { |
|
787 |
+ const SCEV *SLen = SE->getSCEV(Length); |
|
788 |
+ const SCEV *OffsetP = SE->getMinusSCEV(SE->getSCEV(Pointer), |
|
789 |
+ SE->getSCEV(Base)); |
|
790 |
+ SLen = SE->getNoopOrZeroExtend(SLen, I64Ty); |
|
791 |
+ OffsetP = SE->getNoopOrZeroExtend(OffsetP, I64Ty); |
|
792 |
+ const SCEV *Limit = SE->getSCEV(Bounds); |
|
793 |
+ Limit = SE->getNoopOrZeroExtend(Limit, I64Ty); |
|
794 |
+ |
|
795 |
+ DEBUG(dbgs() << "Checking access to " << *Pointer << " of length " << |
|
796 |
+ *Length << "\n"); |
|
797 |
+ if (OffsetP == Limit) { |
|
680 | 798 |
printLocation(I, true); |
681 | 799 |
errs() << "OffsetP == Limit: " << *OffsetP << "\n"; |
682 | 800 |
errs() << " while checking access to "; |
... | ... |
@@ -685,64 +805,72 @@ namespace llvm { |
685 | 685 |
printValue(Length); |
686 | 686 |
errs() << "\n"; |
687 | 687 |
return false; |
688 |
- } |
|
688 |
+ } |
|
689 | 689 |
|
690 |
- if (SLen == Limit) { |
|
690 |
+ if (SLen == Limit) { |
|
691 | 691 |
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(OffsetP)) { |
692 |
- if (SC->isZero()) |
|
693 |
- return true; |
|
692 |
+ if (SC->isZero()) |
|
693 |
+ return true; |
|
694 | 694 |
} |
695 | 695 |
errs() << "SLen == Limit: " << *SLen << "\n"; |
696 | 696 |
errs() << " while checking access to " << *Pointer << " of length " |
697 |
- << *Length << " at " << *I << "\n"; |
|
697 |
+ << *Length << " at " << *I << "\n"; |
|
698 | 698 |
return false; |
699 |
- } |
|
700 |
- |
|
701 |
- bool valid = true; |
|
702 |
- SLen = SE->getAddExpr(OffsetP, SLen); |
|
703 |
- // check that offset + slen <= limit; |
|
704 |
- // umax(offset+slen, limit) == limit is a sufficient (but not necessary |
|
705 |
- // condition) |
|
706 |
- const SCEV *MaxL = SE->getUMaxExpr(SLen, Limit); |
|
707 |
- if (MaxL != Limit) { |
|
699 |
+ } |
|
700 |
+ |
|
701 |
+ bool valid = true; |
|
702 |
+ SLen = SE->getAddExpr(OffsetP, SLen); |
|
703 |
+ // check that offset + slen <= limit; |
|
704 |
+ // umax(offset+slen, limit) == limit is a sufficient (but not necessary |
|
705 |
+ // condition) |
|
706 |
+ const SCEV *MaxL = SE->getUMaxExpr(SLen, Limit); |
|
707 |
+ if (MaxL != Limit) { |
|
708 | 708 |
DEBUG(dbgs() << "MaxL != Limit: " << *MaxL << ", " << *Limit << "\n"); |
709 | 709 |
valid &= insertCheck(SLen, Limit, I, false); |
710 |
- } |
|
710 |
+ } |
|
711 | 711 |
|
712 |
- //TODO: nullpointer check |
|
713 |
- const SCEV *Max = SE->getUMaxExpr(OffsetP, Limit); |
|
714 |
- if (Max == Limit) |
|
712 |
+ //TODO: nullpointer check |
|
713 |
+ const SCEV *Max = SE->getUMaxExpr(OffsetP, Limit); |
|
714 |
+ if (Max == Limit) |
|
715 | 715 |
return valid; |
716 |
- DEBUG(dbgs() << "Max != Limit: " << *Max << ", " << *Limit << "\n"); |
|
717 |
- |
|
718 |
- // check that offset < limit |
|
719 |
- valid &= insertCheck(OffsetP, Limit, I, true); |
|
720 |
- return valid; |
|
721 |
- } |
|
722 |
- |
|
723 |
- bool validateAccess(Value *Pointer, unsigned size, Instruction *I) |
|
724 |
- { |
|
725 |
- return validateAccess(Pointer, |
|
726 |
- ConstantInt::get(Type::getInt32Ty(Pointer->getContext()), |
|
727 |
- size), I); |
|
728 |
- } |
|
716 |
+ DEBUG(dbgs() << "Max != Limit: " << *Max << ", " << *Limit << "\n"); |
|
717 |
+ |
|
718 |
+ // check that offset < limit |
|
719 |
+ valid &= insertCheck(OffsetP, Limit, I, true); |
|
720 |
+ return valid; |
|
721 |
+ } |
|
722 |
+ |
|
723 |
+ bool validateAccess(Value *Pointer, unsigned size, Instruction *I) |
|
724 |
+ { |
|
725 |
+ return validateAccess(Pointer, |
|
726 |
+ ConstantInt::get(Type::getInt32Ty(Pointer->getContext()), |
|
727 |
+ size), I); |
|
728 |
+ } |
|
729 |
+ |
|
729 | 730 |
}; |
730 |
- char PtrVerifier::ID; |
|
731 |
+ char PtrVerifier::ID; |
|
731 | 732 |
|
732 |
-} |
|
733 |
-#ifdef LLVM30 |
|
733 |
+} /* end namespace llvm */ |
|
734 |
+#if LLVM_VERSION >= 30 |
|
734 | 735 |
INITIALIZE_PASS_BEGIN(PtrVerifier, "", "", false, false) |
736 |
+#if LLVM_VERSION < 32 |
|
735 | 737 |
INITIALIZE_PASS_DEPENDENCY(TargetData) |
738 |
+#else |
|
739 |
+INITIALIZE_PASS_DEPENDENCY(DataLayout) |
|
740 |
+#endif |
|
736 | 741 |
INITIALIZE_PASS_DEPENDENCY(DominatorTree) |
737 | 742 |
INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) |
743 |
+#if LLVM_VERSION < 34 |
|
738 | 744 |
INITIALIZE_AG_DEPENDENCY(CallGraph) |
745 |
+#else |
|
746 |
+INITIALIZE_PASS_DEPENDENCY(CallGraph) |
|
747 |
+#endif |
|
739 | 748 |
INITIALIZE_PASS_DEPENDENCY(PointerTracking) |
740 |
-INITIALIZE_PASS_END(PtrVerifier, "clambcrtchecks", "ClamBC RTchecks", false, false) |
|
749 |
+INITIALIZE_PASS_END(PtrVerifier, "clambc-rtchecks", "ClamBC RTchecks", false, false) |
|
741 | 750 |
#endif |
742 | 751 |
|
743 | 752 |
|
744 | 753 |
llvm::Pass *createClamBCRTChecks() |
745 | 754 |
{ |
746 |
- return new PtrVerifier(); |
|
755 |
+ return new PtrVerifier(); |
|
747 | 756 |
} |
748 |
- |
... | ... |
@@ -34,11 +34,8 @@ if BUILD_EXTERNAL_LLVM |
34 | 34 |
# we know this will be built with GNU make, so its safe to use GNU make specific |
35 | 35 |
# $(shell ...) |
36 | 36 |
#LLVM_DEPS=$(shell $(LLVM_CONFIG) --libfiles jit nativecodegen) |
37 |
-libclamavcxx_la_CXXFLAGS = $(AM_CPPFLAGS) @LLVMCONFIG_CXXFLAGS@ -fexceptions -DLLVM28 -DLLVM29 @JSON_CPPFLAGS@ |
|
38 |
-if BUILD_LLVM3 |
|
39 |
-libclamavcxx_la_CXXFLAGS += -DLLVM30 |
|
40 |
-endif |
|
41 |
-libclamavcxx_la_LDFLAGS = @LLVMCONFIG_LDFLAGS@ @LLVMCONFIG_LIBS@ @JSON_LDFLAGS@ |
|
37 |
+libclamavcxx_la_CXXFLAGS = $(AM_CPPFLAGS) @LLVMCONFIG_CXXFLAGS@ -fexceptions -DLLVM_VERSION=${LLVM_VERSION} @JSON_CPPFLAGS@ |
|
38 |
+libclamavcxx_la_LDFLAGS = @LLVMCONFIG_LDFLAGS@ @LLVMCONFIG_LIBS@ @LLVMCONFIG_LDFLAGS@ @JSON_LDFLAGS@ |
|
42 | 39 |
libclamavcxx_la_DEPENDENCIES = @LLVMCONFIG_LIBFILES@ @JSON_LIBS@ |
43 | 40 |
noinst_LTLIBRARIES = libclamavcxx.la |
44 | 41 |
libclamavcxx_la_SOURCES += PointerTracking.cpp |
... | ... |
@@ -51,7 +48,7 @@ noinst_LTLIBRARIES = libclamavcxx.la libllvmsystem.la\ |
51 | 51 |
libclamavcxx_la_LIBADD=libllvmjit.la |
52 | 52 |
libclamavcxx_la_DEPENDENCIES=libllvmjit.la libllvmcodegen.la libllvmsystem.la |
53 | 53 |
libclamavcxx_la_LDFLAGS=-no-undefined |
54 |
-libclamavcxx_la_CXXFLAGS = $(LLVM_CXXFLAGS) @JSON_CPPFLAGS@ |
|
54 |
+libclamavcxx_la_CXXFLAGS = $(LLVM_CXXFLAGS) -DLLVM_VERSION=${LLVM_VERSION} @JSON_CPPFLAGS@ |
|
55 | 55 |
|
56 | 56 |
|
57 | 57 |
if BUILD_X86 |
... | ... |
@@ -95,17 +95,16 @@ POST_UNINSTALL = : |
95 | 95 |
build_triplet = @build@ |
96 | 96 |
host_triplet = @host@ |
97 | 97 |
target_triplet = @target@ |
98 |
-@BUILD_EXTERNAL_LLVM_TRUE@@BUILD_LLVM3_TRUE@am__append_1 = -DLLVM30 |
|
99 |
-@BUILD_EXTERNAL_LLVM_TRUE@am__append_2 = PointerTracking.cpp \ |
|
98 |
+@BUILD_EXTERNAL_LLVM_TRUE@am__append_1 = PointerTracking.cpp \ |
|
100 | 99 |
@BUILD_EXTERNAL_LLVM_TRUE@ PointerTracking.h |
101 |
-@BUILD_EXTERNAL_LLVM_FALSE@am__append_3 = $(LLVM_INCLUDES) $(LLVM_DEFS) |
|
100 |
+@BUILD_EXTERNAL_LLVM_FALSE@am__append_2 = $(LLVM_INCLUDES) $(LLVM_DEFS) |
|
101 |
+@BUILD_EXTERNAL_LLVM_FALSE@@BUILD_X86_TRUE@am__append_3 = libllvmx86codegen.la |
|
102 | 102 |
@BUILD_EXTERNAL_LLVM_FALSE@@BUILD_X86_TRUE@am__append_4 = libllvmx86codegen.la |
103 | 103 |
@BUILD_EXTERNAL_LLVM_FALSE@@BUILD_X86_TRUE@am__append_5 = libllvmx86codegen.la |
104 |
-@BUILD_EXTERNAL_LLVM_FALSE@@BUILD_X86_TRUE@am__append_6 = libllvmx86codegen.la |
|
104 |
+@BUILD_EXTERNAL_LLVM_FALSE@@BUILD_PPC_TRUE@am__append_6 = libllvmpowerpccodegen.la |
|
105 | 105 |
@BUILD_EXTERNAL_LLVM_FALSE@@BUILD_PPC_TRUE@am__append_7 = libllvmpowerpccodegen.la |
106 | 106 |
@BUILD_EXTERNAL_LLVM_FALSE@@BUILD_PPC_TRUE@am__append_8 = libllvmpowerpccodegen.la |
107 |
-@BUILD_EXTERNAL_LLVM_FALSE@@BUILD_PPC_TRUE@am__append_9 = libllvmpowerpccodegen.la |
|
108 |
-@BUILD_EXTERNAL_LLVM_FALSE@@MAINTAINER_MODE_TRUE@am__append_10 = $(TBLGENFILES) |
|
107 |
+@BUILD_EXTERNAL_LLVM_FALSE@@MAINTAINER_MODE_TRUE@am__append_9 = $(TBLGENFILES) |
|
109 | 108 |
@BUILD_EXTERNAL_LLVM_FALSE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = tblgen$(EXEEXT) |
110 | 109 |
subdir = . |
111 | 110 |
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ |
... | ... |
@@ -969,6 +968,7 @@ LLVMCONFIG_CXXFLAGS = @LLVMCONFIG_CXXFLAGS@ |
969 | 969 |
LLVMCONFIG_LDFLAGS = @LLVMCONFIG_LDFLAGS@ |
970 | 970 |
LLVMCONFIG_LIBFILES = @LLVMCONFIG_LIBFILES@ |
971 | 971 |
LLVMCONFIG_LIBS = @LLVMCONFIG_LIBS@ |
972 |
+LLVM_VERSION = @LLVM_VERSION@ |
|
972 | 973 |
LN_S = @LN_S@ |
973 | 974 |
LTLIBOBJS = @LTLIBOBJS@ |
974 | 975 |
MAINT = @MAINT@ |
... | ... |
@@ -1063,38 +1063,35 @@ LLVM_INCLUDES = -I$(top_srcdir)/llvm/include -I$(top_builddir)/llvm/include |
1063 | 1063 |
# TODO: HP-UX should have -D_REENTRANT -D_HPUX_SOURCE |
1064 | 1064 |
LLVM_DEFS = -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D_DEBUG -D_GNU_SOURCE |
1065 | 1065 |
AM_CPPFLAGS = -I$(top_srcdir)/../.. -I$(top_srcdir)/.. \ |
1066 |
- -I$(top_builddir)/../../ $(am__append_3) |
|
1066 |
+ -I$(top_builddir)/../../ $(am__append_2) |
|
1067 | 1067 |
AM_CXXFLAGS = $(LLVM_CXXFLAGS) -fno-exceptions |
1068 | 1068 |
ACLOCAL_AMFLAGS = -I m4 |
1069 | 1069 |
libclamavcxx_la_SOURCES = bytecode2llvm.cpp ClamBCRTChecks.cpp \ |
1070 | 1070 |
ClamBCModule.h ClamBCDiagnostics.h detect.cpp llvm30_compat.h \ |
1071 |
- $(am__append_2) |
|
1072 |
-@BUILD_EXTERNAL_LLVM_FALSE@libclamavcxx_la_CXXFLAGS = $(LLVM_CXXFLAGS) @JSON_CPPFLAGS@ |
|
1071 |
+ $(am__append_1) |
|
1072 |
+@BUILD_EXTERNAL_LLVM_FALSE@libclamavcxx_la_CXXFLAGS = $(LLVM_CXXFLAGS) -DLLVM_VERSION=${LLVM_VERSION} @JSON_CPPFLAGS@ |
|
1073 | 1073 |
#$(LLVM_CONFIG): build-llvm |
1074 | 1074 |
# we know this will be built with GNU make, so its safe to use GNU make specific |
1075 | 1075 |
# $(shell ...) |
1076 | 1076 |
#LLVM_DEPS=$(shell $(LLVM_CONFIG) --libfiles jit nativecodegen) |
1077 |
-@BUILD_EXTERNAL_LLVM_TRUE@libclamavcxx_la_CXXFLAGS = $(AM_CPPFLAGS) \ |
|
1078 |
-@BUILD_EXTERNAL_LLVM_TRUE@ @LLVMCONFIG_CXXFLAGS@ -fexceptions \ |
|
1079 |
-@BUILD_EXTERNAL_LLVM_TRUE@ -DLLVM28 -DLLVM29 @JSON_CPPFLAGS@ \ |
|
1080 |
-@BUILD_EXTERNAL_LLVM_TRUE@ $(am__append_1) |
|
1077 |
+@BUILD_EXTERNAL_LLVM_TRUE@libclamavcxx_la_CXXFLAGS = $(AM_CPPFLAGS) @LLVMCONFIG_CXXFLAGS@ -fexceptions -DLLVM_VERSION=${LLVM_VERSION} @JSON_CPPFLAGS@ |
|
1081 | 1078 |
@BUILD_EXTERNAL_LLVM_FALSE@libclamavcxx_la_LDFLAGS = -no-undefined |
1082 |
-@BUILD_EXTERNAL_LLVM_TRUE@libclamavcxx_la_LDFLAGS = @LLVMCONFIG_LDFLAGS@ @LLVMCONFIG_LIBS@ @JSON_LDFLAGS@ |
|
1079 |
+@BUILD_EXTERNAL_LLVM_TRUE@libclamavcxx_la_LDFLAGS = @LLVMCONFIG_LDFLAGS@ @LLVMCONFIG_LIBS@ @LLVMCONFIG_LDFLAGS@ @JSON_LDFLAGS@ |
|
1083 | 1080 |
@BUILD_EXTERNAL_LLVM_FALSE@libclamavcxx_la_DEPENDENCIES = \ |
1084 | 1081 |
@BUILD_EXTERNAL_LLVM_FALSE@ libllvmjit.la libllvmcodegen.la \ |
1085 |
-@BUILD_EXTERNAL_LLVM_FALSE@ libllvmsystem.la $(am__append_5) \ |
|
1086 |
-@BUILD_EXTERNAL_LLVM_FALSE@ $(am__append_8) |
|
1082 |
+@BUILD_EXTERNAL_LLVM_FALSE@ libllvmsystem.la $(am__append_4) \ |
|
1083 |
+@BUILD_EXTERNAL_LLVM_FALSE@ $(am__append_7) |
|
1087 | 1084 |
@BUILD_EXTERNAL_LLVM_TRUE@libclamavcxx_la_DEPENDENCIES = \ |
1088 | 1085 |
@BUILD_EXTERNAL_LLVM_TRUE@ @LLVMCONFIG_LIBFILES@ @JSON_LIBS@ \ |
1089 |
-@BUILD_EXTERNAL_LLVM_TRUE@ $(am__append_5) $(am__append_8) |
|
1086 |
+@BUILD_EXTERNAL_LLVM_TRUE@ $(am__append_4) $(am__append_7) |
|
1090 | 1087 |
@BUILD_EXTERNAL_LLVM_FALSE@noinst_LTLIBRARIES = libclamavcxx.la \ |
1091 | 1088 |
@BUILD_EXTERNAL_LLVM_FALSE@ libllvmsystem.la libllvmcodegen.la \ |
1092 |
-@BUILD_EXTERNAL_LLVM_FALSE@ libllvmjit.la $(am__append_6) \ |
|
1093 |
-@BUILD_EXTERNAL_LLVM_FALSE@ $(am__append_9) |
|
1089 |
+@BUILD_EXTERNAL_LLVM_FALSE@ libllvmjit.la $(am__append_5) \ |
|
1090 |
+@BUILD_EXTERNAL_LLVM_FALSE@ $(am__append_8) |
|
1094 | 1091 |
@BUILD_EXTERNAL_LLVM_TRUE@noinst_LTLIBRARIES = libclamavcxx.la \ |
1095 |
-@BUILD_EXTERNAL_LLVM_TRUE@ $(am__append_6) $(am__append_9) |
|
1092 |
+@BUILD_EXTERNAL_LLVM_TRUE@ $(am__append_5) $(am__append_8) |
|
1096 | 1093 |
@BUILD_EXTERNAL_LLVM_FALSE@libclamavcxx_la_LIBADD = libllvmjit.la \ |
1097 |
-@BUILD_EXTERNAL_LLVM_FALSE@ $(am__append_4) $(am__append_7) \ |
|
1094 |
+@BUILD_EXTERNAL_LLVM_FALSE@ $(am__append_3) $(am__append_6) \ |
|
1098 | 1095 |
@BUILD_EXTERNAL_LLVM_FALSE@ libllvmcodegen.la libllvmsystem.la |
1099 | 1096 |
@BUILD_EXTERNAL_LLVM_FALSE@LLVM_CXXFLAGS = -Woverloaded-virtual -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings |
1100 | 1097 |
@BUILD_EXTERNAL_LLVM_FALSE@unittest_CXXFLAGS = @NO_VARIADIC_MACROS@ @NO_MISSING_FIELD_INITIALIZERS@ -DGTEST_HAS_TR1_TUPLE=0 |
... | ... |
@@ -1106,7 +1103,7 @@ libclamavcxx_la_SOURCES = bytecode2llvm.cpp ClamBCRTChecks.cpp \ |
1106 | 1106 |
|
1107 | 1107 |
# Rule to rerun LLVM's configure if it changed, before building anything else |
1108 | 1108 |
# LLVM |
1109 |
-@BUILD_EXTERNAL_LLVM_FALSE@BUILT_SOURCES = $(am__append_10) \ |
|
1109 |
+@BUILD_EXTERNAL_LLVM_FALSE@BUILT_SOURCES = $(am__append_9) \ |
|
1110 | 1110 |
@BUILD_EXTERNAL_LLVM_FALSE@ llvm/config.status |
1111 | 1111 |
@BUILD_EXTERNAL_LLVM_FALSE@EXTRA_DIST = $(top_srcdir)/llvm llvmcheck.sh $(TBLGENFILES) |
1112 | 1112 |
@BUILD_EXTERNAL_LLVM_FALSE@libllvmsystem_la_LDFLAGS = @THREAD_LIBS@ |
... | ... |
@@ -23,14 +23,39 @@ |
23 | 23 |
#include "PointerTracking.h" |
24 | 24 |
#include "llvm/Analysis/ScalarEvolution.h" |
25 | 25 |
#include "llvm/Analysis/ScalarEvolutionExpressions.h" |
26 |
-#include "llvm/Constants.h" |
|
27 |
-#include "llvm/Module.h" |
|
28 |
-#include "llvm/Value.h" |
|
29 | 26 |
#include "llvm/Support/CallSite.h" |
30 | 27 |
#include "llvm/Support/InstIterator.h" |
31 | 28 |
#include "llvm/Support/raw_ostream.h" |
29 |
+#include "llvm/Target/TargetLibraryInfo.h" |
|
30 |
+ |
|
31 |
+#if LLVM_VERSION < 32 |
|
32 | 32 |
#include "llvm/Target/TargetData.h" |
33 |
+#elif LLVM_VERSION < 33 |
|
34 |
+#include "llvm/DataLayout.h" |
|
35 |
+#else |
|
36 |
+#include "llvm/IR/DataLayout.h" |
|
37 |
+#endif |
|
38 |
+ |
|
39 |
+#if LLVM_VERSION < 33 |
|
40 |
+#include "llvm/Constants.h" |
|
41 |
+#include "llvm/Module.h" |
|
42 |
+#include "llvm/Value.h" |
|
43 |
+#else |
|
44 |
+#include "llvm/IR/Constants.h" |
|
45 |
+#include "llvm/IR/Module.h" |
|
46 |
+#include "llvm/IR/Value.h" |
|
47 |
+#endif |
|
48 |
+ |
|
33 | 49 |
using namespace llvm; |
50 |
+#if LLVM_VERSION < 29 |
|
51 |
+/* function is succeeded in later LLVM with LLVM correspoding standalone */ |
|
52 |
+static Value *GetUnderlyingObject(Value *P, TargetData *TD) |
|
53 |
+{ |
|
54 |
+ return P->getUnderlyingObject(); |
|
55 |
+} |
|
56 |
+#endif |
|
57 |
+ |
|
58 |
+#if LLVM_VERSION >= 30 |
|
34 | 59 |
namespace llvm { |
35 | 60 |
void initializePointerTrackingPass(llvm::PassRegistry&); |
36 | 61 |
}; |
... | ... |
@@ -42,17 +67,24 @@ INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) |
42 | 42 |
INITIALIZE_PASS_DEPENDENCY(DominatorTree) |
43 | 43 |
INITIALIZE_PASS_END(PointerTracking, "pointertracking", |
44 | 44 |
"Track pointer bounds", false, true) |
45 |
+#endif |
|
45 | 46 |
|
46 | 47 |
char PointerTracking::ID = 0; |
47 | 48 |
PointerTracking::PointerTracking() : FunctionPass(ID) { |
49 |
+#if LLVM_VERSION >= 30 |
|
48 | 50 |
initializePointerTrackingPass(*PassRegistry::getPassRegistry()); |
51 |
+#endif |
|
49 | 52 |
} |
50 | 53 |
|
51 | 54 |
bool PointerTracking::runOnFunction(Function &F) { |
52 | 55 |
predCache.clear(); |
53 | 56 |
assert(analyzing.empty()); |
54 | 57 |
FF = &F; |
58 |
+#if LLVM_VERSION < 32 |
|
55 | 59 |
TD = getAnalysisIfAvailable<TargetData>(); |
60 |
+#else |
|
61 |
+ TD = getAnalysisIfAvailable<DataLayout>(); |
|
62 |
+#endif |
|
56 | 63 |
SE = &getAnalysis<ScalarEvolution>(); |
57 | 64 |
LI = &getAnalysis<LoopInfo>(); |
58 | 65 |
DT = &getAnalysis<DominatorTree>(); |
... | ... |
@@ -119,9 +151,17 @@ const SCEV *PointerTracking::computeAllocationCount(Value *P, |
119 | 119 |
return SE->getSCEV(arraySize); |
120 | 120 |
} |
121 | 121 |
|
122 |
+#if LLVM_VERSION < 32 |
|
122 | 123 |
if (CallInst *CI = extractMallocCall(V)) { |
123 | 124 |
Value *arraySize = getMallocArraySize(CI, TD); |
124 | 125 |
constType* AllocTy = getMallocAllocatedType(CI); |
126 |
+#else |
|
127 |
+ TargetLibraryInfo* TLI = new TargetLibraryInfo(); |
|
128 |
+ |
|
129 |
+ if (CallInst *CI = extractMallocCall(V, TLI)) { |
|
130 |
+ Value *arraySize = getMallocArraySize(CI, TD, TLI); |
|
131 |
+ constType* AllocTy = getMallocAllocatedType(CI, TLI); |
|
132 |
+#endif |
|
125 | 133 |
if (!AllocTy || !arraySize) return SE->getCouldNotCompute(); |
126 | 134 |
Ty = AllocTy; |
127 | 135 |
// arraySize elements of type Ty. |
... | ... |
@@ -171,11 +211,21 @@ Value *PointerTracking::computeAllocationCountValue(Value *P, constType *&Ty) co |
171 | 171 |
return AI->getArraySize(); |
172 | 172 |
} |
173 | 173 |
|
174 |
+#if LLVM_VERSION < 32 |
|
174 | 175 |
if (CallInst *CI = extractMallocCall(V)) { |
175 | 176 |
Ty = getMallocAllocatedType(CI); |
176 | 177 |
if (!Ty) |
177 | 178 |
return 0; |
178 | 179 |
Value *arraySize = getMallocArraySize(CI, TD); |
180 |
+#else |
|
181 |
+ TargetLibraryInfo* TLI = new TargetLibraryInfo(); |
|
182 |
+ |
|
183 |
+ if (CallInst *CI = extractMallocCall(V, TLI)) { |
|
184 |
+ Ty = getMallocAllocatedType(CI, TLI); |
|
185 |
+ if (!Ty) |
|
186 |
+ return 0; |
|
187 |
+ Value *arraySize = getMallocArraySize(CI, TD, TLI); |
|
188 |
+#endif |
|
179 | 189 |
if (!arraySize) { |
180 | 190 |
Ty = Type::getInt8Ty(P->getContext()); |
181 | 191 |
return CI->getArgOperand(0); |
... | ... |
@@ -29,18 +29,27 @@ |
29 | 29 |
|
30 | 30 |
#include "llvm/ADT/SmallPtrSet.h" |
31 | 31 |
#include "llvm/Analysis/Dominators.h" |
32 |
-#include "llvm/Instructions.h" |
|
33 | 32 |
#include "llvm/Pass.h" |
34 | 33 |
#include "llvm/Support/PredIteratorCache.h" |
35 | 34 |
#include "llvm30_compat.h" |
36 | 35 |
|
36 |
+#if LLVM_VERSION < 33 |
|
37 |
+#include "llvm/Instructions.h" |
|
38 |
+#else |
|
39 |
+#include "llvm/IR/Instructions.h" |
|
40 |
+#endif |
|
41 |
+ |
|
37 | 42 |
namespace llvm { |
38 | 43 |
class DominatorTree; |
39 | 44 |
class ScalarEvolution; |
40 | 45 |
class SCEV; |
41 | 46 |
class Loop; |
42 | 47 |
class LoopInfo; |
48 |
+#if LLVM_VERSION < 32 |
|
43 | 49 |
class TargetData; |
50 |
+#else |
|
51 |
+ class DataLayout; |
|
52 |
+#endif |
|
44 | 53 |
|
45 | 54 |
// Result from solver, assuming pointer is not NULL, |
46 | 55 |
// and it is not a use-after-free situation. |
... | ... |
@@ -50,7 +59,7 @@ namespace llvm { |
50 | 50 |
Unknown // it can sometimes be true, sometimes false, or it is undecided |
51 | 51 |
}; |
52 | 52 |
|
53 |
-#ifdef LLVM30 |
|
53 |
+#if LLVM_VERSION >= 30 |
|
54 | 54 |
void initializePointerTrackingPass(PassRegistry&); |
55 | 55 |
#endif |
56 | 56 |
|
... | ... |
@@ -106,7 +115,11 @@ namespace llvm { |
106 | 106 |
Value *computeAllocationCountValue(Value *P, constType *&Ty) const; |
107 | 107 |
private: |
108 | 108 |
Function *FF; |
109 |
+#if LLVM_VERSION < 32 |
|
109 | 110 |
TargetData *TD; |
111 |
+#else |
|
112 |
+ DataLayout *TD; |
|
113 |
+#endif |
|
110 | 114 |
ScalarEvolution *SE; |
111 | 115 |
LoopInfo *LI; |
112 | 116 |
DominatorTree *DT; |
... | ... |
@@ -24,10 +24,16 @@ |
24 | 24 |
#ifndef _WIN32 |
25 | 25 |
#include <sys/time.h> |
26 | 26 |
#endif |
27 |
+#include <cstdlib> |
|
28 |
+#include <csetjmp> |
|
29 |
+#include <new> |
|
30 |
+#include <cerrno> |
|
31 |
+#include <string> |
|
27 | 32 |
|
28 | 33 |
#include "ClamBCModule.h" |
29 | 34 |
#include "ClamBCDiagnostics.h" |
30 |
-#include "llvm/Analysis/DebugInfo.h" |
|
35 |
+#include "llvm30_compat.h" |
|
36 |
+ |
|
31 | 37 |
#include "llvm/ADT/DenseMap.h" |
32 | 38 |
#include "llvm/ADT/BitVector.h" |
33 | 39 |
#include "llvm/ADT/PostOrderIterator.h" |
... | ... |
@@ -40,15 +46,9 @@ |
40 | 40 |
#include "llvm/Analysis/ScalarEvolution.h" |
41 | 41 |
#include "llvm/Analysis/Verifier.h" |
42 | 42 |
#include "llvm/AutoUpgrade.h" |
43 |
-#include "llvm/CallingConv.h" |
|
44 |
-#include "llvm/DerivedTypes.h" |
|
45 |
-#include "llvm/Function.h" |
|
46 | 43 |
#include "llvm/ExecutionEngine/ExecutionEngine.h" |
47 | 44 |
#include "llvm/ExecutionEngine/JIT.h" |
48 | 45 |
#include "llvm/ExecutionEngine/JITEventListener.h" |
49 |
-#include "llvm/LLVMContext.h" |
|
50 |
-#include "llvm/Intrinsics.h" |
|
51 |
-#include "llvm/Module.h" |
|
52 | 46 |
#include "llvm/PassManager.h" |
53 | 47 |
#include "llvm/Support/Compiler.h" |
54 | 48 |
#include "llvm/Support/Debug.h" |
... | ... |
@@ -58,10 +58,18 @@ |
58 | 58 |
#include "llvm/Support/MemoryBuffer.h" |
59 | 59 |
#include "llvm/Support/raw_ostream.h" |
60 | 60 |
#include "llvm/Support/SourceMgr.h" |
61 |
-#include "llvm/Support/IRBuilder.h" |
|
62 | 61 |
#include "llvm/Support/PrettyStackTrace.h" |
63 | 62 |
|
64 |
-#ifdef LLVM29 |
|
63 |
+#if LLVM_VERSION < 29 |
|
64 |
+#include "llvm/System/DataTypes.h" |
|
65 |
+#include "llvm/System/Host.h" |
|
66 |
+#include "llvm/System/Memory.h" |
|
67 |
+#include "llvm/System/Mutex.h" |
|
68 |
+#include "llvm/System/Signals.h" |
|
69 |
+#include "llvm/System/Threading.h" |
|
70 |
+#include "llvm/System/ThreadLocal.h" |
|
71 |
+#else |
|
72 |
+#include "llvm/PassRegistry.h" |
|
65 | 73 |
#include "llvm/Support/DataTypes.h" |
66 | 74 |
#include "llvm/Support/FileSystem.h" |
67 | 75 |
#include "llvm/Support/Host.h" |
... | ... |
@@ -70,16 +78,12 @@ |
70 | 70 |
#include "llvm/Support/Signals.h" |
71 | 71 |
#include "llvm/Support/Threading.h" |
72 | 72 |
#include "llvm/Support/ThreadLocal.h" |
73 |
+#endif |
|
74 |
+ |
|
75 |
+#if LLVM_VERSION < 33 |
|
73 | 76 |
#include "llvm/IntrinsicInst.h" |
74 |
-#include "llvm/PassRegistry.h" |
|
75 | 77 |
#else |
76 |
-#include "llvm/System/DataTypes.h" |
|
77 |
-#include "llvm/System/Host.h" |
|
78 |
-#include "llvm/System/Memory.h" |
|
79 |
-#include "llvm/System/Mutex.h" |
|
80 |
-#include "llvm/System/Signals.h" |
|
81 |
-#include "llvm/System/Threading.h" |
|
82 |
-#include "llvm/System/ThreadLocal.h" |
|
78 |
+#include "llvm/IR/IntrinsicInst.h" |
|
83 | 79 |
#endif |
84 | 80 |
|
85 | 81 |
#include "llvm/Support/Timer.h" |
... | ... |
@@ -88,31 +92,73 @@ extern "C" { |
88 | 88 |
void LLVMInitializeX86AsmPrinter(); |
89 | 89 |
void LLVMInitializePowerPCAsmPrinter(); |
90 | 90 |
} |
91 |
-#include "llvm30_compat.h" |
|
92 |
-#ifdef LLVM30 |
|
93 |
-#include "llvm/Support/TargetSelect.h" |
|
94 |
-#else |
|
91 |
+ |
|
92 |
+#if LLVM_VERSION < 30 |
|
95 | 93 |
#include "llvm/Target/TargetSelect.h" |
94 |
+#else |
|
95 |
+#include "llvm/Support/TargetSelect.h" |
|
96 | 96 |
#endif |
97 |
-#include "llvm/Target/TargetData.h" |
|
97 |
+ |
|
98 | 98 |
#include "llvm/Target/TargetOptions.h" |
99 | 99 |
#include "llvm/Support/TargetFolder.h" |
100 | 100 |
#include "llvm/Transforms/Scalar.h" |
101 | 101 |
#include "llvm/Transforms/IPO.h" |
102 | 102 |
#include "llvm/Transforms/Utils/BasicBlockUtils.h" |
103 |
-#include <cstdlib> |
|
104 |
-#include <csetjmp> |
|
105 |
-#include <new> |
|
106 |
-#include <cerrno> |
|
107 |
-#include <string> |
|
103 |
+ |
|
104 |
+#if LLVM_VERSION < 32 |
|
105 |
+#include "llvm/Analysis/DebugInfo.h" |
|
106 |
+#else |
|
107 |
+#include "llvm/DebugInfo.h" |
|
108 |
+#endif |
|
109 |
+ |
|
110 |
+#if LLVM_VERSION < 32 |
|
111 |
+#include "llvm/Support/IRBuilder.h" |
|
112 |
+#include "llvm/Target/TargetData.h" |
|
113 |
+#elif LLVM_VERSION < 33 |
|
114 |
+#include "llvm/IRBuilder.h" |
|
115 |
+#include "llvm/DataLayout.h" |
|
116 |
+#else |
|
117 |
+#include "llvm/IR/IRBuilder.h" |
|
118 |
+#include "llvm/IR/DataLayout.h" |
|
119 |
+#endif |
|
120 |
+ |
|
121 |
+#if LLVM_VERSION < 33 |
|
122 |
+#include "llvm/CallingConv.h" |
|
123 |
+#include "llvm/DerivedTypes.h" |
|
124 |
+#include "llvm/Function.h" |
|
125 |
+#include "llvm/LLVMContext.h" |
|
126 |
+#include "llvm/Intrinsics.h" |
|
127 |
+#include "llvm/Module.h" |
|
128 |
+#else |
|
129 |
+#include "llvm/IR/CallingConv.h" |
|
130 |
+#include "llvm/IR/DerivedTypes.h" |
|
131 |
+#include "llvm/IR/Function.h" |
|
132 |
+#include "llvm/IR/LLVMContext.h" |
|
133 |
+#include "llvm/IR/Intrinsics.h" |
|
134 |
+#include "llvm/IR/Module.h" |
|
135 |
+#endif |
|
136 |
+ |
|
137 |
+#if LLVM_VERSION < 34 |
|
138 |
+#include "llvm/Support/CFG.h" |
|
139 |
+#else |
|
140 |
+#include "llvm/Analysis/CFG.h" |
|
141 |
+#endif |
|
108 | 142 |
|
109 | 143 |
//#define TIMING |
110 | 144 |
#undef TIMING |
111 | 145 |
|
112 | 146 |
#include "llvm/Config/config.h" |
147 |
+#ifdef ENABLE_THREADS |
|
113 | 148 |
#if !ENABLE_THREADS |
114 | 149 |
#error "Thread support was explicitly disabled. Cannot continue" |
115 | 150 |
#endif |
151 |
+#endif |
|
152 |
+ |
|
153 |
+#ifdef LLVM_ENABLE_THREADS |
|
154 |
+#if !LLVM_ENABLE_THREADS |
|
155 |
+#error "Thread support was explicitly disabled. Cannot continue" |
|
156 |
+#endif |
|
157 |
+#endif |
|
116 | 158 |
|
117 | 159 |
#ifdef _GLIBCXX_PARALLEL |
118 | 160 |
#error "libstdc++ parallel mode is not supported for ClamAV. Please remove -D_GLIBCXX_PARALLEL from CXXFLAGS!" |
... | ... |
@@ -128,6 +174,9 @@ void LLVMInitializePowerPCAsmPrinter(); |
128 | 128 |
#include "clamav-config.h" |
129 | 129 |
#endif |
130 | 130 |
|
131 |
+#include <openssl/ssl.h> |
|
132 |
+#include <openssl/err.h> |
|
133 |
+ |
|
131 | 134 |
#include "dconf.h" |
132 | 135 |
#include "clamav.h" |
133 | 136 |
#include "clambc.h" |
... | ... |
@@ -152,18 +201,14 @@ struct cli_bcengine { |
152 | 152 |
}; |
153 | 153 |
|
154 | 154 |
extern "C" uint8_t cli_debug_flag; |
155 |
-#ifdef LLVM29 |
|
155 |
+#if LLVM_VERSION >= 29 |
|
156 | 156 |
namespace llvm { |
157 | 157 |
void initializeRuntimeLimitsPass(PassRegistry&); |
158 | 158 |
}; |
159 | 159 |
#endif |
160 | 160 |
namespace { |
161 | 161 |
|
162 |
-#ifndef LLVM28 |
|
163 |
-#define LLVM28 |
|
164 |
-#endif |
|
165 |
- |
|
166 |
-#ifdef LLVM28 |
|
162 |
+#if LLVM_VERSION >= 28 |
|
167 | 163 |
#define llvm_report_error(x) report_fatal_error(x) |
168 | 164 |
#define llvm_install_error_handler(x) install_fatal_error_handler(x) |
169 | 165 |
#define DwarfExceptionHandling JITExceptionHandling |
... | ... |
@@ -173,7 +218,7 @@ namespace { |
173 | 173 |
#define DEFINEPASS(passname) passname() : FunctionPass(&ID) |
174 | 174 |
#endif |
175 | 175 |
|
176 |
-#ifdef LLVM29 |
|
176 |
+#if LLVM_VERSION >= 29 |
|
177 | 177 |
#define NORETURN LLVM_ATTRIBUTE_NORETURN |
178 | 178 |
#endif |
179 | 179 |
|
... | ... |
@@ -267,7 +312,11 @@ static void NORETURN jit_ssp_handler(void) |
267 | 267 |
jit_exception_handler(); |
268 | 268 |
} |
269 | 269 |
|
270 |
+#if LLVM_VERSION < 33 |
|
270 | 271 |
void llvm_error_handler(void *user_data, const std::string &reason) |
272 |
+#else |
|
273 |
+void llvm_error_handler(void *user_data, const std::string &reason, bool gen_crash_diag = true) |
|
274 |
+#endif |
|
271 | 275 |
{ |
272 | 276 |
// Output it to stderr, it might exceed the 1k/4k limit of cli_errmsg |
273 | 277 |
cli_errmsg("[Bytecode JIT]: [LLVM error] %s\n", reason.c_str()); |
... | ... |
@@ -376,7 +425,11 @@ public: |
376 | 376 |
if (!cli_debug_flag) |
377 | 377 |
return; |
378 | 378 |
cli_dbgmsg_internal("[Bytecode JIT]: emitted function %s of %ld bytes at %p\n", |
379 |
+#if LLVM_VERSION < 31 |
|
379 | 380 |
F.getNameStr().c_str(), (long)Size, Code); |
381 |
+#else |
|
382 |
+ F.getName().str().c_str(), (long)Size, Code); |
|
383 |
+#endif |
|
380 | 384 |
} |
381 | 385 |
}; |
382 | 386 |
|
... | ... |
@@ -409,10 +462,10 @@ public: |
409 | 409 |
|
410 | 410 |
class LLVMTypeMapper { |
411 | 411 |
private: |
412 |
-#ifdef LLVM30 |
|
413 |
- std::vector<Type*> TypeMap; |
|
414 |
-#else |
|
412 |
+#if LLVM_VERSION < 30 |
|
415 | 413 |
std::vector<PATypeHolder> TypeMap; |
414 |
+#else |
|
415 |
+ std::vector<Type*> TypeMap; |
|
416 | 416 |
#endif |
417 | 417 |
LLVMContext &Context; |
418 | 418 |
unsigned numTypes; |
... | ... |
@@ -447,22 +500,22 @@ public: |
447 | 447 |
// invalidated, so we must use a TypeHolder to an Opaque type as a |
448 | 448 |
// start. |
449 | 449 |
for (unsigned i=0;i<count;i++) { |
450 |
-#ifdef LLVM30 |
|
451 |
- TypeMap.push_back(0); |
|
452 |
-#else |
|
450 |
+#if LLVM_VERSION < 30 |
|
453 | 451 |
TypeMap.push_back(OpaqueType::get(Context)); |
452 |
+#else |
|
453 |
+ TypeMap.push_back(0); |
|
454 | 454 |
#endif |
455 | 455 |
} |
456 | 456 |
for (unsigned i=0;i<count;i++) { |
457 | 457 |
const struct cli_bc_type *type = &types[i]; |
458 | 458 |
|
459 | 459 |
constType *Ty = buildType(type, types, Hidden, 0); |
460 |
-#ifdef LLVM30 |
|
461 |
- TypeMap[i] = Ty; |
|
462 |
-#else |
|
460 |
+#if LLVM_VERSION < 30 |
|
463 | 461 |
// Make the opaque type a concrete type, doing recursive type |
464 | 462 |
// unification if needed. |
465 | 463 |
cast<OpaqueType>(TypeMap[i].get())->refineAbstractTypeTo(Ty); |
464 |
+#else |
|
465 |
+ TypeMap[i] = Ty; |
|
466 | 466 |
#endif |
467 | 467 |
} |
468 | 468 |
} |
... | ... |
@@ -514,7 +567,9 @@ public: |
514 | 514 |
return getStatic(ty); |
515 | 515 |
ty -= 69; |
516 | 516 |
assert(ty < numTypes && "TypeID out of range"); |
517 |
-#ifdef LLVM30 |
|
517 |
+#if LLVM_VERSION < 30 |
|
518 |
+ return TypeMap[ty].get(); |
|
519 |
+#else |
|
518 | 520 |
Type *Ty = TypeMap[ty]; |
519 | 521 |
if (Ty) |
520 | 522 |
return Ty; |
... | ... |
@@ -522,8 +577,6 @@ public: |
522 | 522 |
Ty = buildType(&types[ty], types, Hidden, 1); |
523 | 523 |
TypeMap[ty] = Ty; |
524 | 524 |
return Ty; |
525 |
-#else |
|
526 |
- return TypeMap[ty].get(); |
|
527 | 525 |
#endif |
528 | 526 |
} |
529 | 527 |
}; |
... | ... |
@@ -582,7 +635,7 @@ class RuntimeLimits : public FunctionPass { |
582 | 582 |
public: |
583 | 583 |
static char ID; |
584 | 584 |
DEFINEPASS(RuntimeLimits) { |
585 |
-#ifdef LLVM29 |
|
585 |
+#if LLVM_VERSION >= 29 |
|
586 | 586 |
PassRegistry &Registry = *PassRegistry::getPassRegistry(); |
587 | 587 |
initializeRuntimeLimitsPass(Registry); |
588 | 588 |
#endif |
... | ... |
@@ -669,13 +722,18 @@ public: |
669 | 669 |
CallInst* AbrtC = CallInst::Create(func_abort, "", AbrtBB); |
670 | 670 |
AbrtC->setCallingConv(CallingConv::C); |
671 | 671 |
AbrtC->setTailCall(true); |
672 |
+#if LLVM_VERSION < 32 |
|
672 | 673 |
AbrtC->setDoesNotReturn(true); |
673 | 674 |
AbrtC->setDoesNotThrow(true); |
675 |
+#else |
|
676 |
+ AbrtC->setDoesNotReturn(); |
|
677 |
+ AbrtC->setDoesNotThrow(); |
|
678 |
+#endif |
|
674 | 679 |
new UnreachableInst(F.getContext(), AbrtBB); |
675 | 680 |
IRBuilder<false> Builder(F.getContext()); |
676 | 681 |
|
677 | 682 |
Value *Flag = F.arg_begin(); |
678 |
-#ifndef LLVM30 |
|
683 |
+#if LLVM_VERSION < 30 |
|
679 | 684 |
Function *LSBarrier = Intrinsic::getDeclaration(F.getParent(), |
680 | 685 |
Intrinsic::memory_barrier); |
681 | 686 |
Value *MBArgs[] = { |
... | ... |
@@ -695,11 +753,11 @@ public: |
695 | 695 |
E=needsTimeoutCheck.end(); I != E; ++I) { |
696 | 696 |
BasicBlock *BB = *I; |
697 | 697 |
Builder.SetInsertPoint(BB, BB->getTerminator()); |
698 |
-#ifdef LLVM30 |
|
699 |
- Builder.CreateFence(Release); |
|
700 |
-#else |
|
698 |
+#if LLVM_VERSION < 30 |
|
701 | 699 |
// store-load barrier: will be a no-op on x86 but not other arches |
702 | 700 |
Builder.CreateCall(LSBarrier, ARRAYREF(Value*, MBArgs, MBArgs+5)); |
701 |
+#else |
|
702 |
+ Builder.CreateFence(Release); |
|
703 | 703 |
#endif |
704 | 704 |
// Load Flag that tells us we timed out (first byte in bc_ctx) |
705 | 705 |
Value *Cond = Builder.CreateLoad(Flag, true); |
... | ... |
@@ -1020,7 +1078,11 @@ public: |
1020 | 1020 |
: bc(bc), M(M), Context(M->getContext()), EE(EE), |
1021 | 1021 |
PM(PM),PMUnsigned(PMUnsigned), TypeMap(), apiFuncs(apiFuncs),apiMap(apiMap), |
1022 | 1022 |
compiledFunctions(cFuncs), BytecodeID("bc"+Twine(bc->id)), |
1023 |
+#if LLVM_VERSION < 32 |
|
1023 | 1024 |
Folder(EE->getTargetData()), Builder(Context, Folder), Values(), CF(CF) { |
1025 |
+#else |
|
1026 |
+ Folder(EE->getDataLayout()), Builder(Context, Folder), Values(), CF(CF) { |
|
1027 |
+#endif |
|
1024 | 1028 |
|
1025 | 1029 |
for (unsigned i=0;i<cli_apicall_maxglobal - _FIRST_GLOBAL;i++) { |
1026 | 1030 |
unsigned id = cli_globals[i].globalid; |
... | ... |
@@ -1030,7 +1092,7 @@ public: |
1030 | 1030 |
numArgs = 0; |
1031 | 1031 |
} |
1032 | 1032 |
|
1033 |
-#ifndef LLVM30 |
|
1033 |
+#if LLVM_VERSION < 30 |
|
1034 | 1034 |
template <typename InputIterator> |
1035 | 1035 |
#endif |
1036 | 1036 |
Value* createGEP(Value *Base, constType *ETy, ARRAYREFPARAM(Value*,InputIterator Start,InputIterator End,ARef)) { |
... | ... |
@@ -1047,10 +1109,10 @@ public: |
1047 | 1047 |
ostr << " base: " << *Base << ";"; |
1048 | 1048 |
Base->getType()->print(ostr); |
1049 | 1049 |
ostr << "\n indices: "; |
1050 |
-#ifdef LLVM30 |
|
1051 |
- for (ArrayRef<Value*>::iterator I=ARef.begin(); I != ARef.end(); I++) { |
|
1052 |
-#else |
|
1050 |
+#if LLVM_VERSION < 30 |
|
1053 | 1051 |
for (InputIterator I=Start; I != End; I++) { |
1052 |
+#else |
|
1053 |
+ for (ArrayRef<Value*>::iterator I=ARef.begin(); I != ARef.end(); I++) { |
|
1054 | 1054 |
#endif |
1055 | 1055 |
ostr << **I << ", "; |
1056 | 1056 |
} |
... | ... |
@@ -1064,7 +1126,7 @@ public: |
1064 | 1064 |
return Builder.CreateGEP(Base,ARRAYREFP(Start,End,ARef)); |
1065 | 1065 |
} |
1066 | 1066 |
|
1067 |
-#ifndef LLVM30 |
|
1067 |
+#if LLVM_VERSION < 30 |
|
1068 | 1068 |
template <typename InputIterator> |
1069 | 1069 |
#endif |
1070 | 1070 |
bool createGEP(unsigned dest, Value *Base, ARRAYREFPARAM(Value*,InputIterator Start,InputIterator End,ARef)) { |
... | ... |
@@ -1121,7 +1183,7 @@ public: |
1121 | 1121 |
// Have an alloca -> some instruction uses its address otherwise |
1122 | 1122 |
// mem2reg would have converted it to an SSA register. |
1123 | 1123 |
// Enable stack protector for this function. |
1124 |
-#ifndef LLVM29 |
|
1124 |
+#if LLVM_VERSION < 29 |
|
1125 | 1125 |
// LLVM 2.9 has broken SSP, it does a 'mov 0x28, $rax', which tries |
1126 | 1126 |
// to read from the address 0x28 and crashes |
1127 | 1127 |
F->addFnAttr(Attribute::StackProtectReq); |
... | ... |
@@ -1130,7 +1192,7 @@ public: |
1130 | 1130 |
// always add stackprotect attribute (bb #2239), so we know this |
1131 | 1131 |
// function was verified. If there is no alloca it won't actually add |
1132 | 1132 |
// stack protector in emitted code so this won't slow down the app. |
1133 |
-#ifndef LLVM29 |
|
1133 |
+#if LLVM_VERSION < 29 |
|
1134 | 1134 |
F->addFnAttr(Attribute::StackProtect); |
1135 | 1135 |
#endif |
1136 | 1136 |
} |
... | ... |
@@ -1151,7 +1213,11 @@ public: |
1151 | 1151 |
} |
1152 | 1152 |
V = SI->getOperand(0); |
1153 | 1153 |
} |
1154 |
+#if LLVM_VERSION < 32 |
|
1154 | 1155 |
if (EE->getTargetData()->getPointerSize() == 8) { |
1156 |
+#else |
|
1157 |
+ if (EE->getDataLayout()->getPointerSize() == 8) { |
|
1158 |
+#endif |
|
1155 | 1159 |
// eliminate useless trunc, GEP can take i64 too |
1156 | 1160 |
if (TruncInst *I = dyn_cast<TruncInst>(V)) { |
1157 | 1161 |
Value *Src = I->getOperand(0); |
... | ... |
@@ -1226,7 +1292,12 @@ public: |
1226 | 1226 |
Functions[j]->setLinkage(GlobalValue::InternalLinkage); |
1227 | 1227 |
#ifdef C_LINUX |
1228 | 1228 |
/* bb #2270, this should really be fixed either by LLVM or GCC.*/ |
1229 |
+#if LLVM_VERSION < 32 |
|
1229 | 1230 |
Functions[j]->addFnAttr(Attribute::constructStackAlignmentFromInt(16)); |
1231 |
+#else |
|
1232 |
+ // TODO: How does this translate? |
|
1233 |
+// Functions[j]->addFnAttr(Attribute::StackAlignment); |
|
1234 |
+#endif |
|
1230 | 1235 |
#endif |
1231 | 1236 |
} |
1232 | 1237 |
constType *I32Ty = Type::getInt32Ty(Context); |
... | ... |
@@ -1503,6 +1574,9 @@ public: |
1503 | 1503 |
case OP_BC_ICMP_SLT: |
1504 | 1504 |
Store(inst->dest, Builder.CreateICmpSLT(Op0, Op1)); |
1505 | 1505 |
break; |
1506 |
+ case OP_BC_ICMP_SLE: |
|
1507 |
+ Store(inst->dest, Builder.CreateICmpSLE(Op0, Op1)); |
|
1508 |
+ break; |
|
1506 | 1509 |
case OP_BC_SELECT: |
1507 | 1510 |
Store(inst->dest, Builder.CreateSelect(Op0, Op1, Op2)); |
1508 | 1511 |
break; |
... | ... |
@@ -1527,7 +1601,11 @@ public: |
1527 | 1527 |
} |
1528 | 1528 |
CallInst *CI = Builder.CreateCall(DestF, ARRAYREF(Value*, args.begin(), args.end())); |
1529 | 1529 |
CI->setCallingConv(CallingConv::Fast); |
1530 |
+#if LLVM_VERSION < 32 |
|
1530 | 1531 |
CI->setDoesNotThrow(true); |
1532 |
+#else |
|
1533 |
+ CI->setDoesNotThrow(); |
|
1534 |
+#endif |
|
1531 | 1535 |
if (CI->getType()->getTypeID() != Type::VoidTyID) |
1532 | 1536 |
Store(inst->dest, CI); |
1533 | 1537 |
break; |
... | ... |
@@ -1548,7 +1626,11 @@ public: |
1548 | 1548 |
args.push_back(convertOperand(func, DestF->getFunctionType()->getParamType(a+1), op)); |
1549 | 1549 |
} |
1550 | 1550 |
CallInst *CI = Builder.CreateCall(DestF, ARRAYREFVECTOR(Value*, args)); |
1551 |
+#if LLVM_VERSION < 32 |
|
1551 | 1552 |
CI->setDoesNotThrow(true); |
1553 |
+#else |
|
1554 |
+ CI->setDoesNotThrow(); |
|
1555 |
+#endif |
|
1552 | 1556 |
Store(inst->dest, CI); |
1553 | 1557 |
} |
1554 | 1558 |
break; |
... | ... |
@@ -1619,15 +1701,16 @@ public: |
1619 | 1619 |
Value *Dst = convertOperand(func, inst, inst->u.three[0]); |
1620 | 1620 |
Dst = Builder.CreatePointerCast(Dst, PointerType::getUnqual(Type::getInt8Ty(Context))); |
1621 | 1621 |
Value *Val = convertOperand(func, Type::getInt8Ty(Context), inst->u.three[1]); |
1622 |
- Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]); |
|
1623 |
-#ifdef LLVM30 |
|
1622 |
+ //Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]); |
|
1623 |
+ Value *Len = convertOperand(func, Type::getInt64Ty(Context), inst->u.three[2]); |
|
1624 |
+#if LLVM_VERSION < 30 |
|
1625 |
+ CallInst *c = Builder.CreateCall4(CF->FMemset, Dst, Val, Len, |
|
1626 |
+ ConstantInt::get(Type::getInt32Ty(Context), 1)); |
|
1627 |
+#else |
|
1624 | 1628 |
CallInst *c = Builder.CreateCall5(CF->FMemset, Dst, Val, Len, |
1625 | 1629 |
ConstantInt::get(Type::getInt32Ty(Context), 1), |
1626 | 1630 |
ConstantInt::get(Type::getInt1Ty(Context), 0) |
1627 | 1631 |
); |
1628 |
-#else |
|
1629 |
- CallInst *c = Builder.CreateCall4(CF->FMemset, Dst, Val, Len, |
|
1630 |
- ConstantInt::get(Type::getInt32Ty(Context), 1)); |
|
1631 | 1632 |
#endif |
1632 | 1633 |
c->setTailCall(true); |
1633 | 1634 |
c->setDoesNotThrow(); |
... | ... |
@@ -1640,15 +1723,16 @@ public: |
1640 | 1640 |
Dst = Builder.CreatePointerCast(Dst, PointerType::getUnqual(Type::getInt8Ty(Context))); |
1641 | 1641 |
Value *Src = convertOperand(func, inst, inst->u.three[1]); |
1642 | 1642 |
Src = Builder.CreatePointerCast(Src, PointerType::getUnqual(Type::getInt8Ty(Context))); |
1643 |
- Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]); |
|
1644 |
-#ifdef LLVM30 |
|
1643 |
+ //Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]); |
|
1644 |
+ Value *Len = convertOperand(func, Type::getInt64Ty(Context), inst->u.three[2]); |
|
1645 |
+#if LLVM_VERSION < 30 |
|
1646 |
+ CallInst *c = Builder.CreateCall4(CF->FMemcpy, Dst, Src, Len, |
|
1647 |
+ ConstantInt::get(Type::getInt32Ty(Context), 1)); |
|
1648 |
+#else |
|
1645 | 1649 |
CallInst *c = Builder.CreateCall5(CF->FMemcpy, Dst, Src, Len, |
1646 | 1650 |
ConstantInt::get(Type::getInt32Ty(Context), 1), |
1647 | 1651 |
ConstantInt::get(Type::getInt1Ty(Context), 0) |
1648 | 1652 |
); |
1649 |
-#else |
|
1650 |
- CallInst *c = Builder.CreateCall4(CF->FMemcpy, Dst, Src, Len, |
|
1651 |
- ConstantInt::get(Type::getInt32Ty(Context), 1)); |
|
1652 | 1653 |
#endif |
1653 | 1654 |
c->setTailCall(true); |
1654 | 1655 |
c->setDoesNotThrow(); |
... | ... |
@@ -1661,14 +1745,15 @@ public: |
1661 | 1661 |
Dst = Builder.CreatePointerCast(Dst, PointerType::getUnqual(Type::getInt8Ty(Context))); |
1662 | 1662 |
Value *Src = convertOperand(func, inst, inst->u.three[1]); |
1663 | 1663 |
Src = Builder.CreatePointerCast(Src, PointerType::getUnqual(Type::getInt8Ty(Context))); |
1664 |
- Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]); |
|
1665 |
-#ifdef LLVM30 |
|
1664 |
+ //Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]); |
|
1665 |
+ Value *Len = convertOperand(func, Type::getInt64Ty(Context), inst->u.three[2]); |
|
1666 |
+#if LLVM_VERSION < 30 |
|
1667 |
+ CallInst *c = Builder.CreateCall4(CF->FMemmove, Dst, Src, Len, |
|
1668 |
+ ConstantInt::get(Type::getInt32Ty(Context), 1)); |
|
1669 |
+#else |
|
1666 | 1670 |
CallInst *c = Builder.CreateCall5(CF->FMemmove, Dst, Src, Len, |
1667 | 1671 |
ConstantInt::get(Type::getInt32Ty(Context), 1), |
1668 | 1672 |
ConstantInt::get(Type::getInt1Ty(Context), 0)); |
1669 |
-#else |
|
1670 |
- CallInst *c = Builder.CreateCall4(CF->FMemmove, Dst, Src, Len, |
|
1671 |
- ConstantInt::get(Type::getInt32Ty(Context), 1)); |
|
1672 | 1673 |
#endif |
1673 | 1674 |
c->setTailCall(true); |
1674 | 1675 |
c->setDoesNotThrow(); |
... | ... |
@@ -1681,7 +1766,11 @@ public: |
1681 | 1681 |
Dst = Builder.CreatePointerCast(Dst, PointerType::getUnqual(Type::getInt8Ty(Context))); |
1682 | 1682 |
Value *Src = convertOperand(func, inst, inst->u.three[1]); |
1683 | 1683 |
Src = Builder.CreatePointerCast(Src, PointerType::getUnqual(Type::getInt8Ty(Context))); |
1684 |
+#if LLVM_VERSION < 32 |
|
1684 | 1685 |
Value *Len = convertOperand(func, EE->getTargetData()->getIntPtrType(Context), inst->u.three[2]); |
1686 |
+#else |
|
1687 |
+ Value *Len = convertOperand(func, EE->getDataLayout()->getIntPtrType(Context), inst->u.three[2]); |
|
1688 |
+#endif |
|
1685 | 1689 |
CallInst *c = Builder.CreateCall3(CF->FRealmemcmp, Dst, Src, Len); |
1686 | 1690 |
c->setTailCall(true); |
1687 | 1691 |
c->setDoesNotThrow(); |
... | ... |
@@ -1706,7 +1795,11 @@ public: |
1706 | 1706 |
{ |
1707 | 1707 |
CallInst *C = Builder.CreateCall(CF->FBSwap16, convertOperand(func, inst, inst->u.unaryop)); |
1708 | 1708 |
C->setTailCall(true); |
1709 |
+#if LLVM_VERSION < 32 |
|
1709 | 1710 |
C->setDoesNotThrow(true); |
1711 |
+#else |
|
1712 |
+ C->setDoesNotThrow(); |
|
1713 |
+#endif |
|
1710 | 1714 |
Store(inst->dest, C); |
1711 | 1715 |
break; |
1712 | 1716 |
} |
... | ... |
@@ -1714,7 +1807,11 @@ public: |
1714 | 1714 |
{ |
1715 | 1715 |
CallInst *C = Builder.CreateCall(CF->FBSwap32, convertOperand(func, inst, inst->u.unaryop)); |
1716 | 1716 |
C->setTailCall(true); |
1717 |
+#if LLVM_VERSION < 32 |
|
1717 | 1718 |
C->setDoesNotThrow(true); |
1719 |
+#else |
|
1720 |
+ C->setDoesNotThrow(); |
|
1721 |
+#endif |
|
1718 | 1722 |
Store(inst->dest, C); |
1719 | 1723 |
break; |
1720 | 1724 |
} |
... | ... |
@@ -1722,7 +1819,11 @@ public: |
1722 | 1722 |
{ |
1723 | 1723 |
CallInst *C = Builder.CreateCall(CF->FBSwap64, convertOperand(func, inst, inst->u.unaryop)); |
1724 | 1724 |
C->setTailCall(true); |
1725 |
+#if LLVM_VERSION < 32 |
|
1725 | 1726 |
C->setDoesNotThrow(true); |
1727 |
+#else |
|
1728 |
+ C->setDoesNotThrow(); |
|
1729 |
+#endif |
|
1726 | 1730 |
Store(inst->dest, C); |
1727 | 1731 |
break; |
1728 | 1732 |
} |
... | ... |
@@ -1827,7 +1928,11 @@ public: |
1827 | 1827 |
// entrypoint can only be C, emit wrapper |
1828 | 1828 |
Function *F = Function::Create(Functions[0]->getFunctionType(), |
1829 | 1829 |
Function::ExternalLinkage, |
1830 |
+#if LLVM_VERSION < 33 |
|
1830 | 1831 |
Functions[0]->getName()+"_wrap", M); |
1832 |
+#else |
|
1833 |
+ Functions[0]->getName().str()+"_wrap", M); |
|
1834 |
+#endif |
|
1831 | 1835 |
F->setDoesNotThrow(); |
1832 | 1836 |
BasicBlock *BB = BasicBlock::Create(Context, "", F); |
1833 | 1837 |
std::vector<Value*> Args; |
... | ... |
@@ -1886,8 +1991,11 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M |
1886 | 1886 |
"clamjit.fail", M); |
1887 | 1887 |
CF->FHandler->setDoesNotReturn(); |
1888 | 1888 |
CF->FHandler->setDoesNotThrow(); |
1889 |
+#if LLVM_VERSION == 32 |
|
1890 |
+ CF->FHandler->addFnAttr(Attributes::NoInline); |
|
1891 |
+#else |
|
1889 | 1892 |
CF->FHandler->addFnAttr(Attribute::NoInline); |
1890 |
- |
|
1893 |
+#endif |
|
1891 | 1894 |
EE->addGlobalMapping(CF->FHandler, (void*)(intptr_t)jit_exception_handler); |
1892 | 1895 |
EE->InstallLazyFunctionCreator(noUnknownFunctions); |
1893 | 1896 |
EE->getPointerToFunction(CF->FHandler); |
... | ... |
@@ -1895,52 +2003,72 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M |
1895 | 1895 |
std::vector<constType*> args; |
1896 | 1896 |
args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context))); |
1897 | 1897 |
args.push_back(Type::getInt8Ty(Context)); |
1898 |
+ //args.push_back(Type::getInt32Ty(Context)); |
|
1899 |
+ args.push_back(Type::getInt64Ty(Context)); |
|
1898 | 1900 |
args.push_back(Type::getInt32Ty(Context)); |
1899 |
- args.push_back(Type::getInt32Ty(Context)); |
|
1900 |
-#ifdef LLVM30 |
|
1901 |
+#if LLVM_VERSION >= 30 |
|
1901 | 1902 |
args.push_back(Type::getInt1Ty(Context)); |
1902 | 1903 |
#endif |
1903 | 1904 |
FunctionType* FuncTy_3 = FunctionType::get(Type::getVoidTy(Context), |
1904 | 1905 |
args, false); |
1905 | 1906 |
CF->FMemset = Function::Create(FuncTy_3, GlobalValue::ExternalLinkage, |
1906 |
-#ifdef LLVM30 |
|
1907 |
- "llvm.memset.p0i8.i32", |
|
1907 |
+#if LLVM_VERSION < 30 |
|
1908 |
+ //"llvm.memset.i32", |
|
1909 |
+ "llvm.memset.i64", |
|
1908 | 1910 |
#else |
1909 |
- "llvm.memset.i32", |
|
1911 |
+ //"llvm.memset.p0i8.i32", |
|
1912 |
+ "llvm.memset.p0i8.i64", |
|
1910 | 1913 |
#endif |
1911 |
- M); |
|
1914 |
+ M); |
|
1912 | 1915 |
CF->FMemset->setDoesNotThrow(); |
1916 |
+#if LLVM_VERSION < 32 |
|
1913 | 1917 |
CF->FMemset->setDoesNotCapture(1, true); |
1918 |
+#else |
|
1919 |
+ CF->FMemset->setDoesNotCapture(1); |
|
1920 |
+#endif |
|
1914 | 1921 |
|
1915 | 1922 |
args.clear(); |
1916 | 1923 |
args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context))); |
1917 | 1924 |
args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context))); |
1925 |
+ //args.push_back(Type::getInt32Ty(Context)); |
|
1926 |
+ args.push_back(Type::getInt64Ty(Context)); |
|
1918 | 1927 |
args.push_back(Type::getInt32Ty(Context)); |
1919 |
- args.push_back(Type::getInt32Ty(Context)); |
|
1920 |
-#ifdef LLVM30 |
|
1928 |
+#if LLVM_VERSION >= 30 |
|
1921 | 1929 |
args.push_back(Type::getInt1Ty(Context)); |
1922 | 1930 |
#endif |
1923 | 1931 |
FunctionType* FuncTy_4 = FunctionType::get(Type::getVoidTy(Context), |
1924 | 1932 |
args, false); |
1925 | 1933 |
CF->FMemmove = Function::Create(FuncTy_4, GlobalValue::ExternalLinkage, |
1926 |
-#ifdef LLVM30 |
|
1927 |
- "llvm.memmove.p0i8.i32", |
|
1934 |
+#if LLVM_VERSION < 30 |
|
1935 |
+ //"llvm.memmove.i32", |
|
1936 |
+ "llvm.memcpy.i64", |
|
1928 | 1937 |
#else |
1929 |
- "llvm.memmove.i32", |
|
1938 |
+ //"llvm.memmove.p0i8.i32", |
|
1939 |
+ "llvm.memmove.p0i8.i64", |
|
1930 | 1940 |
#endif |
1931 |
- M); |
|
1941 |
+ M); |
|
1932 | 1942 |
CF->FMemmove->setDoesNotThrow(); |
1943 |
+#if LLVM_VERSION < 32 |
|
1933 | 1944 |
CF->FMemmove->setDoesNotCapture(1, true); |
1945 |
+#else |
|
1946 |
+ CF->FMemmove->setDoesNotCapture(1); |
|
1947 |
+#endif |
|
1934 | 1948 |
|
1935 | 1949 |
CF->FMemcpy = Function::Create(FuncTy_4, GlobalValue::ExternalLinkage, |
1936 |
-#ifdef LLVM30 |
|
1937 |
- "llvm.memcpy.p0i8.p0i8.i32", |
|
1950 |
+#if LLVM_VERSION < 30 |
|
1951 |
+ //"llvm.memcpy.i32", |
|
1952 |
+ "llvm.memcpy.i64", |
|
1938 | 1953 |
#else |
1939 |
- "llvm.memcpy.i32", |
|
1954 |
+ //"llvm.memcpy.p0i8.p0i8.i32", |
|
1955 |
+ "llvm.memcpy.p0i8.p0i8.i64", |
|
1940 | 1956 |
#endif |
1941 |
- M); |
|
1957 |
+ M); |
|
1942 | 1958 |
CF->FMemcpy->setDoesNotThrow(); |
1959 |
+#if LLVM_VERSION < 32 |
|
1943 | 1960 |
CF->FMemcpy->setDoesNotCapture(1, true); |
1961 |
+#else |
|
1962 |
+ CF->FMemcpy->setDoesNotCapture(1); |
|
1963 |
+#endif |
|
1944 | 1964 |
|
1945 | 1965 |
args.clear(); |
1946 | 1966 |
args.push_back(Type::getInt16Ty(Context)); |
... | ... |
@@ -1980,7 +2108,11 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M |
1980 | 1980 |
args.clear(); |
1981 | 1981 |
args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context))); |
1982 | 1982 |
args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context))); |
1983 |
+#if LLVM_VERSION < 32 |
|
1983 | 1984 |
args.push_back(EE->getTargetData()->getIntPtrType(Context)); |
1985 |
+#else |
|
1986 |
+ args.push_back(EE->getDataLayout()->getIntPtrType(Context)); |
|
1987 |
+#endif |
|
1984 | 1988 |
FuncTy_5 = FunctionType::get(Type::getInt32Ty(Context), |
1985 | 1989 |
args, false); |
1986 | 1990 |
CF->FRealmemcmp = Function::Create(FuncTy_5, GlobalValue::ExternalLinkage, "memcmp", M); |
... | ... |
@@ -1989,7 +2121,7 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M |
1989 | 1989 |
} |
1990 | 1990 |
|
1991 | 1991 |
} |
1992 |
-#ifdef LLVM29 |
|
1992 |
+#if LLVM_VERSION >= 29 |
|
1993 | 1993 |
INITIALIZE_PASS_BEGIN(RuntimeLimits, "rl", "Runtime Limits", false, false) |
1994 | 1994 |
INITIALIZE_PASS_DEPENDENCY(LoopInfo) |
1995 | 1995 |
INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) |
... | ... |
@@ -2203,16 +2335,23 @@ static void setGuard(unsigned char* guardbuf) |
2203 | 2203 |
char salt[48]; |
2204 | 2204 |
memcpy(salt, name_salt, 16); |
2205 | 2205 |
for(unsigned i = 16; i < 48; i++) |
2206 |
- salt[i] = cli_rndnum(255); |
|
2206 |
+ salt[i] = cli_rndnum(255); |
|
2207 | 2207 |
|
2208 | 2208 |
cl_hash_data("md5", salt, 48, guardbuf, NULL); |
2209 | 2209 |
} |
2210 |
- |
|
2210 |
+#if LLVM_VERSION < 32 |
|
2211 | 2211 |
static void addFPasses(FunctionPassManager &FPM, bool trusted, const TargetData *TD) |
2212 |
+#else |
|
2213 |
+static void addFPasses(FunctionPassManager &FPM, bool trusted, const DataLayout *TD) |
|
2214 |
+#endif |
|
2212 | 2215 |
{ |
2213 | 2216 |
// Set up the optimizer pipeline. Start with registering info about how |
2214 | 2217 |
// the target lays out data structures. |
2218 |
+#if LLVM_VERSION < 32 |
|
2215 | 2219 |
FPM.add(new TargetData(*TD)); |
2220 |
+#else |
|
2221 |
+ FPM.add(new DataLayout(*TD)); |
|
2222 |
+#endif |
|
2216 | 2223 |
// Promote allocas to registers. |
2217 | 2224 |
FPM.add(createPromoteMemoryToRegisterPass()); |
2218 | 2225 |
FPM.add(new BrSimplifier()); |
... | ... |
@@ -2234,6 +2373,24 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs) |
2234 | 2234 |
// Create the JIT. |
2235 | 2235 |
std::string ErrorMsg; |
2236 | 2236 |
EngineBuilder builder(M); |
2237 |
+ |
|
2238 |
+#if LLVM_VERSION >= 31 |
|
2239 |
+ TargetOptions Options; |
|
2240 |
+#ifdef CL_DEBUG |
|
2241 |
+ //disable this for now, it leaks |
|
2242 |
+ Options.JITEmitDebugInfo = false; |
|
2243 |
+// Options.JITEmitDebugInfo = true; |
|
2244 |
+#else |
|
2245 |
+ Options.JITEmitDebugInfo = false; |
|
2246 |
+#endif |
|
2247 |
+#if LLVM_VERSION < 34 |
|
2248 |
+ Options.DwarfExceptionHandling = false; |
|
2249 |
+#else |
|
2250 |
+ // TODO: How to do this now? |
|
2251 |
+#endif |
|
2252 |
+ builder.setTargetOptions(Options); |
|
2253 |
+#endif |
|
2254 |
+ |
|
2237 | 2255 |
builder.setErrorStr(&ErrorMsg); |
2238 | 2256 |
builder.setEngineKind(EngineKind::JIT); |
2239 | 2257 |
builder.setOptLevel(CodeGenOpt::Default); |
... | ... |
@@ -2258,11 +2415,24 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs) |
2258 | 2258 |
addFunctionProtos(&CF, EE, M); |
2259 | 2259 |
|
2260 | 2260 |
FunctionPassManager OurFPM(M), OurFPMUnsigned(M); |
2261 |
+#if LLVM_VERSION < 32 |
|
2261 | 2262 |
M->setDataLayout(EE->getTargetData()->getStringRepresentation()); |
2263 |
+#else |
|
2264 |
+ M->setDataLayout(EE->getDataLayout()->getStringRepresentation()); |
|
2265 |
+#endif |
|
2266 |
+#if LLVM_VERSION < 31 |
|
2262 | 2267 |
M->setTargetTriple(sys::getHostTriple()); |
2263 |
- |
|
2268 |
+#else |
|
2269 |
+ M->setTargetTriple(sys::getDefaultTargetTriple()); |
|
2270 |
+#endif |
|
2271 |
+#if LLVM_VERSION < 32 |
|
2264 | 2272 |
addFPasses(OurFPM, true, EE->getTargetData()); |
2265 | 2273 |
addFPasses(OurFPMUnsigned, false, EE->getTargetData()); |
2274 |
+#else |
|
2275 |
+ addFPasses(OurFPM, true, EE->getDataLayout()); |
|
2276 |
+ addFPasses(OurFPMUnsigned, false, EE->getDataLayout()); |
|
2277 |
+#endif |
|
2278 |
+ |
|
2266 | 2279 |
|
2267 | 2280 |
//TODO: create a wrapper that calls pthread_getspecific |
2268 | 2281 |
unsigned maxh = cli_globals[0].offset + sizeof(struct cli_bc_hooks); |
... | ... |
@@ -2369,7 +2539,11 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs) |
2369 | 2369 |
} |
2370 | 2370 |
} |
2371 | 2371 |
PassManager PM; |
2372 |
+#if LLVM_VERSION < 32 |
|
2372 | 2373 |
PM.add(new TargetData(*EE->getTargetData())); |
2374 |
+#else |
|
2375 |
+ PM.add(new DataLayout(*EE->getDataLayout())); |
|
2376 |
+#endif |
|
2373 | 2377 |
// TODO: only run this on the untrusted bytecodes, not all of them... |
2374 | 2378 |
if (has_untrusted) |
2375 | 2379 |
PM.add(createClamBCRTChecks()); |
... | ... |
@@ -2434,11 +2608,17 @@ int bytecode_init(void) |
2434 | 2434 |
llvm_install_error_handler(llvm_error_handler); |
2435 | 2435 |
#ifdef CL_DEBUG |
2436 | 2436 |
sys::PrintStackTraceOnErrorSignal(); |
2437 |
+#if LLVM_VERSION >= 34 |
|
2438 |
+ llvm::EnablePrettyStackTrace(); |
|
2439 |
+#endif |
|
2437 | 2440 |
#else |
2441 |
+#if LLVM_VERSION < 34 |
|
2438 | 2442 |
llvm::DisablePrettyStackTrace = true; |
2439 | 2443 |
#endif |
2444 |
+#endif |
|
2440 | 2445 |
atexit(do_shutdown); |
2441 | 2446 |
|
2447 |
+#if LLVM_VERSION < 31 |
|
2442 | 2448 |
#ifdef CL_DEBUG |
2443 | 2449 |
//disable this for now, it leaks |
2444 | 2450 |
llvm::JITEmitDebugInfo = false; |
... | ... |
@@ -2447,6 +2627,7 @@ int bytecode_init(void) |
2447 | 2447 |
llvm::JITEmitDebugInfo = false; |
2448 | 2448 |
#endif |
2449 | 2449 |
llvm::DwarfExceptionHandling = false; |
2450 |
+#endif |
|
2450 | 2451 |
llvm_start_multithreaded(); |
2451 | 2452 |
|
2452 | 2453 |
// If we have a native target, initialize it to ensure it is linked in and |
... | ... |
@@ -2527,7 +2708,9 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) |
2527 | 2527 |
if (I == LinePrinter.files.end()) { |
2528 | 2528 |
lines = new linesTy; |
2529 | 2529 |
std::string ErrorMessage; |
2530 |
-#ifdef LLVM29 |
|
2530 |
+#if LLVM_VERSION < 29 |
|
2531 |
+ lines->buffer = MemoryBuffer::getFile(path, &ErrorMessage); |
|
2532 |
+#else |
|
2531 | 2533 |
OwningPtr<MemoryBuffer> File; |
2532 | 2534 |
error_code ec = MemoryBuffer::getFile(path, File); |
2533 | 2535 |
if (ec) { |
... | ... |
@@ -2535,8 +2718,6 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) |
2535 | 2535 |
lines->buffer = 0; |
2536 | 2536 |
} else |
2537 | 2537 |
lines->buffer = File.take(); |
2538 |
-#else |
|
2539 |
- lines->buffer = MemoryBuffer::getFile(path, &ErrorMessage); |
|
2540 | 2538 |
#endif |
2541 | 2539 |
if (!lines->buffer) { |
2542 | 2540 |
errs() << "Unable to open file '" << path << "'\n"; |
... | ... |
@@ -2570,7 +2751,7 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) |
2570 | 2570 |
} |
2571 | 2571 |
assert(ctx->line < lines->linev.size()); |
2572 | 2572 |
|
2573 |
-#ifndef LLVM28 |
|
2573 |
+#if LLVM_VERSION < 28 |
|
2574 | 2574 |
int line = (int)ctx->line ? (int)ctx->line : -1; |
2575 | 2575 |
int col = (int)ctx->col ? (int)ctx->col : -1; |
2576 | 2576 |
//TODO: print this ourselves, instead of using SMDiagnostic |
... | ... |
@@ -2605,14 +2786,18 @@ namespace ClamBCModule { |
2605 | 2605 |
void stop(const char *msg, llvm::Function* F, llvm::Instruction* I) |
2606 | 2606 |
{ |
2607 | 2607 |
if (F && F->hasName()) { |
2608 |
+#if LLVM_VERSION < 31 |
|
2608 | 2609 |
cli_warnmsg("[Bytecode JIT] in function %s: %s", F->getNameStr().c_str(), msg); |
2610 |
+#else |
|
2611 |
+ cli_warnmsg("[Bytecode JIT] in function %s: %s", F->getName().str().c_str(), msg); |
|
2612 |
+#endif |
|
2609 | 2613 |
} else { |
2610 | 2614 |
cli_warnmsg("[Bytecode JIT] %s", msg); |
2611 | 2615 |
} |
2612 | 2616 |
} |
2613 | 2617 |
} |
2614 | 2618 |
|
2615 |
-#ifdef LLVM29 |
|
2619 |
+#if LLVM_VERSION >= 29 |
|
2616 | 2620 |
static Value *findDbgGlobalDeclare(GlobalVariable *V) { |
2617 | 2621 |
const Module *M = V->getParent(); |
2618 | 2622 |
NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.gv"); |
... | ... |
@@ -2672,7 +2857,12 @@ static const DbgDeclareInst *findDbgDeclare(const Value *V) { |
2672 | 2672 |
static bool getLocationInfo(const Value *V, std::string &DisplayName, |
2673 | 2673 |
std::string &Type, unsigned &LineNo, |
2674 | 2674 |
std::string &File, std::string &Dir) { |
2675 |
+#if LLVM_VERSION < 33 |
|
2675 | 2676 |
DICompileUnit Unit; |
2677 |
+#else |
|
2678 |
+ StringRef G; |
|
2679 |
+ StringRef H; |
|
2680 |
+#endif |
|
2676 | 2681 |
DIType TypeD; |
2677 | 2682 |
|
2678 | 2683 |
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(const_cast<Value*>(V))) { |
... | ... |
@@ -2684,7 +2874,12 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName, |
2684 | 2684 |
if (!D.empty()) |
2685 | 2685 |
DisplayName = D; |
2686 | 2686 |
LineNo = Var.getLineNumber(); |
2687 |
+#if LLVM_VERSION < 33 |
|
2687 | 2688 |
Unit = Var.getCompileUnit(); |
2689 |
+#else |
|
2690 |
+ G = Var.getFilename(); |
|
2691 |
+ H = Var.getDirectory(); |
|
2692 |
+#endif |
|
2688 | 2693 |
TypeD = Var.getType(); |
2689 | 2694 |
} else if (Function *F = dyn_cast<Function>(const_cast<Value*>(V))){ |
2690 | 2695 |
Value *DIF = findDbgSubprogramDeclare(F); |
... | ... |
@@ -2695,7 +2890,12 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName, |
2695 | 2695 |
if (!D.empty()) |
2696 | 2696 |
DisplayName = D; |
2697 | 2697 |
LineNo = Var.getLineNumber(); |
2698 |
+#if LLVM_VERSION < 33 |
|
2698 | 2699 |
Unit = Var.getCompileUnit(); |
2700 |
+#else |
|
2701 |
+ G = Var.getFilename(); |
|
2702 |
+ H = Var.getDirectory(); |
|
2703 |
+#endif |
|
2699 | 2704 |
TypeD = Var.getType(); |
2700 | 2705 |
} else { |
2701 | 2706 |
const DbgDeclareInst *DDI = findDbgDeclare(V); |
... | ... |
@@ -2706,19 +2906,27 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName, |
2706 | 2706 |
if (!D.empty()) |
2707 | 2707 |
DisplayName = D; |
2708 | 2708 |
LineNo = Var.getLineNumber(); |
2709 |
+#if LLVM_VERSION < 33 |
|
2709 | 2710 |
Unit = Var.getCompileUnit(); |
2711 |
+#else |
|
2712 |
+ // getFilename and getDirectory are not defined |
|
2713 |
+ G = StringRef(); |
|
2714 |
+ H = StringRef(); |
|
2715 |
+#endif |
|
2710 | 2716 |
TypeD = Var.getType(); |
2711 | 2717 |
} |
2712 | 2718 |
|
2713 | 2719 |
StringRef T = TypeD.getName(); |
2714 | 2720 |
if (!T.empty()) |
2715 | 2721 |
Type = T; |
2716 |
- StringRef F = Unit.getFilename(); |
|
2717 |
- if (!F.empty()) |
|
2718 |
- File = F; |
|
2719 |
- StringRef D = Unit.getDirectory(); |
|
2720 |
- if (!D.empty()) |
|
2721 |
- Dir = D; |
|
2722 |
+#if LLVM_VERSION < 33 |
|
2723 |
+ StringRef G = Unit.getFilename(); |
|
2724 |
+ StringRef H = Unit.getDirectory(); |
|
2725 |
+#endif |
|
2726 |
+ if (!G.empty()) |
|
2727 |
+ File = G; |
|
2728 |
+ if (!H.empty()) |
|
2729 |
+ Dir = H; |
|
2722 | 2730 |
return true; |
2723 | 2731 |
} |
2724 | 2732 |
#endif |
... | ... |
@@ -640,8 +640,6 @@ LIBOBJS |
640 | 640 |
JSON_CPPFLAGS |
641 | 641 |
JSON_LDFLAGS |
642 | 642 |
JSON_LIBS |
643 |
-BUILD_LLVM3_FALSE |
|
644 |
-BUILD_LLVM3_TRUE |
|
645 | 643 |
BUILD_EXTERNAL_LLVM_FALSE |
646 | 644 |
BUILD_EXTERNAL_LLVM_TRUE |
647 | 645 |
NO_MISSING_FIELD_INITIALIZERS |
... | ... |
@@ -653,6 +651,7 @@ BUILD_X86_TRUE |
653 | 653 |
THREAD_LIBS |
654 | 654 |
DEBUG_BUILD_FALSE |
655 | 655 |
DEBUG_BUILD_TRUE |
656 |
+LLVM_VERSION |
|
656 | 657 |
subdirs |
657 | 658 |
LLVMCONFIG_LIBFILES |
658 | 659 |
LLVMCONFIG_LIBS |
... | ... |
@@ -15613,10 +15612,7 @@ if test "${with_system_llvm+set}" = set; then : |
15613 | 15613 |
*) |
15614 | 15614 |
llvmconfig="$withval" |
15615 | 15615 |
llvmver=`$llvmconfig --version` |
15616 |
- if test "$llvmver" != "2.9" && test "$llvmver" != "3.0svn" && |
|
15617 |
- test "$llvmver" != "3.0"; then |
|
15618 |
- as_fn_error $? "LLVM 2.9 required, but \"$llvmver\" found" "$LINENO" 5 |
|
15619 |
- fi |
|
15616 |
+ |
|
15620 | 15617 |
LLVMCONFIG_CXXFLAGS=`$llvmconfig --cxxflags` |
15621 | 15618 |
|
15622 | 15619 |
LLVMCONFIG_LDFLAGS=`$llvmconfig --ldflags` |
... | ... |
@@ -15639,13 +15635,48 @@ $as_echo "$as_me: LIBS from llvm-config: $LLVMCONFIG_LIBS" >&6;} |
15639 | 15639 |
fi |
15640 | 15640 |
|
15641 | 15641 |
|
15642 |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for supported LLVM version" >&5 |
|
15643 |
+$as_echo_n "checking for supported LLVM version... " >&6; } |
|
15642 | 15644 |
if test "x$llvmconfig" = "x"; then |
15643 | 15645 |
|
15644 | 15646 |
|
15645 | 15647 |
subdirs="$subdirs llvm" |
15646 | 15648 |
|
15649 |
+ llvmver="2.8" |
|
15650 |
+ packaged_llvm="yes" |
|
15651 |
+fi |
|
15652 |
+ |
|
15653 |
+llvmver_val=`echo "$llvmver" | sed -e 's/svn//g'` |
|
15654 |
+llvmver_major=`echo "$llvmver_val" | sed -e 's/\([0-9]\).*/\1/'` |
|
15655 |
+llvmver_minor=`echo "$llvmver_val" | sed -e 's/[0-9]//' | sed -e 's/^\.//' | sed -e 's/\([0-9]\).*/\1/'` |
|
15656 |
+llvmver_patch=`echo "$llvmver_val" | sed -e 's/[0-9]\.[0-9]//' | sed -e 's/^\.//' | sed -e 's/\([0-9]\).*/\1/'` |
|
15657 |
+llvmver_suffix= |
|
15658 |
+if test "x$llvmver_patch" = "x"; then |
|
15659 |
+ llvmver_patch=0 |
|
15647 | 15660 |
fi |
15648 | 15661 |
|
15662 |
+llvmver_test=${llvmver_major}${llvmver_minor}${llvmver_patch} |
|
15663 |
+if test "x$packaged_llvm" = "xyes"; then |
|
15664 |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok ($llvmver)" >&5 |
|
15665 |
+$as_echo "ok ($llvmver)" >&6; } |
|
15666 |
+elif test $llvmver_test -lt 290; then |
|
15667 |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no ($llvmver)" >&5 |
|
15668 |
+$as_echo "no ($llvmver)" >&6; } |
|
15669 |
+ as_fn_error $? "LLVM >= 2.9 required, but \"$llvmver\"($llvmver_test) found" "$LINENO" 5 |
|
15670 |
+elif test $llvmver_test -gt 342; then |
|
15671 |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no ($llvmver)" >&5 |
|
15672 |
+$as_echo "no ($llvmver)" >&6; } |
|
15673 |
+ as_fn_error $? "LLVM <= 3.4.2 required, but \"$llvmver\"($llvmver_test) found" "$LINENO" 5 |
|
15674 |
+else |
|
15675 |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok ($llvmver)" >&5 |
|
15676 |
+$as_echo "ok ($llvmver)" >&6; } |
|
15677 |
+fi |
|
15678 |
+ |
|
15679 |
+llvmver_int=${llvmver_major}${llvmver_minor} |
|
15680 |
+ |
|
15681 |
+LLVM_VERSION=$llvmver_int |
|
15682 |
+ |
|
15683 |
+ |
|
15649 | 15684 |
# Check whether --enable-llvm was given. |
15650 | 15685 |
if test "${enable_llvm+set}" = set; then : |
15651 | 15686 |
enableval=$enable_llvm; enable_llvm=$enableval |
... | ... |
@@ -15711,7 +15742,7 @@ $as_echo_n "checking for supported OS... " >&6; } |
15711 | 15711 |
case "$target_cpu" in |
15712 | 15712 |
i?86|amd64|x86_64|powerpc*) |
15713 | 15713 |
case "$target_os" in |
15714 |
- darwin*|freebsd*|openbsd*|netbsd*|dragonfly*|linux*|solaris*|win32*|mingw*) |
|
15714 |
+ darwin*|freebsd*|kfreebsd*|openbsd*|netbsd*|dragonfly*|linux*|solaris*|win32*|mingw*) |
|
15715 | 15715 |
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ok ($target_cpu-$target_os)" >&5 |
15716 | 15716 |
$as_echo "ok ($target_cpu-$target_os)" >&6; } |
15717 | 15717 |
;; |
... | ... |
@@ -15873,14 +15904,6 @@ else |
15873 | 15873 |
BUILD_EXTERNAL_LLVM_FALSE= |
15874 | 15874 |
fi |
15875 | 15875 |
|
15876 |
- if test -n "$llvmconfig" && test "$llvmver" != "2.9"; then |
|
15877 |
- BUILD_LLVM3_TRUE= |
|
15878 |
- BUILD_LLVM3_FALSE='#' |
|
15879 |
-else |
|
15880 |
- BUILD_LLVM3_TRUE='#' |
|
15881 |
- BUILD_LLVM3_FALSE= |
|
15882 |
-fi |
|
15883 |
- |
|
15884 | 15876 |
|
15885 | 15877 |
|
15886 | 15878 |
|
... | ... |
@@ -16256,10 +16279,6 @@ if test -z "${BUILD_EXTERNAL_LLVM_TRUE}" && test -z "${BUILD_EXTERNAL_LLVM_FALSE |
16256 | 16256 |
as_fn_error $? "conditional \"BUILD_EXTERNAL_LLVM\" was never defined. |
16257 | 16257 |
Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
16258 | 16258 |
fi |
16259 |
-if test -z "${BUILD_LLVM3_TRUE}" && test -z "${BUILD_LLVM3_FALSE}"; then |
|
16260 |
- as_fn_error $? "conditional \"BUILD_LLVM3\" was never defined. |
|
16261 |
-Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
|
16262 |
-fi |
|
16263 | 16259 |
|
16264 | 16260 |
: "${CONFIG_STATUS=./config.status}" |
16265 | 16261 |
ac_write_fail=0 |
... | ... |
@@ -59,10 +59,7 @@ AC_ARG_WITH([system-llvm], AC_HELP_STRING([-with-system-llvm], |
59 | 59 |
*) |
60 | 60 |
llvmconfig="$withval" |
61 | 61 |
llvmver=`$llvmconfig --version` |
62 |
- if test "$llvmver" != "2.9" && test "$llvmver" != "3.0svn" && |
|
63 |
- test "$llvmver" != "3.0"; then |
|
64 |
- AC_MSG_ERROR([LLVM 2.9 required, but "$llvmver" found]) |
|
65 |
- fi |
|
62 |
+ |
|
66 | 63 |
AC_SUBST(LLVMCONFIG_CXXFLAGS, [`$llvmconfig --cxxflags`]) |
67 | 64 |
AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`]) |
68 | 65 |
AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs jit nativecodegen scalaropts ipo`]) |
... | ... |
@@ -75,10 +72,43 @@ AC_ARG_WITH([system-llvm], AC_HELP_STRING([-with-system-llvm], |
75 | 75 |
esac |
76 | 76 |
]) |
77 | 77 |
|
78 |
+AC_MSG_CHECKING([for supported LLVM version]) |
|
78 | 79 |
if test "x$llvmconfig" = "x"; then |
80 |
+ dnl macro not available in older autotools |
|
79 | 81 |
AC_CONFIG_SUBDIRS([llvm]) |
82 |
+ dnl llvmver=`$srcdir/llvm/configure --version | sed -n 1p | sed 's/llvm configure //'` |
|
83 |
+ llvmver="2.8" |
|
84 |
+ packaged_llvm="yes" |
|
85 |
+fi |
|
86 |
+ |
|
87 |
+llvmver_val=`echo "$llvmver" | sed -e 's/svn//g'` |
|
88 |
+llvmver_major=`echo "$llvmver_val" | sed -e 's/\([[0-9]]\).*/\1/'` |
|
89 |
+llvmver_minor=`echo "$llvmver_val" | sed -e 's/[[0-9]]//' | sed -e 's/^\.//' | sed -e 's/\([[0-9]]\).*/\1/'` |
|
90 |
+llvmver_patch=`echo "$llvmver_val" | sed -e 's/[[0-9]]\.[[0-9]]//' | sed -e 's/^\.//' | sed -e 's/\([[0-9]]\).*/\1/'` |
|
91 |
+dnl suffix unused as of LLVM 3.4.1 |
|
92 |
+llvmver_suffix= |
|
93 |
+if test "x$llvmver_patch" = "x"; then |
|
94 |
+ llvmver_patch=0 |
|
95 |
+fi |
|
96 |
+ |
|
97 |
+llvmver_test=${llvmver_major}${llvmver_minor}${llvmver_patch} |
|
98 |
+if test "x$packaged_llvm" = "xyes"; then |
|
99 |
+ AC_MSG_RESULT([ok ($llvmver)]) |
|
100 |
+elif test $llvmver_test -lt 290; then |
|
101 |
+ AC_MSG_RESULT([no ($llvmver)]) |
|
102 |
+ AC_MSG_ERROR([LLVM >= 2.9 required, but "$llvmver"($llvmver_test) found]) |
|
103 |
+elif test $llvmver_test -gt 342; then |
|
104 |
+ AC_MSG_RESULT([no ($llvmver)]) |
|
105 |
+ AC_MSG_ERROR([LLVM <= 3.4.2 required, but "$llvmver"($llvmver_test) found]) |
|
106 |
+else |
|
107 |
+ AC_MSG_RESULT([ok ($llvmver)]) |
|
80 | 108 |
fi |
81 | 109 |
|
110 |
+dnl patch does not affect clamav source (yet) |
|
111 |
+llvmver_int=${llvmver_major}${llvmver_minor} |
|
112 |
+ |
|
113 |
+AC_SUBST([LLVM_VERSION], [$llvmver_int]) |
|
114 |
+ |
|
82 | 115 |
AC_ARG_ENABLE([llvm],AC_HELP_STRING([-enable-llvm], |
83 | 116 |
[Enable 'llvm' JIT/verifier support @<:@default=auto@:>@]), |
84 | 117 |
[enable_llvm=$enableval], [enable_llvm="auto"]) |
... | ... |
@@ -128,7 +158,7 @@ if test "$enable_llvm" = "auto"; then |
128 | 128 |
case "$target_cpu" in |
129 | 129 |
i?86|amd64|x86_64|powerpc*) |
130 | 130 |
case "$target_os" in |
131 |
- darwin*|freebsd*|openbsd*|netbsd*|dragonfly*|linux*|solaris*|win32*|mingw*) |
|
131 |
+ darwin*|freebsd*|kfreebsd*|openbsd*|netbsd*|dragonfly*|linux*|solaris*|win32*|mingw*) |
|
132 | 132 |
AC_MSG_RESULT([ok ($target_cpu-$target_os)]) |
133 | 133 |
;; |
134 | 134 |
*) |
... | ... |
@@ -223,7 +253,6 @@ CXX_FLAG_CHECK(NO_MISSING_FIELD_INITIALIZERS, [-Wno-missing-field-initializers]) |
223 | 223 |
AC_MSG_RESULT([$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS]) |
224 | 224 |
|
225 | 225 |
AM_CONDITIONAL(BUILD_EXTERNAL_LLVM, [test -n "$llvmconfig"]) |
226 |
-AM_CONDITIONAL(BUILD_LLVM3, [test -n "$llvmconfig" && test "$llvmver" != "2.9"]) |
|
227 | 226 |
|
228 | 227 |
m4_include([../../m4/reorganization/libs/json.m4]) |
229 | 228 |
AC_SUBST([JSON_LIBS]) |
... | ... |
@@ -21,19 +21,18 @@ |
21 | 21 |
*/ |
22 | 22 |
|
23 | 23 |
#include "llvm/ADT/Triple.h" |
24 |
+#include "llvm/Config/config.h" |
|
24 | 25 |
#include "llvm/Support/raw_ostream.h" |
25 |
-#ifdef LLVM29 |
|
26 |
-#include "llvm/Support/Host.h" |
|
27 |
-#include "llvm/Support/DataTypes.h" |
|
28 |
-#include "llvm/Support/Memory.h" |
|
29 |
-#else |
|
30 |
-#include "llvm/System/Host.h" |
|
26 |
+#if LLVM_VERSION < 29 |
|
31 | 27 |
#include "llvm/System/DataTypes.h" |
28 |
+#include "llvm/System/Host.h" |
|
32 | 29 |
#include "llvm/System/Memory.h" |
30 |
+#else |
|
31 |
+#include "llvm/Support/DataTypes.h" |
|
32 |
+#include "llvm/Support/Host.h" |
|
33 |
+#include "llvm/Support/Memory.h" |
|
33 | 34 |
#endif |
34 | 35 |
|
35 |
-#include "llvm/Config/config.h" |
|
36 |
- |
|
37 | 36 |
extern "C" { |
38 | 37 |
#include "bytecode_detect.h" |
39 | 38 |
} |
... | ... |
@@ -56,16 +55,27 @@ static void warn_assumptions(const char *msg, int a, int b) |
56 | 56 |
|
57 | 57 |
void cli_detect_env_jit(struct cli_environment *env) |
58 | 58 |
{ |
59 |
+#if LLVM_VERSION < 31 |
|
59 | 60 |
std::string host_triple = sys::getHostTriple(); |
61 |
+#else |
|
62 |
+ std::string host_triple = sys::getDefaultTargetTriple(); |
|
63 |
+#endif |
|
60 | 64 |
INIT_STRFIELD(env->triple, host_triple.c_str()); |
61 | 65 |
|
62 | 66 |
std::string cpu = sys::getHostCPUName(); |
63 | 67 |
INIT_STRFIELD(env->cpu, cpu.c_str()); |
64 | 68 |
|
69 |
+#if LLVM_VERSION < 33 |
|
65 | 70 |
if (env->big_endian != (int)sys::isBigEndianHost()) { |
66 | 71 |
warn_assumptions("host endianness", env->big_endian, sys::isBigEndianHost()); |
67 | 72 |
env->big_endian = sys::isBigEndianHost(); |
68 | 73 |
} |
74 |
+#else |
|
75 |
+ if (env->big_endian != (int)sys::IsBigEndianHost) { |
|
76 |
+ warn_assumptions("host endianness", env->big_endian, sys::IsBigEndianHost); |
|
77 |
+ env->big_endian = sys::IsBigEndianHost; |
|
78 |
+ } |
|
79 |
+#endif |
|
69 | 80 |
|
70 | 81 |
#ifdef __GNUC__ |
71 | 82 |
env->cpp_version = MAKE_VERSION(0, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); |
... | ... |
@@ -144,12 +154,14 @@ void cli_detect_env_jit(struct cli_environment *env) |
144 | 144 |
CASE_OS(Linux, os_linux); |
145 | 145 |
CASE_OS(Lv2, os_unknown); |
146 | 146 |
CASE_OS(MinGW32, os_win32); |
147 |
-#ifndef LLVM29 |
|
147 |
+#if LLVM_VERSION < 29 |
|
148 | 148 |
CASE_OS(MinGW64, os_win64); |
149 | 149 |
#endif |
150 | 150 |
CASE_OS(NetBSD, os_bsd); |
151 | 151 |
CASE_OS(OpenBSD, os_bsd); |
152 |
+#if LLVM_VERSION < 31 |
|
152 | 153 |
CASE_OS(Psp, os_unknown); |
154 |
+#endif |
|
153 | 155 |
CASE_OS(Solaris, os_solaris); |
154 | 156 |
case Triple::Win32: |
155 | 157 |
env->os = llvm_os_Win32; |
... | ... |
@@ -1,16 +1,4 @@ |
1 |
-#ifdef LLVM30 |
|
2 |
-#define constType Type |
|
3 |
-#define constArrayType ArrayType |
|
4 |
-#define constStructType StructType |
|
5 |
-#define constPointerType PointerType |
|
6 |
-#define constFunctionType FunctionType |
|
7 |
-#define ARRAYREF(t,a,b) ArrayRef<t>(a,b) |
|
8 |
-#define ARRAYREFPARAM(t,a,b,n) ArrayRef<t> n |
|
9 |
-#define ARRAYREFP(a,b,n) n |
|
10 |
-#define ARRAYREFVECTOR(t,a) ArrayRef<t>(a) |
|
11 |
-#define HINT(n) n, |
|
12 |
-#define OPT(n) ,n |
|
13 |
-#else |
|
1 |
+#if LLVM_VERSION < 30 |
|
14 | 2 |
#define constType const Type |
15 | 3 |
#define constArrayType const ArrayType |
16 | 4 |
#define constStructType const StructType |
... | ... |
@@ -22,4 +10,16 @@ |
22 | 22 |
#define ARRAYREFVECTOR(t,a) (a).begin(),(a).end() |
23 | 23 |
#define HINT(n) |
24 | 24 |
#define OPT(n) |
25 |
+#else |
|
26 |
+#define constType Type |
|
27 |
+#define constArrayType ArrayType |
|
28 |
+#define constStructType StructType |
|
29 |
+#define constPointerType PointerType |
|
30 |
+#define constFunctionType FunctionType |
|
31 |
+#define ARRAYREF(t,a,b) ArrayRef<t>(a,b) |
|
32 |
+#define ARRAYREFPARAM(t,a,b,n) ArrayRef<t> n |
|
33 |
+#define ARRAYREFP(a,b,n) n |
|
34 |
+#define ARRAYREFVECTOR(t,a) ArrayRef<t>(a) |
|
35 |
+#define HINT(n) n, |
|
36 |
+#define OPT(n) ,n |
|
25 | 37 |
#endif |
... | ... |
@@ -932,7 +932,7 @@ int cache_check(unsigned char *hash, cli_ctx *ctx) { |
932 | 932 |
todo -= readme; |
933 | 933 |
at += readme; |
934 | 934 |
|
935 |
- if (cl_update_hash(hashctx, buf, readme)) { |
|
935 |
+ if (cl_update_hash(hashctx, (void *)buf, readme)) { |
|
936 | 936 |
cl_hash_destroy(hashctx); |
937 | 937 |
cli_errmsg("cache_check: error reading while generating hash!\n"); |
938 | 938 |
return CL_EREAD; |
... | ... |
@@ -66,10 +66,10 @@ static size_t base64_len(const char *data, size_t len) |
66 | 66 |
* @param[out] olen The length of the decoded data |
67 | 67 |
* @return The base64-decoded data |
68 | 68 |
*/ |
69 |
-void *cl_base64_decode(char *data, size_t len, void *obuf, size_t *olen) |
|
69 |
+void *cl_base64_decode(char *data, size_t len, void *obuf, size_t *olen, int oneline) |
|
70 | 70 |
{ |
71 | 71 |
BIO *bio, *b64; |
72 |
- void *buf, *ret; |
|
72 |
+ void *buf; |
|
73 | 73 |
|
74 | 74 |
buf = (obuf) ? obuf : malloc(base64_len(data, len)+1); |
75 | 75 |
if (!(buf)) |
... | ... |
@@ -93,7 +93,8 @@ void *cl_base64_decode(char *data, size_t len, void *obuf, size_t *olen) |
93 | 93 |
} |
94 | 94 |
|
95 | 95 |
bio = BIO_push(b64, bio); |
96 |
- BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); |
|
96 |
+ if (oneline) |
|
97 |
+ BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); |
|
97 | 98 |
|
98 | 99 |
*olen = BIO_read(bio, buf, base64_len(data, len)); |
99 | 100 |
|
... | ... |
@@ -124,7 +124,7 @@ int cli_scancpio_old(cli_ctx *ctx) |
124 | 124 |
if(hdr_old.namesize) { |
125 | 125 |
hdr_namesize = EC16(hdr_old.namesize, conv); |
126 | 126 |
namesize = MIN(sizeof(name), hdr_namesize); |
127 |
- if (fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) { |
|
127 |
+ if ((uint32_t)fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) { |
|
128 | 128 |
cli_dbgmsg("cli_scancpio_old: Can't read file name\n"); |
129 | 129 |
return CL_EFORMAT; |
130 | 130 |
} |
... | ... |
@@ -202,7 +202,7 @@ int cli_scancpio_odc(cli_ctx *ctx) |
202 | 202 |
} |
203 | 203 |
if(hdr_namesize) { |
204 | 204 |
namesize = MIN(sizeof(name), hdr_namesize); |
205 |
- if (fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) { |
|
205 |
+ if ((uint32_t)fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) { |
|
206 | 206 |
cli_dbgmsg("cli_scancpio_odc: Can't read file name\n"); |
207 | 207 |
return CL_EFORMAT; |
208 | 208 |
} |
... | ... |
@@ -276,7 +276,7 @@ int cli_scancpio_newc(cli_ctx *ctx, int crc) |
276 | 276 |
} |
277 | 277 |
if(hdr_namesize) { |
278 | 278 |
namesize = MIN(sizeof(name), hdr_namesize); |
279 |
- if (fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) { |
|
279 |
+ if ((uint32_t)fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) { |
|
280 | 280 |
cli_dbgmsg("cli_scancpio_newc: Can't read file name\n"); |
281 | 281 |
return CL_EFORMAT; |
282 | 282 |
} |
... | ... |
@@ -41,6 +41,7 @@ int cli_crt_init(cli_crt *x509) { |
41 | 41 |
} |
42 | 42 |
|
43 | 43 |
void cli_crt_clear(cli_crt *x509) { |
44 |
+ UNUSEDPARAM(x509); |
|
44 | 45 |
mp_clear_multi(&x509->n, &x509->e, &x509->sig, NULL); |
45 | 46 |
} |
46 | 47 |
|
... | ... |
@@ -337,104 +338,8 @@ cli_crt *crtmgr_verify_pkcs7(crtmgr *m, const uint8_t *issuer, const uint8_t *se |
337 | 337 |
return i; |
338 | 338 |
} |
339 | 339 |
|
340 |
-/* DC=com, DC=microsoft, CN=Microsoft Root Certificate Authority */ |
|
341 |
-static const uint8_t MSCA_SUBJECT[] = "\x11\x3b\xd8\x6b\xed\xde\xbc\xd4\xc5\xf1\x0a\xa0\x7a\xb2\x02\x6b\x98\x2f\x4b\x92"; |
|
342 |
-static const uint8_t MSCA_MOD[] = "\ |
|
343 |
-\x00\xf3\x5d\xfa\x80\x67\xd4\x5a\xa7\xa9\x0c\x2c\x90\x20\xd0\ |
|
344 |
-\x35\x08\x3c\x75\x84\xcd\xb7\x07\x89\x9c\x89\xda\xde\xce\xc3\ |
|
345 |
-\x60\xfa\x91\x68\x5a\x9e\x94\x71\x29\x18\x76\x7c\xc2\xe0\xc8\ |
|
346 |
-\x25\x76\x94\x0e\x58\xfa\x04\x34\x36\xe6\xdf\xaf\xf7\x80\xba\ |
|
347 |
-\xe9\x58\x0b\x2b\x93\xe5\x9d\x05\xe3\x77\x22\x91\xf7\x34\x64\ |
|
348 |
-\x3c\x22\x91\x1d\x5e\xe1\x09\x90\xbc\x14\xfe\xfc\x75\x58\x19\ |
|
349 |
-\xe1\x79\xb7\x07\x92\xa3\xae\x88\x59\x08\xd8\x9f\x07\xca\x03\ |
|
350 |
-\x58\xfc\x68\x29\x6d\x32\xd7\xd2\xa8\xcb\x4b\xfc\xe1\x0b\x48\ |
|
351 |
-\x32\x4f\xe6\xeb\xb8\xad\x4f\xe4\x5c\x6f\x13\x94\x99\xdb\x95\ |
|
352 |
-\xd5\x75\xdb\xa8\x1a\xb7\x94\x91\xb4\x77\x5b\xf5\x48\x0c\x8f\ |
|
353 |
-\x6a\x79\x7d\x14\x70\x04\x7d\x6d\xaf\x90\xf5\xda\x70\xd8\x47\ |
|
354 |
-\xb7\xbf\x9b\x2f\x6c\xe7\x05\xb7\xe1\x11\x60\xac\x79\x91\x14\ |
|
355 |
-\x7c\xc5\xd6\xa6\xe4\xe1\x7e\xd5\xc3\x7e\xe5\x92\xd2\x3c\x00\ |
|
356 |
-\xb5\x36\x82\xde\x79\xe1\x6d\xf3\xb5\x6e\xf8\x9f\x33\xc9\xcb\ |
|
357 |
-\x52\x7d\x73\x98\x36\xdb\x8b\xa1\x6b\xa2\x95\x97\x9b\xa3\xde\ |
|
358 |
-\xc2\x4d\x26\xff\x06\x96\x67\x25\x06\xc8\xe7\xac\xe4\xee\x12\ |
|
359 |
-\x33\x95\x31\x99\xc8\x35\x08\x4e\x34\xca\x79\x53\xd5\xb5\xbe\ |
|
360 |
-\x63\x32\x59\x40\x36\xc0\xa5\x4e\x04\x4d\x3d\xdb\x5b\x07\x33\ |
|
361 |
-\xe4\x58\xbf\xef\x3f\x53\x64\xd8\x42\x59\x35\x57\xfd\x0f\x45\ |
|
362 |
-\x7c\x24\x04\x4d\x9e\xd6\x38\x74\x11\x97\x22\x90\xce\x68\x44\ |
|
363 |
-\x74\x92\x6f\xd5\x4b\x6f\xb0\x86\xe3\xc7\x36\x42\xa0\xd0\xfc\ |
|
364 |
-\xc1\xc0\x5a\xf9\xa3\x61\xb9\x30\x47\x71\x96\x0a\x16\xb0\x91\ |
|
365 |
-\xc0\x42\x95\xef\x10\x7f\x28\x6a\xe3\x2a\x1f\xb1\xe4\xcd\x03\ |
|
366 |
-\x3f\x77\x71\x04\xc7\x20\xfc\x49\x0f\x1d\x45\x88\xa4\xd7\xcb\ |
|
367 |
-\x7e\x88\xad\x8e\x2d\xec\x45\xdb\xc4\x51\x04\xc9\x2a\xfc\xec\ |
|
368 |
-\x86\x9e\x9a\x11\x97\x5b\xde\xce\x53\x88\xe6\xe2\xb7\xfd\xac\ |
|
369 |
-\x95\xc2\x28\x40\xdb\xef\x04\x90\xdf\x81\x33\x39\xd9\xb2\x45\ |
|
370 |
-\xa5\x23\x87\x06\xa5\x55\x89\x31\xbb\x06\x2d\x60\x0e\x41\x18\ |
|
371 |
-\x7d\x1f\x2e\xb5\x97\xcb\x11\xeb\x15\xd5\x24\xa5\x94\xef\x15\ |
|
372 |
-\x14\x89\xfd\x4b\x73\xfa\x32\x5b\xfc\xd1\x33\x00\xf9\x59\x62\ |
|
373 |
-\x70\x07\x32\xea\x2e\xab\x40\x2d\x7b\xca\xdd\x21\x67\x1b\x30\ |
|
374 |
-\x99\x8f\x16\xaa\x23\xa8\x41\xd1\xb0\x6e\x11\x9b\x36\xc4\xde\ |
|
375 |
-\x40\x74\x9c\xe1\x58\x65\xc1\x60\x1e\x7a\x5b\x38\xc8\x8f\xbb\ |
|
376 |
-\x04\x26\x7c\xd4\x16\x40\xe5\xb6\x6b\x6c\xaa\x86\xfd\x00\xbf\ |
|
377 |
-\xce\xc1\x35"; |
|
378 |
-static const uint8_t MSCA_EXP[] = "\x01\x00\x01"; |
|
379 |
- |
|
380 |
-/* OU=Copyright (c) 1997 Microsoft Corp., OU=Microsoft Corporation, CN=Microsoft Root Authority */ |
|
381 |
-static const uint8_t MSA_SUBJECT[] = "\xad\xf7\x98\x77\x06\x5e\xf3\x05\xeb\x95\xb5\x6d\xbc\xa9\xe6\x3e\x9a\xb4\x0d\x3b"; |
|
382 |
-static const uint8_t MSA_MOD[] = "\ |
|
383 |
-\x00\xa9\x02\xbd\xc1\x70\xe6\x3b\xf2\x4e\x1b\x28\x9f\x97\x78\ |
|
384 |
-\x5e\x30\xea\xa2\xa9\x8d\x25\x5f\xf8\xfe\x95\x4c\xa3\xb7\xfe\ |
|
385 |
-\x9d\xa2\x20\x3e\x7c\x51\xa2\x9b\xa2\x8f\x60\x32\x6b\xd1\x42\ |
|
386 |
-\x64\x79\xee\xac\x76\xc9\x54\xda\xf2\xeb\x9c\x86\x1c\x8f\x9f\ |
|
387 |
-\x84\x66\xb3\xc5\x6b\x7a\x62\x23\xd6\x1d\x3c\xde\x0f\x01\x92\ |
|
388 |
-\xe8\x96\xc4\xbf\x2d\x66\x9a\x9a\x68\x26\x99\xd0\x3a\x2c\xbf\ |
|
389 |
-\x0c\xb5\x58\x26\xc1\x46\xe7\x0a\x3e\x38\x96\x2c\xa9\x28\x39\ |
|
390 |
-\xa8\xec\x49\x83\x42\xe3\x84\x0f\xbb\x9a\x6c\x55\x61\xac\x82\ |
|
391 |
-\x7c\xa1\x60\x2d\x77\x4c\xe9\x99\xb4\x64\x3b\x9a\x50\x1c\x31\ |
|
392 |
-\x08\x24\x14\x9f\xa9\xe7\x91\x2b\x18\xe6\x3d\x98\x63\x14\x60\ |
|
393 |
-\x58\x05\x65\x9f\x1d\x37\x52\x87\xf7\xa7\xef\x94\x02\xc6\x1b\ |
|
394 |
-\xd3\xbf\x55\x45\xb3\x89\x80\xbf\x3a\xec\x54\x94\x4e\xae\xfd\ |
|
395 |
-\xa7\x7a\x6d\x74\x4e\xaf\x18\xcc\x96\x09\x28\x21\x00\x57\x90\ |
|
396 |
-\x60\x69\x37\xbb\x4b\x12\x07\x3c\x56\xff\x5b\xfb\xa4\x66\x0a\ |
|
397 |
-\x08\xa6\xd2\x81\x56\x57\xef\xb6\x3b\x5e\x16\x81\x77\x04\xda\ |
|
398 |
-\xf6\xbe\xae\x80\x95\xfe\xb0\xcd\x7f\xd6\xa7\x1a\x72\x5c\x3c\ |
|
399 |
-\xca\xbc\xf0\x08\xa3\x22\x30\xb3\x06\x85\xc9\xb3\x20\x77\x13\ |
|
400 |
-\x85\xdf"; |
|
401 |
-static const uint8_t MSA_EXP[] = "\x01\x00\x01"; |
|
402 |
- |
|
403 |
- |
|
404 |
-/* C=ZA, ST=Western Cape, L=Durbanville, O=Thawte, OU=Thawte Certification, CN=Thawte Timestamping CA */ |
|
405 |
-static const uint8_t THAW_SUBJECT[] = "\x9a\x02\x27\x8e\x9c\xb1\x28\x76\xc4\x7a\xb0\xbc\x75\xdd\x69\x4e\x72\xd1\xb2\xbc"; |
|
406 |
-static const uint8_t THAW_MOD[] = "\ |
|
407 |
-\x00\xd6\x2b\x58\x78\x61\x45\x86\x53\xea\x34\x7b\x51\x9c\xed\ |
|
408 |
-\xb0\xe6\x2e\x18\x0e\xfe\xe0\x5f\xa8\x27\xd3\xb4\xc9\xe0\x7c\ |
|
409 |
-\x59\x4e\x16\x0e\x73\x54\x60\xc1\x7f\xf6\x9f\x2e\xe9\x3a\x85\ |
|
410 |
-\x24\x15\x3c\xdb\x47\x04\x63\xc3\x9e\xc4\x94\x1a\x5a\xdf\x4c\ |
|
411 |
-\x7a\xf3\xd9\x43\x1d\x3c\x10\x7a\x79\x25\xdb\x90\xfe\xf0\x51\ |
|
412 |
-\xe7\x30\xd6\x41\x00\xfd\x9f\x28\xdf\x79\xbe\x94\xbb\x9d\xb6\ |
|
413 |
-\x14\xe3\x23\x85\xd7\xa9\x41\xe0\x4c\xa4\x79\xb0\x2b\x1a\x8b\ |
|
414 |
-\xf2\xf8\x3b\x8a\x3e\x45\xac\x71\x92\x00\xb4\x90\x41\x98\xfb\ |
|
415 |
-\x5f\xed\xfa\xb7\x2e\x8a\xf8\x88\x37"; |
|
416 |
-const uint8_t THAW_EXP[] = "\x01\x00\x01"; |
|
417 |
- |
|
418 |
- |
|
419 |
-/* C=US, O=VeriSign, Inc., OU=Class 3 Public Primary Certification Authority */ |
|
420 |
-static const uint8_t VER_SUBJECT[] = "\x29\xdb\xd4\xb8\x8f\x78\x5f\x33\x41\x92\x87\xe1\xaf\x46\x50\xe1\x77\xa4\x6f\xc0"; |
|
421 |
-static const uint8_t VER_MOD[] = "\ |
|
422 |
-\x00\xc9\x5c\x59\x9e\xf2\x1b\x8a\x01\x14\xb4\x10\xdf\x04\x40\ |
|
423 |
-\xdb\xe3\x57\xaf\x6a\x45\x40\x8f\x84\x0c\x0b\xd1\x33\xd9\xd9\ |
|
424 |
-\x11\xcf\xee\x02\x58\x1f\x25\xf7\x2a\xa8\x44\x05\xaa\xec\x03\ |
|
425 |
-\x1f\x78\x7f\x9e\x93\xb9\x9a\x00\xaa\x23\x7d\xd6\xac\x85\xa2\ |
|
426 |
-\x63\x45\xc7\x72\x27\xcc\xf4\x4c\xc6\x75\x71\xd2\x39\xef\x4f\ |
|
427 |
-\x42\xf0\x75\xdf\x0a\x90\xc6\x8e\x20\x6f\x98\x0f\xf8\xac\x23\ |
|
428 |
-\x5f\x70\x29\x36\xa4\xc9\x86\xe7\xb1\x9a\x20\xcb\x53\xa5\x85\ |
|
429 |
-\xe7\x3d\xbe\x7d\x9a\xfe\x24\x45\x33\xdc\x76\x15\xed\x0f\xa2\ |
|
430 |
-\x71\x64\x4c\x65\x2e\x81\x68\x45\xa7"; |
|
431 |
-static const uint8_t VER_EXP[] = "\x01\x00\x01"; |
|
432 |
- |
|
433 |
- |
|
434 | 340 |
int crtmgr_add_roots(struct cl_engine *engine, crtmgr *m) { |
435 |
- cli_crt ca; |
|
436 |
- cli_crt *crt, *new_crt; |
|
437 |
- |
|
341 |
+ cli_crt *crt; |
|
438 | 342 |
/* |
439 | 343 |
* Certs are cached in engine->cmgr. Copy from there. |
440 | 344 |
*/ |
... | ... |
@@ -164,7 +164,7 @@ unsigned char *cl_hash_data(char *alg, const void *buf, size_t len, unsigned cha |
164 | 164 |
|
165 | 165 |
cur=0; |
166 | 166 |
while (cur < len) { |
167 |
- size_t todo = MIN(EVP_MD_block_size(md), len-cur); |
|
167 |
+ size_t todo = MIN((unsigned long)EVP_MD_block_size(md), (unsigned long)(len-cur)); |
|
168 | 168 |
if (!EVP_DigestUpdate(ctx, (void *)(((unsigned char *)buf)+cur), todo)) { |
169 | 169 |
if (!(obuf)) |
170 | 170 |
free(ret); |
... | ... |
@@ -399,7 +399,7 @@ int cl_verify_signature(EVP_PKEY *pkey, char *alg, unsigned char *sig, unsigned |
399 | 399 |
unsigned char *newsig; |
400 | 400 |
size_t newsiglen; |
401 | 401 |
|
402 |
- newsig = (unsigned char *)cl_base64_decode((char *)sig, siglen, NULL, &newsiglen); |
|
402 |
+ newsig = (unsigned char *)cl_base64_decode((char *)sig, siglen, NULL, &newsiglen, 1); |
|
403 | 403 |
if (!(newsig)) |
404 | 404 |
return -1; |
405 | 405 |
|
... | ... |
@@ -736,7 +736,7 @@ X509 *cl_get_x509_from_mem(void *data, unsigned int len) |
736 | 736 |
|
737 | 737 |
int cl_validate_certificate_chain_ts_dir(char *tsdir, char *certpath) |
738 | 738 |
{ |
739 |
- char **authorities=NULL, **t, *fullpath; |
|
739 |
+ char **authorities=NULL, **t; |
|
740 | 740 |
size_t nauths = 0; |
741 | 741 |
int res; |
742 | 742 |
DIR *dp; |
... | ... |
@@ -964,7 +964,6 @@ struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj) |
964 | 964 |
{ |
965 | 965 |
struct tm *t; |
966 | 966 |
char* str; |
967 |
- size_t i = 0; |
|
968 | 967 |
const char *fmt=NULL; |
969 | 968 |
time_t localt; |
970 | 969 |
#ifdef _WIN32 |
... | ... |
@@ -1032,7 +1031,6 @@ X509_CRL *cl_load_crl(const char *file) |
1032 | 1032 |
X509_CRL *x=NULL; |
1033 | 1033 |
FILE *fp; |
1034 | 1034 |
struct tm *tm; |
1035 |
- time_t crltime; |
|
1036 | 1035 |
|
1037 | 1036 |
if (!(file)) |
1038 | 1037 |
return NULL; |
... | ... |
@@ -47,6 +47,7 @@ |
47 | 47 |
|
48 | 48 |
static void cli_untgz_cleanup(char *path, gzFile infile, FILE *outfile, int fdd) |
49 | 49 |
{ |
50 |
+ UNUSEDPARAM(fdd); |
|
50 | 51 |
cli_dbgmsg("in cli_untgz_cleanup()\n"); |
51 | 52 |
if (path != NULL) |
52 | 53 |
free (path); |
... | ... |
@@ -180,6 +181,7 @@ static int cli_untgz(int fd, const char *destdir) |
180 | 180 |
|
181 | 181 |
static void cli_tgzload_cleanup(int comp, struct cli_dbio *dbio, int fdd) |
182 | 182 |
{ |
183 |
+ UNUSEDPARAM(fdd); |
|
183 | 184 |
cli_dbgmsg("in cli_tgzload_cleanup()\n"); |
184 | 185 |
if(comp) { |
185 | 186 |
gzclose(dbio->gzs); |
... | ... |
@@ -95,10 +95,10 @@ static int dmg_handle_mish(cli_ctx *, unsigned int, char *, uint64_t, struct dmg |
95 | 95 |
int cli_scandmg(cli_ctx *ctx) |
96 | 96 |
{ |
97 | 97 |
struct dmg_koly_block hdr; |
98 |
- int ret, namelen, ofd; |
|
98 |
+ int ret; |
|
99 | 99 |
size_t maplen, nread; |
100 | 100 |
off_t pos = 0; |
101 |
- char *dirname, *tmpfile; |
|
101 |
+ char *dirname; |
|
102 | 102 |
const char *outdata; |
103 | 103 |
unsigned int file = 0; |
104 | 104 |
struct dmg_mish_with_stripes *mish_list = NULL, *mish_list_tail = NULL; |
... | ... |
@@ -255,7 +255,7 @@ int cli_scandmg(cli_ctx *ctx) |
255 | 255 |
/* Reset state early, for continue cases */ |
256 | 256 |
stateDepth[DMG_FIND_KEY_DATA] = -1; |
257 | 257 |
state--; |
258 |
- if (xmlStrcmp(nodeName, "data") != 0) { |
|
258 |
+ if (xmlStrcmp(nodeName, (const xmlChar *)"data") != 0) { |
|
259 | 259 |
cli_dbgmsg("cli_scandmg: Not blkx data element\n"); |
260 | 260 |
xmlFree(nodeName); |
261 | 261 |
continue; |
... | ... |
@@ -316,7 +316,7 @@ int cli_scandmg(cli_ctx *ctx) |
316 | 316 |
} |
317 | 317 |
if ((state == DMG_FIND_KEY_DATA) |
318 | 318 |
&& (depth > stateDepth[state-1]) |
319 |
- && (xmlStrcmp(nodeName, "key") == 0)) { |
|
319 |
+ && (xmlStrcmp(nodeName, (const xmlChar *)"key") == 0)) { |
|
320 | 320 |
xmlChar * textValue; |
321 | 321 |
dmg_parsemsg("read: Found key - checking for Data\n"); |
322 | 322 |
if (xmlTextReaderRead(reader) != 1) { |
... | ... |
@@ -334,7 +334,7 @@ int cli_scandmg(cli_ctx *ctx) |
334 | 334 |
xmlFree(nodeName); |
335 | 335 |
continue; |
336 | 336 |
} |
337 |
- if (xmlStrcmp(textValue, "Data") == 0) { |
|
337 |
+ if (xmlStrcmp(textValue, (const xmlChar *)"Data") == 0) { |
|
338 | 338 |
dmg_parsemsg("read: Matched data\n"); |
339 | 339 |
stateDepth[DMG_FIND_KEY_DATA] = depth; |
340 | 340 |
state++; |
... | ... |
@@ -346,12 +346,12 @@ int cli_scandmg(cli_ctx *ctx) |
346 | 346 |
} |
347 | 347 |
if ((state == DMG_FIND_BLKX_CONTAINER) |
348 | 348 |
&& (depth == stateDepth[state-1])) { |
349 |
- if (xmlStrcmp(nodeName, "array") == 0) { |
|
349 |
+ if (xmlStrcmp(nodeName, (const xmlChar *)"array") == 0) { |
|
350 | 350 |
dmg_parsemsg("read: Found array blkx\n"); |
351 | 351 |
stateDepth[DMG_FIND_BLKX_CONTAINER] = depth; |
352 | 352 |
state++; |
353 | 353 |
} |
354 |
- else if (xmlStrcmp(nodeName, "dict") == 0) { |
|
354 |
+ else if (xmlStrcmp(nodeName, (const xmlChar *)"dict") == 0) { |
|
355 | 355 |
dmg_parsemsg("read: Found dict blkx\n"); |
356 | 356 |
stateDepth[DMG_FIND_BLKX_CONTAINER] = depth; |
357 | 357 |
state++; |
... | ... |
@@ -364,7 +364,7 @@ int cli_scandmg(cli_ctx *ctx) |
364 | 364 |
} |
365 | 365 |
if ((state == DMG_FIND_KEY_BLKX) |
366 | 366 |
&& (depth == stateDepth[state-1] + 1) |
367 |
- && (xmlStrcmp(nodeName, "key") == 0)) { |
|
367 |
+ && (xmlStrcmp(nodeName, (const xmlChar *)"key") == 0)) { |
|
368 | 368 |
xmlChar * textValue; |
369 | 369 |
dmg_parsemsg("read: Found key - checking for blkx\n"); |
370 | 370 |
if (xmlTextReaderRead(reader) != 1) { |
... | ... |
@@ -382,7 +382,7 @@ int cli_scandmg(cli_ctx *ctx) |
382 | 382 |
xmlFree(nodeName); |
383 | 383 |
continue; |
384 | 384 |
} |
385 |
- if (xmlStrcmp(textValue, "blkx") == 0) { |
|
385 |
+ if (xmlStrcmp(textValue, (const xmlChar *)"blkx") == 0) { |
|
386 | 386 |
cli_dbgmsg("cli_scandmg: Matched blkx\n"); |
387 | 387 |
stateDepth[DMG_FIND_KEY_BLKX] = depth; |
388 | 388 |
state++; |
... | ... |
@@ -394,7 +394,7 @@ int cli_scandmg(cli_ctx *ctx) |
394 | 394 |
} |
395 | 395 |
if ((state == DMG_FIND_DICT_RESOURCE_FORK) |
396 | 396 |
&& (depth == stateDepth[state-1])) { |
397 |
- if (xmlStrcmp(nodeName, "dict") == 0) { |
|
397 |
+ if (xmlStrcmp(nodeName, (const xmlChar *)"dict") == 0) { |
|
398 | 398 |
dmg_parsemsg("read: Found resource-fork dict\n"); |
399 | 399 |
stateDepth[DMG_FIND_DICT_RESOURCE_FORK] = depth; |
400 | 400 |
state++; |
... | ... |
@@ -407,19 +407,19 @@ int cli_scandmg(cli_ctx *ctx) |
407 | 407 |
} |
408 | 408 |
if ((state == DMG_FIND_KEY_RESOURCE_FORK) |
409 | 409 |
&& (depth == stateDepth[state-1] + 1) |
410 |
- && (xmlStrcmp(nodeName, "key") == 0)) { |
|
410 |
+ && (xmlStrcmp(nodeName, (const xmlChar *)"key") == 0)) { |
|
411 | 411 |
dmg_parsemsg("read: Found resource-fork key\n"); |
412 | 412 |
stateDepth[DMG_FIND_KEY_RESOURCE_FORK] = depth; |
413 | 413 |
state++; |
414 | 414 |
} |
415 | 415 |
if ((state == DMG_FIND_BASE_DICT) |
416 | 416 |
&& (depth == stateDepth[state-1] + 1) |
417 |
- && (xmlStrcmp(nodeName, "dict") == 0)) { |
|
417 |
+ && (xmlStrcmp(nodeName, (const xmlChar *)"dict") == 0)) { |
|
418 | 418 |
dmg_parsemsg("read: Found dict start\n"); |
419 | 419 |
stateDepth[DMG_FIND_BASE_DICT] = depth; |
420 | 420 |
state++; |
421 | 421 |
} |
422 |
- if ((state == DMG_FIND_BASE_PLIST) && (xmlStrcmp(nodeName, "plist") == 0)) { |
|
422 |
+ if ((state == DMG_FIND_BASE_PLIST) && (xmlStrcmp(nodeName, (const xmlChar *)"plist") == 0)) { |
|
423 | 423 |
dmg_parsemsg("read: Found plist start\n"); |
424 | 424 |
stateDepth[DMG_FIND_BASE_PLIST] = depth; |
425 | 425 |
state++; |
... | ... |
@@ -498,13 +498,14 @@ int cli_scandmg(cli_ctx *ctx) |
498 | 498 |
static int dmg_decode_mish(cli_ctx *ctx, unsigned int *mishblocknum, xmlChar *mish_base64, |
499 | 499 |
struct dmg_mish_with_stripes *mish_set) |
500 | 500 |
{ |
501 |
- int ret = CL_CLEAN; |
|
502 | 501 |
size_t base64_len, buff_size, decoded_len; |
503 | 502 |
uint8_t *decoded; |
504 | 503 |
const uint8_t mish_magic[4] = { 0x6d, 0x69, 0x73, 0x68 }; |
505 | 504 |
|
505 |
+ UNUSEDPARAM(ctx); |
|
506 |
+ |
|
506 | 507 |
(*mishblocknum)++; |
507 |
- base64_len = strlen(mish_base64); |
|
508 |
+ base64_len = strlen((const char *)mish_base64); |
|
508 | 509 |
dmg_parsemsg("dmg_decode_mish: len of encoded block %u is %lu\n", *mishblocknum, base64_len); |
509 | 510 |
|
510 | 511 |
/* speed vs memory, could walk the encoded data and skip whitespace in calculation */ |
... | ... |
@@ -652,6 +653,8 @@ static int dmg_stripe_zeroes(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mi |
652 | 652 |
ssize_t written; |
653 | 653 |
uint8_t obuf[BUFSIZ]; |
654 | 654 |
|
655 |
+ UNUSEDPARAM(ctx); |
|
656 |
+ |
|
655 | 657 |
cli_dbgmsg("dmg_stripe_zeroes: stripe " STDu32 "\n", index); |
656 | 658 |
if (len == 0) |
657 | 659 |
return CL_CLEAN; |
... | ... |
@@ -659,7 +662,7 @@ static int dmg_stripe_zeroes(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mi |
659 | 659 |
memset(obuf, 0, sizeof(obuf)); |
660 | 660 |
while (len > sizeof(obuf)) { |
661 | 661 |
written = cli_writen(fd, obuf, sizeof(obuf)); |
662 |
- if (written != sizeof(obuf)) { |
|
662 |
+ if ((size_t)written != sizeof(obuf)) { |
|
663 | 663 |
ret = CL_EWRITE; |
664 | 664 |
break; |
665 | 665 |
} |
... | ... |
@@ -668,7 +671,7 @@ static int dmg_stripe_zeroes(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mi |
668 | 668 |
|
669 | 669 |
if ((ret == CL_CLEAN) && (len > 0)) { |
670 | 670 |
written = cli_writen(fd, obuf, len); |
671 |
- if (written != len) { |
|
671 |
+ if ((size_t)written != len) { |
|
672 | 672 |
ret = CL_EWRITE; |
673 | 673 |
} |
674 | 674 |
} |
... | ... |
@@ -684,7 +687,6 @@ static int dmg_stripe_zeroes(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mi |
684 | 684 |
static int dmg_stripe_store(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish_with_stripes *mish_set) |
685 | 685 |
{ |
686 | 686 |
const void *obuf; |
687 |
- int ret; |
|
688 | 687 |
size_t off = mish_set->stripes[index].dataOffset; |
689 | 688 |
size_t len = mish_set->stripes[index].dataLength; |
690 | 689 |
ssize_t written; |
... | ... |
@@ -703,7 +705,7 @@ static int dmg_stripe_store(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mis |
703 | 703 |
cli_errmsg("dmg_stripe_store: error writing bytes to file (out of disk space?)\n"); |
704 | 704 |
return CL_EWRITE; |
705 | 705 |
} |
706 |
- else if (written != len) { |
|
706 |
+ else if ((size_t)written != len) { |
|
707 | 707 |
cli_errmsg("dmg_stripe_store: error writing bytes to file (out of disk space?)\n"); |
708 | 708 |
return CL_EWRITE; |
709 | 709 |
} |
... | ... |
@@ -713,7 +715,7 @@ static int dmg_stripe_store(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mis |
713 | 713 |
/* Stripe handling: ADC block (type 0x80000004) */ |
714 | 714 |
static int dmg_stripe_adc(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish_with_stripes *mish_set) |
715 | 715 |
{ |
716 |
- int ret = CL_CLEAN, adcret; |
|
716 |
+ int adcret; |
|
717 | 717 |
adc_stream strm; |
718 | 718 |
size_t off = mish_set->stripes[index].dataOffset; |
719 | 719 |
size_t len = mish_set->stripes[index].dataLength; |
... | ... |
@@ -796,7 +798,7 @@ static int dmg_stripe_adc(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish_ |
796 | 796 |
/* Stripe handling: deflate block (type 0x80000005) */ |
797 | 797 |
static int dmg_stripe_inflate(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish_with_stripes *mish_set) |
798 | 798 |
{ |
799 |
- int ret = CL_CLEAN, zstat; |
|
799 |
+ int zstat; |
|
800 | 800 |
z_stream strm; |
801 | 801 |
size_t off = mish_set->stripes[index].dataOffset; |
802 | 802 |
size_t len = mish_set->stripes[index].dataLength; |
... | ... |
@@ -905,7 +907,7 @@ static int dmg_stripe_bzip(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish |
905 | 905 |
|
906 | 906 |
#if HAVE_BZLIB_H |
907 | 907 |
memset(&strm, 0, sizeof(strm)); |
908 |
- strm.next_out = obuf; |
|
908 |
+ strm.next_out = (char *)obuf; |
|
909 | 909 |
strm.avail_out = sizeof(obuf); |
910 | 910 |
if (BZ2_bzDecompressInit(&strm, 0, 0) != BZ_OK) { |
911 | 911 |
cli_dbgmsg("dmg_stripe_bzip: bzDecompressInit failed\n"); |
... | ... |
@@ -960,13 +962,13 @@ static int dmg_stripe_bzip(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish |
960 | 960 |
break; |
961 | 961 |
} |
962 | 962 |
|
963 |
- if (cli_writen(fd, obuf, next_write) != next_write) { |
|
963 |
+ if ((size_t)cli_writen(fd, obuf, next_write) != next_write) { |
|
964 | 964 |
cli_dbgmsg("dmg_stripe_bzip: error writing to tmpfile\n"); |
965 | 965 |
ret = CL_EWRITE; |
966 | 966 |
break; |
967 | 967 |
} |
968 | 968 |
|
969 |
- strm.next_out = obuf; |
|
969 |
+ strm.next_out = (char *)obuf; |
|
970 | 970 |
strm.avail_out = sizeof(obuf); |
971 | 971 |
|
972 | 972 |
if (rc == BZ_OK) |
... | ... |
@@ -989,13 +991,13 @@ static int dmg_stripe_bzip(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish |
989 | 989 |
break; |
990 | 990 |
} |
991 | 991 |
|
992 |
- if (cli_writen(fd, obuf, next_write) != next_write) { |
|
992 |
+ if ((size_t)cli_writen(fd, obuf, next_write) != next_write) { |
|
993 | 993 |
cli_dbgmsg("dmg_stripe_bzip: error writing to tmpfile\n"); |
994 | 994 |
ret = CL_EWRITE; |
995 | 995 |
break; |
996 | 996 |
} |
997 | 997 |
|
998 |
- strm.next_out = obuf; |
|
998 |
+ strm.next_out = (char *)obuf; |
|
999 | 999 |
strm.avail_out = sizeof(obuf); |
1000 | 1000 |
} |
1001 | 1001 |
} while ((rc == BZ_OK) && (len > 0)); |
... | ... |
@@ -1154,7 +1156,7 @@ static int dmg_extract_xml(cli_ctx *ctx, char *dir, struct dmg_koly_block *hdr) |
1154 | 1154 |
return CL_ETMPFILE; |
1155 | 1155 |
} |
1156 | 1156 |
|
1157 |
- if (cli_writen(ofd, outdata, hdr->xmlLength) != hdr->xmlLength) { |
|
1157 |
+ if ((uint64_t)cli_writen(ofd, outdata, hdr->xmlLength) != hdr->xmlLength) { |
|
1158 | 1158 |
cli_errmsg("cli_scandmg: Not all bytes written!\n"); |
1159 | 1159 |
close(ofd); |
1160 | 1160 |
free(xmlfile); |
... | ... |
@@ -815,11 +815,7 @@ int cli_scanelf(cli_ctx *ctx) |
815 | 815 |
int cli_elfheader(fmap_t *map, struct cli_exe_info *elfinfo) |
816 | 816 |
{ |
817 | 817 |
union elf_file_hdr file_hdr; |
818 |
- struct elf_section_hdr32 *section_hdr = NULL; |
|
819 |
- struct elf_program_hdr32 *program_hdr = NULL; |
|
820 |
- uint16_t shnum, phnum, shentsize, phentsize, i; |
|
821 |
- uint64_t entry, fentry = 0, shoff, phoff; |
|
822 |
- uint8_t conv = 0, err, is64 = 0; |
|
818 |
+ uint8_t conv = 0, is64 = 0; |
|
823 | 819 |
int ret; |
824 | 820 |
|
825 | 821 |
cli_dbgmsg("in cli_elfheader\n"); |
... | ... |
@@ -711,7 +711,6 @@ static int in_iconv_u16(const m_area_t* in_m_area, iconv_t* iconv_struct, m_area |
711 | 711 |
char* input = (char*)in_m_area->buffer + in_m_area->offset; |
712 | 712 |
size_t outleft = out_m_area->length > 0 ? out_m_area->length : 0; |
713 | 713 |
char* out = (char*)out_m_area->buffer; |
714 |
- char err[128]; |
|
715 | 714 |
|
716 | 715 |
out_m_area->offset = 0; |
717 | 716 |
if(!inleft) { |
... | ... |
@@ -734,7 +733,7 @@ static int in_iconv_u16(const m_area_t* in_m_area, iconv_t* iconv_struct, m_area |
734 | 734 |
while (inleft && (outleft >= 2)) { /* iconv doesn't like inleft to be 0 */ |
735 | 735 |
const size_t outleft_last = outleft; |
736 | 736 |
assert(*iconv_struct != (iconv_t)-1); |
737 |
- rc = iconv(*iconv_struct, &input, &inleft, &out, &outleft); |
|
737 |
+ rc = iconv(*iconv_struct, (const char **)(&input), &inleft, &out, &outleft); |
|
738 | 738 |
if(rc == (size_t)-1) { |
739 | 739 |
if(errno == E2BIG) { |
740 | 740 |
/* not enough space in output buffer */ |
... | ... |
@@ -117,9 +117,12 @@ static const struct ftmap_s { |
117 | 117 |
{ "CL_TYPE_OOXML_PPT", CL_TYPE_OOXML_PPT }, |
118 | 118 |
{ "CL_TYPE_OOXML_XL", CL_TYPE_OOXML_XL }, |
119 | 119 |
{ "CL_TYPE_INTERNAL", CL_TYPE_INTERNAL }, |
120 |
+ { "CL_TYPE_XDP", CL_TYPE_XDP }, |
|
120 | 121 |
{ NULL, CL_TYPE_IGNORED } |
121 | 122 |
}; |
122 | 123 |
|
124 |
+cli_file_t cli_partitiontype(const unsigned char *buf, size_t buflen, const struct cl_engine *engine); |
|
125 |
+ |
|
123 | 126 |
cli_file_t cli_ftcode(const char *name) |
124 | 127 |
{ |
125 | 128 |
unsigned int i; |
... | ... |
@@ -266,7 +269,7 @@ cli_file_t cli_filetype2(fmap_t *map, const struct cl_engine *engine, cli_file_t |
266 | 266 |
int zi; |
267 | 267 |
|
268 | 268 |
for (zi=0; zi<32; zi++) { |
269 |
- znamep = cli_memstr(znamep, zlen, lhdr_magic, 4); |
|
269 |
+ znamep = (const unsigned char *)cli_memstr((const char *)znamep, zlen, lhdr_magic, 4); |
|
270 | 270 |
if (NULL != znamep) { |
271 | 271 |
znamep += SIZEOF_LH; |
272 | 272 |
zlen = zread - (znamep - zbuff); |
... | ... |
@@ -181,6 +181,7 @@ static const char *ftypes_int[] = { |
181 | 181 |
"0:512:4546492050415254:Disk Image - GUID Partition Table:CL_TYPE_ANY:CL_TYPE_GPT:77", |
182 | 182 |
"1:0:4552{510}504D0000:Disk Image - Apple Partition Map:CL_TYPE_ANY:CL_TYPE_APM:77", |
183 | 183 |
"0:0:7b20224d61676963223a2022434c414d4a534f4e763022:Internal properties:CL_TYPE_ANY:CL_TYPE_INTERNAL:78", |
184 |
+ "1:*:3c7864703a786470:Adobe XDP - Embedded PDF:CL_TYPE_ANY:CL_TYPE_XDP:79", |
|
184 | 185 |
NULL |
185 | 186 |
}; |
186 | 187 |
|
... | ... |
@@ -190,6 +190,8 @@ int filter_add_static(struct filter *m, const unsigned char *pattern, unsigned l |
190 | 190 |
uint32_t best = 0xffffffff; |
191 | 191 |
uint8_t best_pos = 0; |
192 | 192 |
|
193 |
+ UNUSEDPARAM(name); |
|
194 |
+ |
|
193 | 195 |
cli_perf_log_count(TRIE_ORIG_LEN, len > 8 ? 8 : len); |
194 | 196 |
/* TODO: choose best among MAXCHOICES */ |
195 | 197 |
/* cut length */ |
... | ... |
@@ -282,15 +284,6 @@ static inline unsigned char spec_ith_char(const struct char_spec *spec, unsigned |
282 | 282 |
return i; |
283 | 283 |
} |
284 | 284 |
|
285 |
-static const struct char_spec full_range = {NULL, 0,0xff,1,0}; |
|
286 |
- |
|
287 |
-static inline int spec_is_fullrange(const struct char_spec *spec0, const struct char_spec *spec1) |
|
288 |
-{ |
|
289 |
- return !memcmp(spec0, &full_range, sizeof(full_range)) && |
|
290 |
- !memcmp(spec1, &full_range, sizeof(full_range)); |
|
291 |
-} |
|
292 |
- |
|
293 |
- |
|
294 | 285 |
#ifndef MIN |
295 | 286 |
#define MIN(a,b) ((a) < (b) ? (a) : (b)) |
296 | 287 |
#endif |
... | ... |
@@ -696,43 +689,6 @@ int filter_add_acpatt(struct filter *m, const struct cli_ac_patt *pat) |
696 | 696 |
return j+2; |
697 | 697 |
} |
698 | 698 |
|
699 |
-static const struct match_len_info { |
|
700 |
- uint8_t shortest; |
|
701 |
- uint8_t longest; |
|
702 |
-} match_len[256] = { |
|
703 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9}, |
|
704 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{6,9}, |
|
705 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9}, |
|
706 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{7,9}, |
|
707 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9}, |
|
708 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{6,9}, |
|
709 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9}, |
|
710 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{8,9}, |
|
711 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9}, |
|
712 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{6,9}, |
|
713 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9}, |
|
714 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{7,9}, |
|
715 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9}, |
|
716 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{6,9}, |
|
717 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9}, |
|
718 |
- {2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{9,9}, |
|
719 |
- {2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{5,8}, |
|
720 |
- {2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{6,8}, |
|
721 |
- {2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{5,8}, |
|
722 |
- {2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{7,8}, |
|
723 |
- {2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{5,8}, |
|
724 |
- {2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{6,8}, |
|
725 |
- {2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{5,8}, |
|
726 |
- {2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{8,8}, |
|
727 |
- {2,7},{3,7},{2,7},{4,7},{2,7},{3,7},{2,7},{5,7}, |
|
728 |
- {2,7},{3,7},{2,7},{4,7},{2,7},{3,7},{2,7},{6,7}, |
|
729 |
- {2,7},{3,7},{2,7},{4,7},{2,7},{3,7},{2,7},{5,7}, |
|
730 |
- {2,7},{3,7},{2,7},{4,7},{2,7},{3,7},{2,7},{7,7}, |
|
731 |
- {2,6},{3,6},{2,6},{4,6},{2,6},{3,6},{2,6},{5,6}, |
|
732 |
- {2,6},{3,6},{2,6},{4,6},{2,6},{3,6},{2,6},{6,6}, |
|
733 |
- {2,5},{3,5},{2,5},{4,5},{2,5},{3,5},{2,5},{5,5}, |
|
734 |
- {2,4},{3,4},{2,4},{4,4},{2,3},{3,3},{2,2},{0,0} |
|
735 |
-}; |
|
736 | 699 |
/* state 11110011 means that we may have a match of length min 4, max 5 */ |
737 | 700 |
|
738 | 701 |
__hot__ int filter_search_ext(const struct filter *m, const unsigned char *data, unsigned long len, struct filter_match_info *inf) |
... | ... |
@@ -62,12 +62,8 @@ static off_t pread_cb(void *handle, void *buf, size_t count, off_t offset) |
62 | 62 |
|
63 | 63 |
|
64 | 64 |
fmap_t *fmap_check_empty(int fd, off_t offset, size_t len, int *empty) { |
65 |
- unsigned int pages, mapsz, hdrsz; |
|
66 |
- unsigned short dumb = 1; |
|
67 |
- int pgsz = cli_getpagesize(); |
|
68 | 65 |
STATBUF st; |
69 | 66 |
fmap_t *m; |
70 |
- void *handle = (void*)(ssize_t)fd; |
|
71 | 67 |
|
72 | 68 |
*empty = 0; |
73 | 69 |
if(FSTAT(fd, &st)) { |
... | ... |
@@ -215,7 +211,7 @@ extern cl_fmap_t *cl_fmap_open_handle(void *handle, size_t offset, size_t len, |
215 | 215 |
cl_fmap_t *m; |
216 | 216 |
int pgsz = cli_getpagesize(); |
217 | 217 |
|
218 |
- if(offset < 0 || offset != fmap_align_to(offset, pgsz)) { |
|
218 |
+ if((off_t)offset < 0 || offset != fmap_align_to(offset, pgsz)) { |
|
219 | 219 |
cli_warnmsg("fmap: attempted mapping with unaligned offset\n"); |
220 | 220 |
return NULL; |
221 | 221 |
} |
... | ... |
@@ -651,8 +647,6 @@ static void mem_unneed_off(fmap_t *m, size_t at, size_t len); |
651 | 651 |
static const void *mem_need_offstr(fmap_t *m, size_t at, size_t len_hint); |
652 | 652 |
static const void *mem_gets(fmap_t *m, char *dst, size_t *at, size_t max_len); |
653 | 653 |
|
654 |
-static void unmap_none(fmap_t *m) {} |
|
655 |
- |
|
656 | 654 |
extern cl_fmap_t *cl_fmap_open_memory(const void *start, size_t len) |
657 | 655 |
{ |
658 | 656 |
int pgsz = cli_getpagesize(); |
... | ... |
@@ -676,6 +670,7 @@ extern cl_fmap_t *cl_fmap_open_memory(const void *start, size_t len) |
676 | 676 |
|
677 | 677 |
|
678 | 678 |
static const void *mem_need(fmap_t *m, size_t at, size_t len, int lock) { /* WIN32 */ |
679 |
+ UNUSEDPARAM(lock); |
|
679 | 680 |
if(!len) { |
680 | 681 |
return NULL; |
681 | 682 |
} |
... | ... |
@@ -687,7 +682,12 @@ static const void *mem_need(fmap_t *m, size_t at, size_t len, int lock) { /* WIN |
687 | 687 |
return (void *)((char *)m->data + at); |
688 | 688 |
} |
689 | 689 |
|
690 |
-static void mem_unneed_off(fmap_t *m, size_t at, size_t len) {} |
|
690 |
+static void mem_unneed_off(fmap_t *m, size_t at, size_t len) |
|
691 |
+{ |
|
692 |
+ UNUSEDPARAM(m); |
|
693 |
+ UNUSEDPARAM(at); |
|
694 |
+ UNUSEDPARAM(len); |
|
695 |
+} |
|
691 | 696 |
|
692 | 697 |
static const void *mem_need_offstr(fmap_t *m, size_t at, size_t len_hint) { |
693 | 698 |
char *ptr = (char *)m->data + at; |
... | ... |
@@ -759,7 +759,7 @@ int fmap_dump_to_file(fmap_t *map, const char *tmpdir, char **outname, int *outf |
759 | 759 |
b = fmap_need_off_once_len(map, pos, BUFSIZ, &len); |
760 | 760 |
pos += len; |
761 | 761 |
if(b && (len > 0)) { |
762 |
- if (cli_writen(tmpfd, b, len) != len) { |
|
762 |
+ if ((size_t)cli_writen(tmpfd, b, len) != len) { |
|
763 | 763 |
cli_warnmsg("fmap_dump_to_file: write failed to %s!\n", tmpname); |
764 | 764 |
close(tmpfd); |
765 | 765 |
unlink(tmpname); |
... | ... |
@@ -780,7 +780,7 @@ int fmap_dump_to_file(fmap_t *map, const char *tmpdir, char **outname, int *outf |
780 | 780 |
|
781 | 781 |
int fmap_fd(fmap_t *m) |
782 | 782 |
{ |
783 |
- int fd, ret; |
|
783 |
+ int fd; |
|
784 | 784 |
if (!m->handle_is_fd) |
785 | 785 |
return -1; |
786 | 786 |
fd = (int)(ssize_t)m->handle; |
... | ... |
@@ -78,22 +78,22 @@ size_t gpt_detect_size(fmap_t *map) |
78 | 78 |
|
79 | 79 |
buff = (unsigned char*)fmap_need_off_once(map, 512, 8); |
80 | 80 |
if (!buff) return 0; |
81 |
- if (0 == strncmp(buff, GPT_SIGNATURE_STR, 8)) |
|
81 |
+ if (0 == strncmp((const char *)buff, GPT_SIGNATURE_STR, 8)) |
|
82 | 82 |
return 512; |
83 | 83 |
|
84 | 84 |
buff = (unsigned char*)fmap_need_off_once(map, 1024, 8); |
85 | 85 |
if (!buff) return 0; |
86 |
- if (0 == strncmp(buff, GPT_SIGNATURE_STR, 8)) |
|
86 |
+ if (0 == strncmp((const char *)buff, GPT_SIGNATURE_STR, 8)) |
|
87 | 87 |
return 1024; |
88 | 88 |
|
89 | 89 |
buff = (unsigned char*)fmap_need_off_once(map, 2048, 8); |
90 | 90 |
if (!buff) return 0; |
91 |
- if (0 == strncmp(buff, GPT_SIGNATURE_STR, 8)) |
|
91 |
+ if (0 == strncmp((const char *)buff, GPT_SIGNATURE_STR, 8)) |
|
92 | 92 |
return 2048; |
93 | 93 |
|
94 | 94 |
buff = (unsigned char*)fmap_need_off_once(map, 4096, 8); |
95 | 95 |
if (!buff) return 0; |
96 |
- if (0 == strncmp(buff, GPT_SIGNATURE_STR, 8)) |
|
96 |
+ if (0 == strncmp((const char *)buff, GPT_SIGNATURE_STR, 8)) |
|
97 | 97 |
return 4096; |
98 | 98 |
|
99 | 99 |
return 0; |
... | ... |
@@ -571,6 +571,8 @@ static void gpt_printSectors(cli_ctx *ctx, size_t sectorsize) |
571 | 571 |
gpt_parsemsg("%llu-%llu: Secondary GPT Partition Table\n", shdr.tableStartLBA, stableLastLBA); |
572 | 572 |
gpt_parsemsg("%llu: Secondary GPT Header\n", phdr.backupLBA); |
573 | 573 |
#else |
574 |
+ UNUSEDPARAM(ctx); |
|
575 |
+ UNUSEDPARAM(sectorsize); |
|
574 | 576 |
return; |
575 | 577 |
#endif |
576 | 578 |
} |
... | ... |
@@ -931,7 +931,7 @@ int cli_map_removekey(struct cli_map *m, const void *key, int32_t keysize) |
931 | 931 |
int cli_map_setvalue(struct cli_map *m, const void* value, int32_t valuesize) |
932 | 932 |
{ |
933 | 933 |
if ((m->valuesize && m->valuesize != valuesize) |
934 |
- || m->last_insert >= m->nvalues || m->last_insert < 0) |
|
934 |
+ || (uint32_t)(m->last_insert) >= m->nvalues || m->last_insert < 0) |
|
935 | 935 |
return -CL_EARG; |
936 | 936 |
if (m->valuesize) { |
937 | 937 |
memcpy((char*)m->u.sized_values + m->last_insert * m->valuesize, |
... | ... |
@@ -967,14 +967,14 @@ int cli_map_getvalue_size(struct cli_map *m) |
967 | 967 |
{ |
968 | 968 |
if (m->valuesize) |
969 | 969 |
return m->valuesize; |
970 |
- if (m->last_find < 0 || m->last_find >= m->nvalues) |
|
970 |
+ if (m->last_find < 0 || (uint32_t)(m->last_find) >= m->nvalues) |
|
971 | 971 |
return -CL_EARG; |
972 | 972 |
return m->u.unsized_values[m->last_find].valuesize; |
973 | 973 |
} |
974 | 974 |
|
975 | 975 |
void* cli_map_getvalue(struct cli_map *m) |
976 | 976 |
{ |
977 |
- if (m->last_find < 0 || m->last_find >= m->nvalues) |
|
977 |
+ if (m->last_find < 0 || (uint32_t)(m->last_find) >= m->nvalues) |
|
978 | 978 |
return NULL; |
979 | 979 |
if (m->valuesize) |
980 | 980 |
return (char*)m->u.sized_values + m->last_find*m->valuesize; |
... | ... |
@@ -300,6 +300,8 @@ static int hfsplus_scanfile(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, hfsHea |
300 | 300 |
uint32_t outputBlocks = 0; |
301 | 301 |
uint8_t ext; |
302 | 302 |
|
303 |
+ UNUSEDPARAM(extHeader); |
|
304 |
+ |
|
303 | 305 |
/* bad record checks */ |
304 | 306 |
if (!fork || (fork->logicalSize == 0) || (fork->totalBlocks == 0)) { |
305 | 307 |
cli_dbgmsg("hfsplus_dumpfile: Empty file.\n"); |
... | ... |
@@ -381,7 +383,7 @@ static int hfsplus_scanfile(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, hfsHea |
381 | 381 |
break; |
382 | 382 |
} |
383 | 383 |
written = cli_writen(ofd, mPtr, to_write); |
384 |
- if (written != to_write) { |
|
384 |
+ if ((size_t)written != to_write) { |
|
385 | 385 |
cli_errmsg("hfsplus_dumpfile: write error\n"); |
386 | 386 |
ret = CL_EWRITE; |
387 | 387 |
break; |
... | ... |
@@ -425,6 +427,8 @@ static int hfsplus_validate_catalog(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader |
425 | 425 |
{ |
426 | 426 |
hfsPlusForkData *catFork; |
427 | 427 |
|
428 |
+ UNUSEDPARAM(ctx); |
|
429 |
+ |
|
428 | 430 |
catFork = &(volHeader->catalogFile); |
429 | 431 |
if (catFork->totalBlocks >= volHeader->totalBlocks) { |
430 | 432 |
cli_dbgmsg("hfsplus_getnodelimit: catFork totalBlocks too large!\n"); |
... | ... |
@@ -446,13 +450,15 @@ static int hfsplus_validate_catalog(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader |
446 | 446 |
static int hfsplus_fetch_node (cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, hfsHeaderRecord *catHeader, |
447 | 447 |
hfsHeaderRecord *extHeader, uint32_t node, uint8_t *buff) |
448 | 448 |
{ |
449 |
- int foundBlock = 0, ret = CL_CLEAN; |
|
449 |
+ int foundBlock = 0; |
|
450 | 450 |
uint64_t catalogOffset; |
451 | 451 |
uint32_t fetchBlock, fetchStart; |
452 | 452 |
uint32_t extentNum = 0, realFileBlock; |
453 | 453 |
size_t fileOffset = 0; |
454 | 454 |
hfsPlusForkData *catFork; |
455 | 455 |
|
456 |
+ UNUSEDPARAM(extHeader); |
|
457 |
+ |
|
456 | 458 |
/* Make sure node is in range */ |
457 | 459 |
if (node >= catHeader->totalNodes) { |
458 | 460 |
cli_dbgmsg("hfsplus_fetch_node: invalid node number " STDu32 "\n", node); |
... | ... |
@@ -535,15 +541,6 @@ static int hfsplus_fetch_node (cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, hfs |
535 | 535 |
} |
536 | 536 |
|
537 | 537 |
/* Given the catalog and other details, scan all the volume contents */ |
538 |
-static int hfsplus_scan_node(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, hfsHeaderRecord *catHeader, |
|
539 |
- hfsHeaderRecord *extHeader, const char *dirname, uint8_t *nodeBuf) |
|
540 |
-{ |
|
541 |
- int ret = CL_CLEAN; |
|
542 |
- |
|
543 |
- return ret; |
|
544 |
-} |
|
545 |
- |
|
546 |
-/* Given the catalog and other details, scan all the volume contents */ |
|
547 | 538 |
static int hfsplus_walk_catalog(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, hfsHeaderRecord *catHeader, |
548 | 539 |
hfsHeaderRecord *extHeader, const char *dirname) |
549 | 540 |
{ |
... | ... |
@@ -62,6 +62,8 @@ |
62 | 62 |
#include "hostid.h" |
63 | 63 |
#include "libclamav/others.h" |
64 | 64 |
|
65 |
+struct device *get_device_entry(struct device *devices, size_t *ndevices, const char *name); |
|
66 |
+ |
|
65 | 67 |
struct device *get_device_entry(struct device *devices, size_t *ndevices, const char *name) |
66 | 68 |
{ |
67 | 69 |
void *p; |
... | ... |
@@ -256,7 +256,7 @@ int cli_scanishield_msi(cli_ctx *ctx, off_t off) { |
256 | 256 |
while(csize) { |
257 | 257 |
uint8_t buf2[BUFSIZ]; |
258 | 258 |
z.avail_in = MIN(csize, sizeof(buf2)); |
259 |
- if(fmap_readn(map, buf2, off, z.avail_in) != z.avail_in) { |
|
259 |
+ if((uInt)fmap_readn(map, buf2, off, z.avail_in) != z.avail_in) { |
|
260 | 260 |
cli_dbgmsg("ishield-msi: premature EOS or read fail\n"); |
261 | 261 |
break; |
262 | 262 |
} |
... | ... |
@@ -373,7 +373,7 @@ int cli_scanishield(cli_ctx *ctx, off_t off, size_t sz) { |
373 | 373 |
if(fsize < 0 || fsize == LONG_MAX || |
374 | 374 |
!*strsz || !eostr || eostr == strsz || *eostr || |
375 | 375 |
(unsigned long)fsize >= sz || |
376 |
- data - fname >= sz - fsize |
|
376 |
+ (size_t)(data - fname) >= sz - fsize |
|
377 | 377 |
) break; |
378 | 378 |
|
379 | 379 |
cli_dbgmsg("ishield: @%lx found file %s (%s) - version %s - size %lu\n", (unsigned long int) coff, fname, path, version, (unsigned long int) fsize); |
... | ... |
@@ -70,7 +70,7 @@ static int iso_scan_file(const iso9660_t *iso, unsigned int block, unsigned int |
70 | 70 |
ret = CL_EFORMAT; |
71 | 71 |
break; |
72 | 72 |
} |
73 |
- if(cli_writen(fd, buf, todo) != todo) { |
|
73 |
+ if((unsigned int)cli_writen(fd, buf, todo) != todo) { |
|
74 | 74 |
cli_warnmsg("iso_scan_file: Can't write to file %s\n", tmpf); |
75 | 75 |
ret = CL_EWRITE; |
76 | 76 |
break; |
... | ... |
@@ -65,7 +65,7 @@ int json_object_object_get_ex(struct json_object *obj, const char *key, struct j |
65 | 65 |
#define nojson_func cli_dbgmsg |
66 | 66 |
|
67 | 67 |
/* internal functions */ |
68 |
-int cli_json_nojson(); |
|
68 |
+int cli_json_nojson(void); |
|
69 | 69 |
|
70 | 70 |
int cli_jsonnull_nojson(const char* key); |
71 | 71 |
int cli_jsonstr_nojson(const char* key, const char* s); |
... | ... |
@@ -199,6 +199,10 @@ CLAMAV_PRIVATE { |
199 | 199 |
cli_bytecode_debug_printsrc; |
200 | 200 |
cli_bytecode_printversion; |
201 | 201 |
cli_bytecode_describe; |
202 |
+ cli_bytetype_describe; |
|
203 |
+ cli_bytevalue_describe; |
|
204 |
+ cli_byteinst_describe; |
|
205 |
+ cli_bytefunc_describe; |
|
202 | 206 |
cli_printcxxver; |
203 | 207 |
cli_detect_environment; |
204 | 208 |
cli_disasm_one; |
... | ... |
@@ -28,9 +28,9 @@ |
28 | 28 |
#include "lzma_iface.h" |
29 | 29 |
|
30 | 30 |
void *__lzma_wrap_alloc(void *unused, size_t size) { |
31 |
+ UNUSEDPARAM(unused); |
|
31 | 32 |
if(!size || size > CLI_MAX_ALLOCATION) |
32 | 33 |
return NULL; |
33 |
- unused = unused; |
|
34 | 34 |
if(!size || size > CLI_MAX_ALLOCATION) { |
35 | 35 |
cli_dbgmsg("lzma_wrap_alloc(): Attempt to allocate %lu bytes.\n", (unsigned long int) size); |
36 | 36 |
return NULL; |
... | ... |
@@ -39,7 +39,7 @@ void *__lzma_wrap_alloc(void *unused, size_t size) { |
39 | 39 |
return cli_malloc(size); |
40 | 40 |
} |
41 | 41 |
void __lzma_wrap_free(void *unused, void *freeme) { |
42 |
- unused = unused; |
|
42 |
+ UNUSEDPARAM(unused); |
|
43 | 43 |
free(freeme); |
44 | 44 |
} |
45 | 45 |
static ISzAlloc g_Alloc = { __lzma_wrap_alloc, __lzma_wrap_free }; |
... | ... |
@@ -293,10 +293,8 @@ static int ac_maketrans(struct cli_matcher *root) |
293 | 293 |
{ |
294 | 294 |
struct bfs_list *bfs = NULL, *bfs_last = NULL; |
295 | 295 |
struct cli_ac_node *ac_root = root->ac_root, *child, *node, *fail; |
296 |
- struct cli_ac_patt *patt; |
|
297 | 296 |
int i, ret; |
298 | 297 |
|
299 |
- |
|
300 | 298 |
for(i = 0; i < 256; i++) { |
301 | 299 |
node = ac_root->trans[i]; |
302 | 300 |
if(!node) { |
... | ... |
@@ -911,6 +909,7 @@ int cli_ac_initdata(struct cli_ac_data *data, uint32_t partsigs, uint32_t lsigs, |
911 | 911 |
{ |
912 | 912 |
unsigned int i, j; |
913 | 913 |
|
914 |
+ UNUSEDPARAM(tracklen); |
|
914 | 915 |
|
915 | 916 |
if(!data) { |
916 | 917 |
cli_errmsg("cli_ac_init: data == NULL\n"); |
... | ... |
@@ -1360,7 +1359,7 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v |
1360 | 1360 |
if(res) { |
1361 | 1361 |
newres = (struct cli_ac_result *) malloc(sizeof(struct cli_ac_result)); |
1362 | 1362 |
if(!newres) { |
1363 |
- cli_errmsg("cli_ac_scanbuff: Can't allocate memory for newres %u\n", sizeof(struct cli_ac_result)); |
|
1363 |
+ cli_errmsg("cli_ac_scanbuff: Can't allocate memory for newres %lu\n", sizeof(struct cli_ac_result)); |
|
1364 | 1364 |
return CL_EMEM; |
1365 | 1365 |
} |
1366 | 1366 |
newres->virname = pt->virname; |
... | ... |
@@ -1413,7 +1412,7 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v |
1413 | 1413 |
if(res) { |
1414 | 1414 |
newres = (struct cli_ac_result *) malloc(sizeof(struct cli_ac_result)); |
1415 | 1415 |
if(!newres) { |
1416 |
- cli_errmsg("cli_ac_scanbuff: Can't allocate memory for newres %u\n", sizeof(struct cli_ac_result)); |
|
1416 |
+ cli_errmsg("cli_ac_scanbuff: Can't allocate memory for newres %lu\n", sizeof(struct cli_ac_result)); |
|
1417 | 1417 |
return CL_EMEM; |
1418 | 1418 |
} |
1419 | 1419 |
newres->virname = pt->virname; |
... | ... |
@@ -72,8 +72,19 @@ static inline int PERF_LOG_TRIES(int8_t acmode, int8_t bm_called, int32_t length |
72 | 72 |
} |
73 | 73 |
|
74 | 74 |
#else |
75 |
-static inline void PERF_LOG_FILTER(int32_t pos, uint32_t length, int8_t trie) {} |
|
76 |
-static inline int PERF_LOG_TRIES(int8_t acmode, int8_t bm_called, int32_t length) { return 0; } |
|
75 |
+static inline void PERF_LOG_FILTER(int32_t pos, uint32_t length, int8_t trie) { |
|
76 |
+ UNUSEDPARAM(pos); |
|
77 |
+ UNUSEDPARAM(length); |
|
78 |
+ UNUSEDPARAM(trie); |
|
79 |
+} |
|
80 |
+ |
|
81 |
+static inline int PERF_LOG_TRIES(int8_t acmode, int8_t bm_called, int32_t length) { |
|
82 |
+ UNUSEDPARAM(acmode); |
|
83 |
+ UNUSEDPARAM(bm_called); |
|
84 |
+ UNUSEDPARAM(length); |
|
85 |
+ |
|
86 |
+ return 0; |
|
87 |
+} |
|
77 | 88 |
#endif |
78 | 89 |
|
79 | 90 |
static inline int matcher_run(const struct cli_matcher *root, |
... | ... |
@@ -97,6 +108,8 @@ static inline int matcher_run(const struct cli_matcher *root, |
97 | 97 |
const unsigned char* orig_buffer; |
98 | 98 |
unsigned int viruses_found = 0; |
99 | 99 |
|
100 |
+ UNUSEDPARAM(map); |
|
101 |
+ |
|
100 | 102 |
if (root->filter) { |
101 | 103 |
if(filter_search_ext(root->filter, buffer, length, &info) == -1) { |
102 | 104 |
/* for safety always scan last maxpatlen bytes */ |
... | ... |
@@ -529,7 +542,7 @@ int cli_checkfp(unsigned char *digest, size_t size, cli_ctx *ctx) |
529 | 529 |
} |
530 | 530 |
|
531 | 531 |
if (ctx->engine->cb_hash) |
532 |
- ctx->engine->cb_hash(fmap_fd(*ctx->fmap), size, md5, cli_get_last_virus(ctx), ctx->cb_ctx); |
|
532 |
+ ctx->engine->cb_hash(fmap_fd(*ctx->fmap), size, (const unsigned char *)md5, cli_get_last_virus(ctx), ctx->cb_ctx); |
|
533 | 533 |
|
534 | 534 |
if (ctx->engine->cb_stats_add_sample) |
535 | 535 |
ctx->engine->cb_stats_add_sample(cli_get_last_virus(ctx), digest, size, §ions, ctx->engine->stats_data); |
... | ... |
@@ -925,11 +938,11 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli |
925 | 925 |
uint32_t data_len = bytes - maxpatlen * (offset!=0); |
926 | 926 |
|
927 | 927 |
if(compute_hash[CLI_HASH_MD5]) |
928 |
- cl_update_hash(md5ctx, data, data_len); |
|
928 |
+ cl_update_hash(md5ctx, (void *)data, data_len); |
|
929 | 929 |
if(compute_hash[CLI_HASH_SHA1]) |
930 |
- cl_update_hash(sha1ctx, data, data_len); |
|
930 |
+ cl_update_hash(sha1ctx, (void *)data, data_len); |
|
931 | 931 |
if(compute_hash[CLI_HASH_SHA256]) |
932 |
- cl_update_hash(sha256ctx, data, data_len); |
|
932 |
+ cl_update_hash(sha256ctx, (void *)data, data_len); |
|
933 | 933 |
} |
934 | 934 |
} |
935 | 935 |
|
... | ... |
@@ -1023,7 +1036,7 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli |
1023 | 1023 |
|
1024 | 1024 |
if(troot) { |
1025 | 1025 |
if(ret != CL_VIRUS || SCAN_ALL) |
1026 |
- ret = cli_lsig_eval(ctx, troot, &tdata, &info, refhash); |
|
1026 |
+ ret = cli_lsig_eval(ctx, troot, &tdata, &info, (const char *)refhash); |
|
1027 | 1027 |
if (ret == CL_VIRUS) |
1028 | 1028 |
viruses_found++; |
1029 | 1029 |
|
... | ... |
@@ -1034,7 +1047,7 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli |
1034 | 1034 |
|
1035 | 1035 |
if(groot) { |
1036 | 1036 |
if(ret != CL_VIRUS || SCAN_ALL) |
1037 |
- ret = cli_lsig_eval(ctx, groot, &gdata, &info, refhash); |
|
1037 |
+ ret = cli_lsig_eval(ctx, groot, &gdata, &info, (const char *)refhash); |
|
1038 | 1038 |
cli_ac_freedata(&gdata); |
1039 | 1039 |
} |
1040 | 1040 |
|
... | ... |
@@ -18,8 +18,6 @@ |
18 | 18 |
* MA 02110-1301, USA. |
19 | 19 |
*/ |
20 | 20 |
|
21 |
-static char const rcsid[] = "$Id: mbox.c,v 1.381 2007/02/15 12:26:44 njh Exp $"; |
|
22 |
- |
|
23 | 21 |
#if HAVE_CONFIG_H |
24 | 22 |
#include "clamav-config.h" |
25 | 23 |
#endif |
... | ... |
@@ -2144,7 +2142,7 @@ boundaryStart(const char *line, const char *boundary) |
2144 | 2144 |
|
2145 | 2145 |
newline = strdup(line); |
2146 | 2146 |
if (!(newline)) |
2147 |
- newline = line; |
|
2147 |
+ newline = (char *)line; |
|
2148 | 2148 |
|
2149 | 2149 |
if (newline != line && strlen(newline)) { |
2150 | 2150 |
char *p; |
... | ... |
@@ -2266,7 +2264,8 @@ boundaryEnd(const char *line, const char *boundary) |
2266 | 2266 |
|
2267 | 2267 |
p = newline = strdup(line); |
2268 | 2268 |
if (!(newline)) { |
2269 |
- p = newline = line; |
|
2269 |
+ p = (char *)line; |
|
2270 |
+ newline = (char *)line; |
|
2270 | 2271 |
} |
2271 | 2272 |
|
2272 | 2273 |
if (newline != line && strlen(newline)) { |
... | ... |
@@ -2508,7 +2507,7 @@ parseMimeHeader(message *m, const char *cmd, const table_t *rfc821Table, const c |
2508 | 2508 |
|
2509 | 2509 |
buf = cli_malloc(strlen(ptr) + 1); |
2510 | 2510 |
if(buf == NULL) { |
2511 |
- cli_errmsg("parseMimeHeader: Unable to allocate memory for buf %u\n", strlen(ptr) + 1); |
|
2511 |
+ cli_errmsg("parseMimeHeader: Unable to allocate memory for buf %lu\n", strlen(ptr) + 1); |
|
2512 | 2512 |
if(copy) |
2513 | 2513 |
free(copy); |
2514 | 2514 |
return -1; |
... | ... |
@@ -2617,7 +2616,7 @@ parseMimeHeader(message *m, const char *cmd, const table_t *rfc821Table, const c |
2617 | 2617 |
case CONTENT_DISPOSITION: |
2618 | 2618 |
buf = cli_malloc(strlen(ptr) + 1); |
2619 | 2619 |
if(buf == NULL) { |
2620 |
- cli_errmsg("parseMimeHeader: Unable to allocate memory for buf %u\n", strlen(ptr) + 1); |
|
2620 |
+ cli_errmsg("parseMimeHeader: Unable to allocate memory for buf %lu\n", strlen(ptr) + 1); |
|
2621 | 2621 |
if(copy) |
2622 | 2622 |
free(copy); |
2623 | 2623 |
return -1; |
... | ... |
@@ -2695,7 +2694,7 @@ rfc822comments(const char *in, char *out) |
2695 | 2695 |
if(out == NULL) { |
2696 | 2696 |
out = cli_malloc(strlen(in) + 1); |
2697 | 2697 |
if(out == NULL) { |
2698 |
- cli_errmsg("rfc822comments: Unable to allocate memory for out %u\n", strlen(in) + 1); |
|
2698 |
+ cli_errmsg("rfc822comments: Unable to allocate memory for out %lu\n", strlen(in) + 1); |
|
2699 | 2699 |
return NULL; |
2700 | 2700 |
} |
2701 | 2701 |
} |
... | ... |
@@ -2763,7 +2762,7 @@ rfc2047(const char *in) |
2763 | 2763 |
out = cli_malloc(strlen(in) + 1); |
2764 | 2764 |
|
2765 | 2765 |
if(out == NULL) { |
2766 |
- cli_errmsg("rfc2047: Unable to allocate memory for out %u\n", strlen(in) + 1); |
|
2766 |
+ cli_errmsg("rfc2047: Unable to allocate memory for out %lu\n", strlen(in) + 1); |
|
2767 | 2767 |
return NULL; |
2768 | 2768 |
} |
2769 | 2769 |
|
... | ... |
@@ -3197,6 +3196,8 @@ checkURLs(message *mainMessage, mbox_ctx *mctx, mbox_status *rc, int is_html) |
3197 | 3197 |
blob *b; |
3198 | 3198 |
tag_arguments_t hrefs; |
3199 | 3199 |
|
3200 |
+ UNUSEDPARAM(is_html); |
|
3201 |
+ |
|
3200 | 3202 |
if(*rc == VIRUS) |
3201 | 3203 |
return; |
3202 | 3204 |
|
... | ... |
@@ -67,7 +67,6 @@ enum MBR_STATE { |
67 | 67 |
|
68 | 68 |
static int mbr_scanextprtn(cli_ctx *ctx, unsigned *prtncount, off_t extlba, |
69 | 69 |
size_t extlbasize, size_t sectorsize); |
70 |
-static void mbr_printbr(struct mbr_boot_record *record); |
|
71 | 70 |
static int mbr_check_mbr(struct mbr_boot_record *record, size_t maplen, size_t sectorsize); |
72 | 71 |
static int mbr_check_ebr(struct mbr_boot_record *record); |
73 | 72 |
static int mbr_primary_prtn_intxn(cli_ctx *ctx, struct mbr_boot_record mbr, size_t sectorsize); |
... | ... |
@@ -425,24 +424,6 @@ void mbr_convert_to_host(struct mbr_boot_record *record) |
425 | 425 |
record->signature = be16_to_host(record->signature); |
426 | 426 |
} |
427 | 427 |
|
428 |
-static void mbr_printbr(struct mbr_boot_record *record) |
|
429 |
-{ |
|
430 |
- unsigned i; |
|
431 |
- |
|
432 |
- cli_dbgmsg("signature: %x\n", record->signature); |
|
433 |
- for (i = 0; i < MBR_MAX_PARTITION_ENTRIES; ++i) { |
|
434 |
- cli_dbgmsg("entry %u:\n", i); |
|
435 |
- cli_dbgmsg("\tstatus: %x\n", record->entries[i].status); |
|
436 |
- cli_dbgmsg("\tfirstCHS: [%u, %u, %u]\n", record->entries[i].firstCHS[0], |
|
437 |
- record->entries[i].firstCHS[1], record->entries[i].firstCHS[2]); |
|
438 |
- cli_dbgmsg("\ttype: %x\n", record->entries[i].type); |
|
439 |
- cli_dbgmsg("\tlastCHS: [%u, %u, %u]\n", record->entries[i].lastCHS[0], |
|
440 |
- record->entries[i].lastCHS[1], record->entries[i].lastCHS[2]); |
|
441 |
- cli_dbgmsg("\tfirstLBA: %u\n", record->entries[i].firstLBA); |
|
442 |
- cli_dbgmsg("\tnumLBA: %u\n", record->entries[i].numLBA); |
|
443 |
- } |
|
444 |
-} |
|
445 |
- |
|
446 | 428 |
static int mbr_check_mbr(struct mbr_boot_record *record, size_t maplen, size_t sectorsize) |
447 | 429 |
{ |
448 | 430 |
unsigned i = 0; |
... | ... |
@@ -58,7 +58,7 @@ |
58 | 58 |
#ifdef DEBUGMPOOL |
59 | 59 |
#define spam(...) cli_warnmsg( __VA_ARGS__) |
60 | 60 |
#else |
61 |
-static inline void spam(const char *fmt, ...) { fmt = fmt; } /* gcc STFU */ |
|
61 |
+static inline void spam(const char *fmt, ...) { UNUSEDPARAM(fmt); } |
|
62 | 62 |
#endif |
63 | 63 |
|
64 | 64 |
#include "mpool.h" |
... | ... |
@@ -127,7 +127,7 @@ static int mszip_read_input(struct mszip_stream *zip) { |
127 | 127 |
int nread = zip->read_cb(zip->file, zip->inbuf, (int)zip->inbuf_size); |
128 | 128 |
if (nread < 0) { |
129 | 129 |
if (zip->file->error == CL_BREAK) { |
130 |
- if (nread == zip->last) { |
|
130 |
+ if ((unsigned int)nread == zip->last) { |
|
131 | 131 |
cli_dbgmsg("mszip_read_input: Two consecutive CL_BREAKs reached.\n"); |
132 | 132 |
return CL_BREAK; |
133 | 133 |
} |
... | ... |
@@ -34,61 +34,6 @@ |
34 | 34 |
#include "bzlib_private.h" |
35 | 35 |
#include "others.h" |
36 | 36 |
|
37 |
-static const Int32 BZ2_rNums[512] = { |
|
38 |
- 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, |
|
39 |
- 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, |
|
40 |
- 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, |
|
41 |
- 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, |
|
42 |
- 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, |
|
43 |
- 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, |
|
44 |
- 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, |
|
45 |
- 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, |
|
46 |
- 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, |
|
47 |
- 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, |
|
48 |
- 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, |
|
49 |
- 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, |
|
50 |
- 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, |
|
51 |
- 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, |
|
52 |
- 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, |
|
53 |
- 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, |
|
54 |
- 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, |
|
55 |
- 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, |
|
56 |
- 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, |
|
57 |
- 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, |
|
58 |
- 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, |
|
59 |
- 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, |
|
60 |
- 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, |
|
61 |
- 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, |
|
62 |
- 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, |
|
63 |
- 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, |
|
64 |
- 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, |
|
65 |
- 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, |
|
66 |
- 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, |
|
67 |
- 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, |
|
68 |
- 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, |
|
69 |
- 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, |
|
70 |
- 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, |
|
71 |
- 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, |
|
72 |
- 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, |
|
73 |
- 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, |
|
74 |
- 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, |
|
75 |
- 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, |
|
76 |
- 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, |
|
77 |
- 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, |
|
78 |
- 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, |
|
79 |
- 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, |
|
80 |
- 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, |
|
81 |
- 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, |
|
82 |
- 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, |
|
83 |
- 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, |
|
84 |
- 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, |
|
85 |
- 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, |
|
86 |
- 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, |
|
87 |
- 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, |
|
88 |
- 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, |
|
89 |
- 936, 638 |
|
90 |
-}; |
|
91 |
- |
|
92 | 37 |
/*---------------------------------------------------*/ |
93 | 38 |
static |
94 | 39 |
void makeMaps_d ( DState* s ) |
... | ... |
@@ -1045,14 +990,16 @@ int bz_config_ok ( void ) |
1045 | 1045 |
static |
1046 | 1046 |
void* default_bzalloc ( void* opaque, Int32 items, Int32 size ) |
1047 | 1047 |
{ |
1048 |
- void* v = cli_malloc ( items * size ); |
|
1049 |
- return v; |
|
1048 |
+ void* v = cli_malloc ( items * size ); |
|
1049 |
+ UNUSEDPARAM(opaque); |
|
1050 |
+ return v; |
|
1050 | 1051 |
} |
1051 | 1052 |
|
1052 | 1053 |
static |
1053 | 1054 |
void default_bzfree ( void* opaque, void* addr ) |
1054 | 1055 |
{ |
1055 |
- if (addr != NULL) free ( addr ); |
|
1056 |
+ UNUSEDPARAM(opaque); |
|
1057 |
+ if (addr != NULL) free ( addr ); |
|
1056 | 1058 |
} |
1057 | 1059 |
|
1058 | 1060 |
/*---------------------------------------------------*/ |
... | ... |
@@ -187,7 +187,7 @@ static int nsis_decomp(struct nsis_st *n) { |
187 | 187 |
static int nsis_unpack_next(struct nsis_st *n, cli_ctx *ctx) { |
188 | 188 |
const unsigned char *ibuf; |
189 | 189 |
uint32_t size, loops; |
190 |
- int ret, gotsome=0, opened=0; |
|
190 |
+ int ret, gotsome=0; |
|
191 | 191 |
unsigned char obuf[BUFSIZ]; |
192 | 192 |
|
193 | 193 |
if (n->eof) { |
... | ... |
@@ -125,8 +125,8 @@ typedef struct property_tag { |
125 | 125 |
unsigned char reserved[4]; |
126 | 126 |
} property_t; |
127 | 127 |
|
128 |
- |
|
129 | 128 |
struct ole2_list_node; |
129 |
+ |
|
130 | 130 |
typedef struct ole2_list_node |
131 | 131 |
{ |
132 | 132 |
uint32_t Val; |
... | ... |
@@ -139,6 +139,13 @@ typedef struct ole2_list |
139 | 139 |
ole2_list_node_t *Head; |
140 | 140 |
} ole2_list_t; |
141 | 141 |
|
142 |
+int ole2_list_init(ole2_list_t * list); |
|
143 |
+int ole2_list_is_empty(ole2_list_t * list); |
|
144 |
+uint32_t ole2_list_size(ole2_list_t * list); |
|
145 |
+int ole2_list_push(ole2_list_t * list, uint32_t val); |
|
146 |
+uint32_t ole2_list_pop(ole2_list_t * list); |
|
147 |
+int ole2_list_delete(ole2_list_t * list); |
|
148 |
+ |
|
142 | 149 |
int |
143 | 150 |
ole2_list_init(ole2_list_t * list) |
144 | 151 |
{ |
... | ... |
@@ -525,10 +532,11 @@ ole2_walk_property_tree(ole2_header_t * hdr, const char *dir, int32_t prop_index |
525 | 525 |
{ |
526 | 526 |
property_t prop_block[4]; |
527 | 527 |
int32_t idx, current_block, i, curindex; |
528 |
- char *name, *dirname; |
|
528 |
+ char *dirname; |
|
529 | 529 |
ole2_list_t node_list; |
530 | 530 |
int ret, func_ret; |
531 | 531 |
#if HAVE_JSON |
532 |
+ char *name; |
|
532 | 533 |
int toval = 0; |
533 | 534 |
#endif |
534 | 535 |
|
... | ... |
@@ -627,7 +635,7 @@ ole2_walk_property_tree(ole2_header_t * hdr, const char *dir, int32_t prop_index |
627 | 627 |
continue; |
628 | 628 |
} |
629 | 629 |
hdr->sbat_root_start = prop_block[idx].start_block; |
630 |
- if (prop_block[idx].child != -1) { |
|
630 |
+ if ((int)(prop_block[idx].child) != -1) { |
|
631 | 631 |
ret = ole2_walk_property_tree(hdr, dir, prop_block[idx].child, handler, rec_level + 1, file_count, ctx, scansize); |
632 | 632 |
if (ret != CL_SUCCESS) { |
633 | 633 |
if ((ctx->options & CL_SCAN_ALLMATCHES) && (ret == CL_VIRUS)) { |
... | ... |
@@ -639,13 +647,13 @@ ole2_walk_property_tree(ole2_header_t * hdr, const char *dir, int32_t prop_index |
639 | 639 |
} |
640 | 640 |
} |
641 | 641 |
} |
642 |
- if (prop_block[idx].prev != -1) { |
|
642 |
+ if ((int)(prop_block[idx].prev) != -1) { |
|
643 | 643 |
if ((ret=ole2_list_push(&node_list, prop_block[idx].prev)) != CL_SUCCESS) { |
644 | 644 |
ole2_list_delete(&node_list); |
645 | 645 |
return ret; |
646 | 646 |
} |
647 | 647 |
} |
648 |
- if (prop_block[idx].next != -1) { |
|
648 |
+ if ((int)(prop_block[idx].next) != -1) { |
|
649 | 649 |
if ((ret=ole2_list_push(&node_list, prop_block[idx].next)) != CL_SUCCESS) { |
650 | 650 |
ole2_list_delete(&node_list); |
651 | 651 |
return ret; |
... | ... |
@@ -677,7 +685,7 @@ ole2_walk_property_tree(ole2_header_t * hdr, const char *dir, int32_t prop_index |
677 | 677 |
} else { |
678 | 678 |
cli_dbgmsg("OLE2: filesize exceeded\n"); |
679 | 679 |
} |
680 |
- if (prop_block[idx].child != -1) { |
|
680 |
+ if ((int)(prop_block[idx].child) != -1) { |
|
681 | 681 |
ret = ole2_walk_property_tree(hdr, dir, prop_block[idx].child, handler, rec_level, file_count, ctx, scansize); |
682 | 682 |
if (ret != CL_SUCCESS) { |
683 | 683 |
if ((ctx->options & CL_SCAN_ALLMATCHES) && (ret == CL_VIRUS)) { |
... | ... |
@@ -689,13 +697,13 @@ ole2_walk_property_tree(ole2_header_t * hdr, const char *dir, int32_t prop_index |
689 | 689 |
} |
690 | 690 |
} |
691 | 691 |
} |
692 |
- if (prop_block[idx].prev != -1) { |
|
692 |
+ if ((int)(prop_block[idx].prev) != -1) { |
|
693 | 693 |
if ((ret=ole2_list_push(&node_list, prop_block[idx].prev)) != CL_SUCCESS) { |
694 | 694 |
ole2_list_delete(&node_list); |
695 | 695 |
return ret; |
696 | 696 |
} |
697 | 697 |
} |
698 |
- if (prop_block[idx].next != -1) { |
|
698 |
+ if ((int)(prop_block[idx].next) != -1) { |
|
699 | 699 |
if ((ret=ole2_list_push(&node_list, prop_block[idx].next)) != CL_SUCCESS) { |
700 | 700 |
ole2_list_delete(&node_list); |
701 | 701 |
return ret; |
... | ... |
@@ -734,7 +742,7 @@ ole2_walk_property_tree(ole2_header_t * hdr, const char *dir, int32_t prop_index |
734 | 734 |
cli_dbgmsg("OLE2 dir entry: %s\n", dirname); |
735 | 735 |
} else |
736 | 736 |
dirname = NULL; |
737 |
- if (prop_block[idx].child != -1) { |
|
737 |
+ if ((int)(prop_block[idx].child) != -1) { |
|
738 | 738 |
ret = ole2_walk_property_tree(hdr, dirname, prop_block[idx].child, handler, rec_level + 1, file_count, ctx, scansize); |
739 | 739 |
if (ret != CL_SUCCESS) { |
740 | 740 |
if ((ctx->options & CL_SCAN_ALLMATCHES) && (ret == CL_VIRUS)) { |
... | ... |
@@ -746,13 +754,13 @@ ole2_walk_property_tree(ole2_header_t * hdr, const char *dir, int32_t prop_index |
746 | 746 |
} |
747 | 747 |
} |
748 | 748 |
} |
749 |
- if (prop_block[idx].prev != -1) { |
|
749 |
+ if ((int)(prop_block[idx].prev) != -1) { |
|
750 | 750 |
if ((ret=ole2_list_push(&node_list, prop_block[idx].prev)) != CL_SUCCESS) { |
751 | 751 |
ole2_list_delete(&node_list); |
752 | 752 |
return ret; |
753 | 753 |
} |
754 | 754 |
} |
755 |
- if (prop_block[idx].next != -1) { |
|
755 |
+ if ((int)(prop_block[idx].next) != -1) { |
|
756 | 756 |
if ((ret=ole2_list_push(&node_list, prop_block[idx].next)) != CL_SUCCESS) { |
757 | 757 |
ole2_list_delete(&node_list); |
758 | 758 |
return ret; |
... | ... |
@@ -782,6 +790,8 @@ handler_writefile(ole2_header_t * hdr, property_t * prop, const char *dir, cli_c |
782 | 782 |
char *hash; |
783 | 783 |
uint32_t cnt; |
784 | 784 |
|
785 |
+ UNUSEDPARAM(ctx); |
|
786 |
+ |
|
785 | 787 |
if (prop->type != 2) { |
786 | 788 |
/* Not a file */ |
787 | 789 |
return CL_SUCCESS; |
... | ... |
@@ -922,7 +932,11 @@ handler_enum(ole2_header_t * hdr, property_t * prop, const char *dir, cli_ctx * |
922 | 922 |
|
923 | 923 |
} |
924 | 924 |
} |
925 |
+#else |
|
926 |
+ UNUSEDPARAM(ctx); |
|
925 | 927 |
#endif |
928 |
+ UNUSEDPARAM(dir); |
|
929 |
+ |
|
926 | 930 |
if (!hdr->has_vba) { |
927 | 931 |
if (!name) |
928 | 932 |
name = get_property_name2(prop->name, prop->name_size); |
... | ... |
@@ -947,6 +961,8 @@ handler_otf(ole2_header_t * hdr, property_t * prop, const char *dir, cli_ctx * c |
947 | 947 |
int ofd, ret; |
948 | 948 |
bitset_t *blk_bitset; |
949 | 949 |
|
950 |
+ UNUSEDPARAM(dir); |
|
951 |
+ |
|
950 | 952 |
if (prop->type != 2) { |
951 | 953 |
/* Not a file */ |
952 | 954 |
return CL_SUCCESS; |
... | ... |
@@ -1175,7 +1191,8 @@ int |
1175 | 1175 |
cli_ole2_extract(const char *dirname, cli_ctx * ctx, struct uniq **vba) |
1176 | 1176 |
{ |
1177 | 1177 |
ole2_header_t hdr; |
1178 |
- int hdr_size, ret = CL_CLEAN; |
|
1178 |
+ int ret = CL_CLEAN; |
|
1179 |
+ size_t hdr_size; |
|
1179 | 1180 |
unsigned int file_count = 0; |
1180 | 1181 |
unsigned long scansize, scansize2; |
1181 | 1182 |
const void *phdr; |
... | ... |
@@ -1200,7 +1217,7 @@ cli_ole2_extract(const char *dirname, cli_ctx * ctx, struct uniq **vba) |
1200 | 1200 |
sizeof(off_t) - sizeof(bitset_t *) - |
1201 | 1201 |
sizeof(struct uniq *) - sizeof(int) - sizeof(fmap_t *); |
1202 | 1202 |
|
1203 |
- if ((*ctx->fmap)->len < hdr_size) { |
|
1203 |
+ if ((size_t)((*ctx->fmap)->len) < (size_t)(hdr_size)) { |
|
1204 | 1204 |
return CL_CLEAN; |
1205 | 1205 |
} |
1206 | 1206 |
hdr.map = *ctx->fmap; |
... | ... |
@@ -1674,7 +1691,7 @@ ole2_process_property(summary_ctx_t *sctx, unsigned char *databuf, uint32_t offs |
1674 | 1674 |
if (!outstr) { |
1675 | 1675 |
return CL_EMEM; |
1676 | 1676 |
} |
1677 |
- strncpy(outstr, databuf+offset, strsize); |
|
1677 |
+ strncpy(outstr, (const char *)(databuf+offset), strsize); |
|
1678 | 1678 |
ret = cli_jsonstr(sctx->summary, sctx->propname, outstr); |
1679 | 1679 |
free(outstr); |
1680 | 1680 |
break; |
... | ... |
@@ -1721,7 +1738,7 @@ ole2_process_property(summary_ctx_t *sctx, unsigned char *databuf, uint32_t offs |
1721 | 1721 |
if (!outstr) { |
1722 | 1722 |
return CL_EMEM; |
1723 | 1723 |
} |
1724 |
- strncpy(outstr, databuf+offset, strsize); |
|
1724 |
+ strncpy(outstr, (const char *)(databuf+offset), strsize); |
|
1725 | 1725 |
outstr2 = (char*)get_property_name2(outstr, strsize); |
1726 | 1726 |
if (outstr2) { |
1727 | 1727 |
ret = cli_jsonstr(sctx->summary, sctx->propname, outstr2); |
... | ... |
@@ -1934,8 +1951,9 @@ static int ole2_summary_propset_json(summary_ctx_t *sctx, off_t offset) |
1934 | 1934 |
unsigned char *hdr, *ps; |
1935 | 1935 |
uint32_t numprops, limitprops; |
1936 | 1936 |
off_t foff = offset, psoff = 0; |
1937 |
- uint32_t propid, poffset; |
|
1938 |
- int i, ret; |
|
1937 |
+ uint32_t poffset; |
|
1938 |
+ int ret; |
|
1939 |
+ unsigned int i; |
|
1939 | 1940 |
|
1940 | 1941 |
cli_dbgmsg("in ole2_summary_propset_json\n"); |
1941 | 1942 |
|
... | ... |
@@ -1973,7 +1991,7 @@ static int ole2_summary_propset_json(summary_ctx_t *sctx, off_t offset) |
1973 | 1973 |
limitprops, numprops, PROPCNTLIMIT); |
1974 | 1974 |
|
1975 | 1975 |
/* extract remaining fragment of propset */ |
1976 |
- if (foff+(sctx->pssize) > sctx->maplen) { |
|
1976 |
+ if ((size_t)(foff+(sctx->pssize)) > (size_t)(sctx->maplen)) { |
|
1977 | 1977 |
sctx->flags |= OLE2_SUMMARY_ERROR_TOOSMALL; |
1978 | 1978 |
return CL_EFORMAT; |
1979 | 1979 |
} |
... | ... |
@@ -2021,7 +2039,7 @@ static int ole2_summary_propset_json(summary_ctx_t *sctx, off_t offset) |
2021 | 2021 |
|
2022 | 2022 |
static int cli_ole2_summary_json_cleanup(summary_ctx_t *sctx, int retcode) |
2023 | 2023 |
{ |
2024 |
- json_object *jobj, *jarr; |
|
2024 |
+ json_object *jarr; |
|
2025 | 2025 |
|
2026 | 2026 |
cli_dbgmsg("in cli_ole2_summary_json_cleanup: %d[%x]\n", retcode, sctx->flags); |
2027 | 2027 |
|
... | ... |
@@ -2071,9 +2089,9 @@ static int cli_ole2_summary_json_cleanup(summary_ctx_t *sctx, int retcode) |
2071 | 2071 |
|
2072 | 2072 |
#endif /* HAVE_JSON */ |
2073 | 2073 |
|
2074 |
+#if HAVE_JSON |
|
2074 | 2075 |
int cli_ole2_summary_json(cli_ctx *ctx, int fd, int mode) |
2075 | 2076 |
{ |
2076 |
-#if HAVE_JSON |
|
2077 | 2077 |
summary_ctx_t sctx; |
2078 | 2078 |
STATBUF statbuf; |
2079 | 2079 |
off_t foff = 0; |
... | ... |
@@ -2186,8 +2204,5 @@ int cli_ole2_summary_json(cli_ctx *ctx, int fd, int mode) |
2186 | 2186 |
} |
2187 | 2187 |
|
2188 | 2188 |
return cli_ole2_summary_json_cleanup(&sctx, CL_SUCCESS); |
2189 |
-#else |
|
2190 |
- cli_dbgmsg("ole2_summary_json: libjson needs to enabled!"); |
|
2191 |
- return CL_SUCCESS; |
|
2192 |
-#endif /* HAVE_JSON */ |
|
2193 | 2189 |
} |
2190 |
+#endif /* HAVE_JSON */ |
... | ... |
@@ -32,6 +32,8 @@ |
32 | 32 |
#endif |
33 | 33 |
#include "json_api.h" |
34 | 34 |
|
35 |
+#include "ooxml.h" |
|
36 |
+ |
|
35 | 37 |
#if HAVE_LIBXML2 |
36 | 38 |
#ifdef _WIN32 |
37 | 39 |
#ifndef LIBXML_WRITER_ENABLED |
... | ... |
@@ -74,17 +76,17 @@ static int ooxml_parse_value(json_object *wrkptr, const char *arrname, const xml |
74 | 74 |
return CL_EMEM; |
75 | 75 |
} |
76 | 76 |
|
77 |
- if (ooxml_is_int(node_value, xmlStrlen(node_value), &val)) { |
|
77 |
+ if (ooxml_is_int((const char *)node_value, xmlStrlen(node_value), &val)) { |
|
78 | 78 |
newobj = json_object_new_int(val); |
79 | 79 |
} |
80 |
- else if (!xmlStrcmp(node_value, "true")) { |
|
80 |
+ else if (!xmlStrcmp(node_value, (const xmlChar *)"true")) { |
|
81 | 81 |
newobj = json_object_new_boolean(1); |
82 | 82 |
} |
83 |
- else if (!xmlStrcmp(node_value, "false")) { |
|
83 |
+ else if (!xmlStrcmp(node_value, (const xmlChar *)"false")) { |
|
84 | 84 |
newobj = json_object_new_boolean(0); |
85 | 85 |
} |
86 | 86 |
else { |
87 |
- newobj = json_object_new_string(node_value); |
|
87 |
+ newobj = json_object_new_string((const char *)node_value); |
|
88 | 88 |
} |
89 | 89 |
|
90 | 90 |
if (NULL == newobj) { |
... | ... |
@@ -218,7 +220,7 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec |
218 | 218 |
|
219 | 219 |
/* check recursion level */ |
220 | 220 |
if (rlvl >= OOXML_JSON_RECLEVEL_MAX) { |
221 |
- cli_dbgmsg("ooxml_parse_element: reached ooxml json recursion limit\n", node_name); |
|
221 |
+ cli_dbgmsg("ooxml_parse_element: reached ooxml json recursion limit\n"); |
|
222 | 222 |
/* skip it */ |
223 | 223 |
xmlTextReaderNext(reader); |
224 | 224 |
//return CL_EMAXREC; |
... | ... |
@@ -238,7 +240,7 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec |
238 | 238 |
cli_dbgmsg("ooxml_parse_element: element tag node nameless\n"); |
239 | 239 |
return CL_EPARSE; /* no name, nameless */ |
240 | 240 |
} |
241 |
- element_tag = ooxml_check_key(node_name, xmlStrlen(node_name)); |
|
241 |
+ element_tag = ooxml_check_key((const char *)node_name, xmlStrlen(node_name)); |
|
242 | 242 |
if (!element_tag) { |
243 | 243 |
cli_dbgmsg("ooxml_parse_element: invalid element tag [%s]\n", node_name); |
244 | 244 |
/* skip it */ |
... | ... |
@@ -274,7 +276,7 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec |
274 | 274 |
|
275 | 275 |
cli_dbgmsg("%s: %s\n", name, value); |
276 | 276 |
|
277 |
- cli_jsonstr(attributes, name, value); |
|
277 |
+ cli_jsonstr(attributes, name, (const char *)value); |
|
278 | 278 |
} |
279 | 279 |
} |
280 | 280 |
|
... | ... |
@@ -310,7 +312,7 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec |
310 | 310 |
return CL_EPARSE; /* no name, nameless */ |
311 | 311 |
} |
312 | 312 |
|
313 |
- end_tag = ooxml_check_key(node_name, xmlStrlen(node_name)); |
|
313 |
+ end_tag = ooxml_check_key((const char *)node_name, xmlStrlen(node_name)); |
|
314 | 314 |
if (!end_tag) { |
315 | 315 |
cli_dbgmsg("ooxml_parse_element: invalid element end tag [%s]\n", node_name); |
316 | 316 |
return CL_EFORMAT; /* unrecognized element tag */ |
... | ... |
@@ -430,7 +432,7 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx) |
430 | 430 |
name = xmlTextReaderConstLocalName(reader); |
431 | 431 |
if (name == NULL) continue; |
432 | 432 |
|
433 |
- if (strcmp(name, "Override")) continue; |
|
433 |
+ if (strcmp((const char *)name, "Override")) continue; |
|
434 | 434 |
|
435 | 435 |
if (!xmlTextReaderHasAttributes(reader)) continue; |
436 | 436 |
|
... | ... |
@@ -440,10 +442,10 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx) |
440 | 440 |
value = xmlTextReaderConstValue(reader); |
441 | 441 |
if (name == NULL || value == NULL) continue; |
442 | 442 |
|
443 |
- if (!xmlStrcmp(name, "ContentType")) { |
|
443 |
+ if (!xmlStrcmp(name, (const xmlChar *)"ContentType")) { |
|
444 | 444 |
CT = value; |
445 | 445 |
} |
446 |
- else if (!xmlStrcmp(name, "PartName")) { |
|
446 |
+ else if (!xmlStrcmp(name, (const xmlChar *)"PartName")) { |
|
447 | 447 |
PN = value; |
448 | 448 |
} |
449 | 449 |
|
... | ... |
@@ -452,10 +454,10 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx) |
452 | 452 |
|
453 | 453 |
if (!CT && !PN) continue; |
454 | 454 |
|
455 |
- if (!xmlStrcmp(CT, "application/vnd.openxmlformats-package.core-properties+xml")) { |
|
455 |
+ if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-package.core-properties+xml")) { |
|
456 | 456 |
if (!core) { |
457 | 457 |
/* default: /docProps/core.xml*/ |
458 |
- tmp = unzip_search(ctx, PN+1, xmlStrlen(PN)-1, &loff); |
|
458 |
+ tmp = unzip_search(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff); |
|
459 | 459 |
if (tmp == CL_ETIMEOUT) { |
460 | 460 |
ret = tmp; |
461 | 461 |
} |
... | ... |
@@ -470,10 +472,10 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx) |
470 | 470 |
} |
471 | 471 |
} |
472 | 472 |
} |
473 |
- else if (!xmlStrcmp(CT, "application/vnd.openxmlformats-officedocument.extended-properties+xml")) { |
|
473 |
+ else if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-officedocument.extended-properties+xml")) { |
|
474 | 474 |
if (!extn) { |
475 | 475 |
/* default: /docProps/app.xml */ |
476 |
- tmp = unzip_search(ctx, PN+1, xmlStrlen(PN)-1, &loff); |
|
476 |
+ tmp = unzip_search(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff); |
|
477 | 477 |
if (tmp == CL_ETIMEOUT) { |
478 | 478 |
ret = tmp; |
479 | 479 |
} |
... | ... |
@@ -488,10 +490,10 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx) |
488 | 488 |
} |
489 | 489 |
} |
490 | 490 |
} |
491 |
- else if (!xmlStrcmp(CT, "application/vnd.openxmlformats-officedocument.custom-properties+xml")) { |
|
491 |
+ else if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-officedocument.custom-properties+xml")) { |
|
492 | 492 |
if (!cust) { |
493 | 493 |
/* default: /docProps/custom.xml */ |
494 |
- tmp = unzip_search(ctx, PN+1, xmlStrlen(PN)-1, &loff); |
|
494 |
+ tmp = unzip_search(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff); |
|
495 | 495 |
if (tmp == CL_ETIMEOUT) { |
496 | 496 |
ret = tmp; |
497 | 497 |
} |
... | ... |
@@ -506,7 +508,7 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx) |
506 | 506 |
} |
507 | 507 |
} |
508 | 508 |
} |
509 |
- else if (!xmlStrcmp(CT, "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml")) { |
|
509 |
+ else if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml")) { |
|
510 | 510 |
dsig++; |
511 | 511 |
} |
512 | 512 |
|
... | ... |
@@ -570,6 +572,7 @@ int cli_process_ooxml(cli_ctx *ctx) |
570 | 570 |
|
571 | 571 |
return unzip_single_internal(ctx, loff, ooxml_content_cb); |
572 | 572 |
#else |
573 |
+ UNUSEDPARAM(ctx); |
|
573 | 574 |
cli_dbgmsg("in cli_processooxml\n"); |
574 | 575 |
#if !HAVE_LIBXML2 |
575 | 576 |
cli_dbgmsg("cli_process_ooxml: libxml2 needs to enabled!"); |
... | ... |
@@ -252,7 +252,7 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine, unsigned |
252 | 252 |
|
253 | 253 |
elem = elems; |
254 | 254 |
elems = elems->next; |
255 |
- hash = elem->hash; |
|
255 |
+ hash = (char *)(elem->hash); |
|
256 | 256 |
while (isspace(*hash)) |
257 | 257 |
hash++; |
258 | 258 |
hashlen = strlen(hash); |
... | ... |
@@ -286,6 +286,8 @@ int cl_init(unsigned int initoptions) |
286 | 286 |
struct timeval tv; |
287 | 287 |
unsigned int pid = (unsigned int) getpid(); |
288 | 288 |
|
289 |
+ UNUSEDPARAM(initoptions); |
|
290 |
+ |
|
289 | 291 |
cl_initialize_crypto(); |
290 | 292 |
|
291 | 293 |
{ |
... | ... |
@@ -766,8 +768,6 @@ struct cl_settings *cl_engine_settings_copy(const struct cl_engine *engine) |
766 | 766 |
|
767 | 767 |
int cl_engine_settings_apply(struct cl_engine *engine, const struct cl_settings *settings) |
768 | 768 |
{ |
769 |
- cli_intel_t *intel; |
|
770 |
- |
|
771 | 769 |
engine->ac_only = settings->ac_only; |
772 | 770 |
engine->ac_mindepth = settings->ac_mindepth; |
773 | 771 |
engine->ac_maxdepth = settings->ac_maxdepth; |
... | ... |
@@ -1163,7 +1163,7 @@ int cli_rmdirs(const char *dirname) |
1163 | 1163 |
if(strcmp(dent->d_name, ".") && strcmp(dent->d_name, "..")) { |
1164 | 1164 |
path = cli_malloc(strlen(dirname) + strlen(dent->d_name) + 2); |
1165 | 1165 |
if(!path) { |
1166 |
- cli_errmsg("cli_rmdirs: Unable to allocate memory for path %u\n", strlen(dirname) + strlen(dent->d_name) + 2); |
|
1166 |
+ cli_errmsg("cli_rmdirs: Unable to allocate memory for path %lu\n", strlen(dirname) + strlen(dent->d_name) + 2); |
|
1167 | 1167 |
closedir(dd); |
1168 | 1168 |
return -1; |
1169 | 1169 |
} |
... | ... |
@@ -121,6 +121,9 @@ uint8_t cli_always_gen_section_hash = 0; |
121 | 121 |
|
122 | 122 |
static void fputs_callback(enum cl_msg severity, const char *fullmsg, const char *msg, void *context) |
123 | 123 |
{ |
124 |
+ UNUSEDPARAM(severity); |
|
125 |
+ UNUSEDPARAM(msg); |
|
126 |
+ UNUSEDPARAM(context); |
|
124 | 127 |
fputs(fullmsg, stderr); |
125 | 128 |
} |
126 | 129 |
|
... | ... |
@@ -23,7 +23,6 @@ |
23 | 23 |
* TODO: Embedded fonts |
24 | 24 |
* TODO: Predictor image handling |
25 | 25 |
*/ |
26 |
-static char const rcsid[] = "$Id: pdf.c,v 1.61 2007/02/12 20:46:09 njh Exp $"; |
|
27 | 26 |
|
28 | 27 |
#if HAVE_CONFIG_H |
29 | 28 |
#include "clamav-config.h" |
... | ... |
@@ -77,6 +76,7 @@ static const char *pdf_nextobject(const char *ptr, size_t len); |
77 | 77 |
/* PDF statistics callbacks and related */ |
78 | 78 |
struct pdfname_action; |
79 | 79 |
|
80 |
+#if HAVE_JSON |
|
80 | 81 |
static void pdf_export_json(struct pdf_struct *); |
81 | 82 |
|
82 | 83 |
static void ASCIIHexDecode_cb(struct pdf_struct *, struct pdf_obj *, struct pdfname_action *); |
... | ... |
@@ -110,6 +110,7 @@ static void Colors_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfnam |
110 | 110 |
static void RichMedia_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act); |
111 | 111 |
static void AcroForm_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act); |
112 | 112 |
static void XFA_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act); |
113 |
+#endif |
|
113 | 114 |
/* End PDF statistics callbacks and related */ |
114 | 115 |
|
115 | 116 |
static int xrefCheck(const char *xref, const char *eof) |
... | ... |
@@ -286,6 +287,8 @@ int pdf_findobj(struct pdf_struct *pdf) |
286 | 286 |
|
287 | 287 |
static int filter_writen(struct pdf_struct *pdf, struct pdf_obj *obj, int fout, const char *buf, off_t len, off_t *sum) |
288 | 288 |
{ |
289 |
+ UNUSEDPARAM(obj); |
|
290 |
+ |
|
289 | 291 |
if (cli_checklimits("pdf", pdf->ctx, *sum, 0, 0)) |
290 | 292 |
return len; /* pretend it was a successful write to suppress CL_EWRITE */ |
291 | 293 |
|
... | ... |
@@ -636,6 +639,8 @@ static int run_pdf_hooks(struct pdf_struct *pdf, enum pdf_phase phase, int fd, i |
636 | 636 |
cli_ctx *ctx = pdf->ctx; |
637 | 637 |
fmap_t *map; |
638 | 638 |
|
639 |
+ UNUSEDPARAM(dumpid); |
|
640 |
+ |
|
639 | 641 |
bc_ctx = cli_bytecode_context_alloc(); |
640 | 642 |
if (!bc_ctx) { |
641 | 643 |
cli_errmsg("cli_pdf: can't allocate memory for bc_ctx"); |
... | ... |
@@ -664,6 +669,7 @@ static int run_pdf_hooks(struct pdf_struct *pdf, enum pdf_phase phase, int fd, i |
664 | 664 |
} |
665 | 665 |
|
666 | 666 |
static void dbg_printhex(const char *msg, const char *hex, unsigned len); |
667 |
+ |
|
667 | 668 |
static void aes_decrypt(const unsigned char *in, off_t *length, unsigned char *q, char *key, unsigned key_n, int has_iv) |
668 | 669 |
{ |
669 | 670 |
unsigned long rk[RKLENGTH(256)]; |
... | ... |
@@ -693,7 +699,7 @@ static void aes_decrypt(const unsigned char *in, off_t *length, unsigned char *q |
693 | 693 |
} |
694 | 694 |
|
695 | 695 |
cli_dbgmsg("aes_decrypt: Calling rijndaelSetupDecrypt\n"); |
696 |
- nrounds = rijndaelSetupDecrypt(rk, key, key_n*8); |
|
696 |
+ nrounds = rijndaelSetupDecrypt(rk, (const unsigned char *)key, key_n*8); |
|
697 | 697 |
cli_dbgmsg("aes_decrypt: Beginning rijndaelDecrypt\n"); |
698 | 698 |
|
699 | 699 |
while (len >= 16) { |
... | ... |
@@ -796,7 +802,7 @@ static char *decrypt_any(struct pdf_struct *pdf, uint32_t id, const char *in, of |
796 | 796 |
break; |
797 | 797 |
case ENC_AESV2: |
798 | 798 |
cli_dbgmsg("cli_pdf: enc is aesv2\n"); |
799 |
- aes_decrypt(in, length, q, result, n, 1); |
|
799 |
+ aes_decrypt((const unsigned char *)in, length, q, (char *)result, n, 1); |
|
800 | 800 |
|
801 | 801 |
noisy_msg(pdf, "decrypted AES(v2) data\n"); |
802 | 802 |
|
... | ... |
@@ -808,7 +814,7 @@ static char *decrypt_any(struct pdf_struct *pdf, uint32_t id, const char *in, of |
808 | 808 |
return NULL; |
809 | 809 |
} |
810 | 810 |
|
811 |
- aes_decrypt(in, length, q, pdf->key, pdf->keylen, 1); |
|
811 |
+ aes_decrypt((const unsigned char *)in, length, q, pdf->key, pdf->keylen, 1); |
|
812 | 812 |
|
813 | 813 |
noisy_msg(pdf, "decrypted AES(v3) data\n"); |
814 | 814 |
|
... | ... |
@@ -837,7 +843,7 @@ static char *decrypt_any(struct pdf_struct *pdf, uint32_t id, const char *in, of |
837 | 837 |
return NULL; |
838 | 838 |
} |
839 | 839 |
|
840 |
- return q; |
|
840 |
+ return (char *)q; |
|
841 | 841 |
} |
842 | 842 |
|
843 | 843 |
static enum enc_method get_enc_method(struct pdf_struct *pdf, struct pdf_obj *obj) |
... | ... |
@@ -883,7 +889,7 @@ static void process(struct text_norm_state *s, enum cstate *st, const char *buf, |
883 | 883 |
if (*buf == ')') { |
884 | 884 |
*st = CSTATE_TJ; |
885 | 885 |
} else { |
886 |
- if (text_normalize_buffer(s, buf, 1) != 1) { |
|
886 |
+ if (text_normalize_buffer(s, (const unsigned char *)buf, 1) != 1) { |
|
887 | 887 |
cli_writen(fout, s->out, s->out_pos); |
888 | 888 |
text_normalize_reset(s); |
889 | 889 |
} |
... | ... |
@@ -915,7 +921,7 @@ static int pdf_scan_contents(int fd, struct pdf_struct *pdf) |
915 | 915 |
return CL_ETMPFILE; |
916 | 916 |
} |
917 | 917 |
|
918 |
- text_normalize_init(&s, outbuff, sizeof(outbuff)); |
|
918 |
+ text_normalize_init(&s, (unsigned char *)outbuff, sizeof(outbuff)); |
|
919 | 919 |
while (1) { |
920 | 920 |
n = cli_readn(fd, inbuf, sizeof(inbuf)); |
921 | 921 |
if (n <= 0) |
... | ... |
@@ -1040,14 +1046,14 @@ int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj, uint32_t flags) |
1040 | 1040 |
|
1041 | 1041 |
cli_dbgmsg("cli_pdf: calculated length %ld\n", length); |
1042 | 1042 |
} else { |
1043 |
- if (size > length+2) { |
|
1043 |
+ if (size > (size_t)length+2) { |
|
1044 | 1044 |
cli_dbgmsg("cli_pdf: calculated length %ld < %ld\n", |
1045 | 1045 |
length, size); |
1046 | 1046 |
length = size; |
1047 | 1047 |
} |
1048 | 1048 |
} |
1049 | 1049 |
|
1050 |
- if (orig_length && size > orig_length + 20) { |
|
1050 |
+ if (orig_length && size > (size_t)orig_length + 20) { |
|
1051 | 1051 |
cli_dbgmsg("cli_pdf: orig length: %ld, length: %ld, size: %ld\n", orig_length, length, size); |
1052 | 1052 |
pdfobj_flag(pdf, obj, BAD_STREAMLEN); |
1053 | 1053 |
} |
... | ... |
@@ -1297,9 +1303,12 @@ struct pdfname_action { |
1297 | 1297 |
enum objstate from_state;/* STATE_NONE is noop */ |
1298 | 1298 |
enum objstate to_state; |
1299 | 1299 |
uint32_t nameflags; |
1300 |
+#if HAVE_JSON |
|
1300 | 1301 |
void (*pdf_stats_cb)(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act); |
1302 |
+#endif |
|
1301 | 1303 |
}; |
1302 | 1304 |
|
1305 |
+#if HAVE_JSON |
|
1303 | 1306 |
static struct pdfname_action pdfname_actions[] = { |
1304 | 1307 |
{"ASCIIHexDecode", OBJ_FILTER_AH, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC, ASCIIHexDecode_cb}, |
1305 | 1308 |
{"ASCII85Decode", OBJ_FILTER_A85, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC, ASCII85Decode_cb}, |
... | ... |
@@ -1348,6 +1357,43 @@ static struct pdfname_action pdfname_actions[] = { |
1348 | 1348 |
{"AcroForm", OBJ_DICT, STATE_NONE, STATE_NONE, NAMEFLAG_NONE, AcroForm_cb}, |
1349 | 1349 |
{"XFA", OBJ_DICT, STATE_NONE, STATE_NONE, NAMEFLAG_NONE, XFA_cb} |
1350 | 1350 |
}; |
1351 |
+#else |
|
1352 |
+static struct pdfname_action pdfname_actions[] = { |
|
1353 |
+ {"ASCIIHexDecode", OBJ_FILTER_AH, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1354 |
+ {"ASCII85Decode", OBJ_FILTER_A85, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1355 |
+ {"A85", OBJ_FILTER_A85, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1356 |
+ {"AHx", OBJ_FILTER_AH, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1357 |
+ {"EmbeddedFile", OBJ_EMBEDDED_FILE, STATE_NONE, STATE_NONE, NAMEFLAG_HEURISTIC}, |
|
1358 |
+ {"FlateDecode", OBJ_FILTER_FLATE, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1359 |
+ {"Fl", OBJ_FILTER_FLATE, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1360 |
+ {"Image", OBJ_IMAGE, STATE_NONE, STATE_NONE, NAMEFLAG_HEURISTIC}, |
|
1361 |
+ {"LZWDecode", OBJ_FILTER_LZW, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1362 |
+ {"LZW", OBJ_FILTER_LZW, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1363 |
+ {"RunLengthDecode", OBJ_FILTER_RL, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1364 |
+ {"RL", OBJ_FILTER_RL, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1365 |
+ {"CCITTFaxDecode", OBJ_FILTER_FAX, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1366 |
+ {"CCF", OBJ_FILTER_FAX, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1367 |
+ {"JBIG2Decode", OBJ_FILTER_DCT, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1368 |
+ {"DCTDecode", OBJ_FILTER_DCT, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1369 |
+ {"DCT", OBJ_FILTER_DCT, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1370 |
+ {"JPXDecode", OBJ_FILTER_JPX, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1371 |
+ {"Crypt", OBJ_FILTER_CRYPT, STATE_FILTER, STATE_NONE, NAMEFLAG_HEURISTIC}, |
|
1372 |
+ {"Standard", OBJ_FILTER_STANDARD, STATE_FILTER, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1373 |
+ {"Sig", OBJ_SIGNED, STATE_ANY, STATE_NONE, NAMEFLAG_HEURISTIC}, |
|
1374 |
+ {"V", OBJ_SIGNED, STATE_ANY, STATE_NONE, NAMEFLAG_HEURISTIC}, |
|
1375 |
+ {"R", OBJ_SIGNED, STATE_ANY, STATE_NONE, NAMEFLAG_HEURISTIC}, |
|
1376 |
+ {"Linearized", OBJ_DICT, STATE_NONE, STATE_LINEARIZED, NAMEFLAG_HEURISTIC}, |
|
1377 |
+ {"Filter", OBJ_HASFILTERS, STATE_ANY, STATE_FILTER, NAMEFLAG_HEURISTIC}, |
|
1378 |
+ {"JavaScript", OBJ_JAVASCRIPT, STATE_S, STATE_JAVASCRIPT, NAMEFLAG_HEURISTIC}, |
|
1379 |
+ {"Length", OBJ_DICT, STATE_FILTER, STATE_NONE, NAMEFLAG_HEURISTIC}, |
|
1380 |
+ {"S", OBJ_DICT, STATE_NONE, STATE_S, NAMEFLAG_HEURISTIC}, |
|
1381 |
+ {"Type", OBJ_DICT, STATE_NONE, STATE_NONE, NAMEFLAG_HEURISTIC}, |
|
1382 |
+ {"OpenAction", OBJ_OPENACTION, STATE_ANY, STATE_OPENACTION, NAMEFLAG_HEURISTIC}, |
|
1383 |
+ {"Launch", OBJ_LAUNCHACTION, STATE_ANY, STATE_LAUNCHACTION, NAMEFLAG_HEURISTIC}, |
|
1384 |
+ {"Page", OBJ_PAGE, STATE_NONE, STATE_NONE, NAMEFLAG_HEURISTIC}, |
|
1385 |
+ {"Contents", OBJ_CONTENTS, STATE_NONE, STATE_CONTENTS, NAMEFLAG_HEURISTIC} |
|
1386 |
+}; |
|
1387 |
+#endif |
|
1351 | 1388 |
|
1352 | 1389 |
#define KNOWN_FILTERS ((1 << OBJ_FILTER_AH) | (1 << OBJ_FILTER_RL) | (1 << OBJ_FILTER_A85) | (1 << OBJ_FILTER_FLATE) | (1 << OBJ_FILTER_LZW) | (1 << OBJ_FILTER_FAX) | (1 << OBJ_FILTER_DCT) | (1 << OBJ_FILTER_JPX) | (1 << OBJ_FILTER_CRYPT)) |
1353 | 1390 |
|
... | ... |
@@ -1383,8 +1429,10 @@ static void handle_pdfname(struct pdf_struct *pdf, struct pdf_obj *obj, const ch |
1383 | 1383 |
pdfobj_flag(pdf, obj, ESCAPED_COMMON_PDFNAME); |
1384 | 1384 |
} |
1385 | 1385 |
|
1386 |
+#if HAVE_JSON |
|
1386 | 1387 |
if ((act->pdf_stats_cb)) |
1387 | 1388 |
act->pdf_stats_cb(pdf, obj, act); |
1389 |
+#endif |
|
1388 | 1390 |
|
1389 | 1391 |
if (act->from_state == *state || act->from_state == STATE_ANY) { |
1390 | 1392 |
*state = act->to_state; |
... | ... |
@@ -1673,8 +1721,6 @@ void pdf_parseobj(struct pdf_struct *pdf, struct pdf_obj *obj) |
1673 | 1673 |
objstate = STATE_NONE; |
1674 | 1674 |
trailer_end = pdf_readint(dict, full_dict_length, "/H"); |
1675 | 1675 |
if (trailer_end > 0 && trailer_end < pdf->size) { |
1676 |
- const char *enc; |
|
1677 |
- |
|
1678 | 1676 |
trailer = trailer_end - 1024; |
1679 | 1677 |
if (trailer < 0) |
1680 | 1678 |
trailer = 0; |
... | ... |
@@ -2023,6 +2069,8 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O, |
2023 | 2023 |
struct arc4_state arc4; |
2024 | 2024 |
unsigned password_empty = 0; |
2025 | 2025 |
|
2026 |
+ UNUSEDPARAM(oulen); |
|
2027 |
+ |
|
2026 | 2028 |
dbg_printhex("U: ", U, 32); |
2027 | 2029 |
dbg_printhex("O: ", O, 32); |
2028 | 2030 |
if (R == 5) { |
... | ... |
@@ -2031,7 +2079,7 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O, |
2031 | 2031 |
/* supplement to ISO3200, 3.5.2 Algorithm 3.11 */ |
2032 | 2032 |
/* user validation salt */ |
2033 | 2033 |
cl_sha256(U+32, 8, result2, NULL); |
2034 |
- dbg_printhex("Computed U", result2, 32); |
|
2034 |
+ dbg_printhex("Computed U", (const char *)result2, 32); |
|
2035 | 2035 |
if (!memcmp(result2, U, 32)) { |
2036 | 2036 |
off_t n; |
2037 | 2037 |
|
... | ... |
@@ -2050,7 +2098,7 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O, |
2050 | 2050 |
return; |
2051 | 2051 |
} |
2052 | 2052 |
|
2053 |
- aes_decrypt(UE, &n, pdf->key, result2, 32, 0); |
|
2053 |
+ aes_decrypt((const unsigned char *)UE, &n, (unsigned char *)(pdf->key), (char *)result2, 32, 0); |
|
2054 | 2054 |
dbg_printhex("cli_pdf: Candidate encryption key", pdf->key, pdf->keylen); |
2055 | 2055 |
} |
2056 | 2056 |
} |
... | ... |
@@ -2093,15 +2141,15 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O, |
2093 | 2093 |
return; |
2094 | 2094 |
|
2095 | 2095 |
memcpy(pdf->key, result, pdf->keylen); |
2096 |
- dbg_printhex("md5", result, 16); |
|
2096 |
+ dbg_printhex("md5", (const char *)result, 16); |
|
2097 | 2097 |
dbg_printhex("Candidate encryption key", pdf->key, pdf->keylen); |
2098 | 2098 |
|
2099 | 2099 |
/* 7.6.3.3 Algorithm 6 */ |
2100 | 2100 |
if (R == 2) { |
2101 | 2101 |
/* 7.6.3.3 Algorithm 4 */ |
2102 | 2102 |
memcpy(data, key_padding, 32); |
2103 |
- arc4_init(&arc4, pdf->key, pdf->keylen); |
|
2104 |
- arc4_apply(&arc4, data, 32); |
|
2103 |
+ arc4_init(&arc4, (const uint8_t *)(pdf->key), pdf->keylen); |
|
2104 |
+ arc4_apply(&arc4, (uint8_t *)data, 32); |
|
2105 | 2105 |
dbg_printhex("computed U (R2)", data, 32); |
2106 | 2106 |
if (!memcmp(data, U, 32)) |
2107 | 2107 |
password_empty = 1; |
... | ... |
@@ -2119,7 +2167,7 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O, |
2119 | 2119 |
cl_hash_data("md5", d, 32 + pdf->fileIDlen, result, NULL); |
2120 | 2120 |
memcpy(data, pdf->key, len); |
2121 | 2121 |
|
2122 |
- arc4_init(&arc4, data, len); |
|
2122 |
+ arc4_init(&arc4, (const uint8_t *)data, len); |
|
2123 | 2123 |
arc4_apply(&arc4, result, 16); |
2124 | 2124 |
for (i=1;i<=19;i++) { |
2125 | 2125 |
unsigned j; |
... | ... |
@@ -2127,12 +2175,12 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O, |
2127 | 2127 |
for (j=0;j<len;j++) |
2128 | 2128 |
data[j] = pdf->key[j] ^ i; |
2129 | 2129 |
|
2130 |
- arc4_init(&arc4, data, len); |
|
2130 |
+ arc4_init(&arc4, (const uint8_t *)data, len); |
|
2131 | 2131 |
arc4_apply(&arc4, result, 16); |
2132 | 2132 |
} |
2133 | 2133 |
|
2134 | 2134 |
dbg_printhex("fileID", pdf->fileID, pdf->fileIDlen); |
2135 |
- dbg_printhex("computed U (R>=3)", result, 16); |
|
2135 |
+ dbg_printhex("computed U (R>=3)", (const char *)result, 16); |
|
2136 | 2136 |
if (!memcmp(result, U, 16)) |
2137 | 2137 |
password_empty = 1; |
2138 | 2138 |
} else { |
... | ... |
@@ -2172,7 +2220,7 @@ static enum enc_method parse_enc_method(const char *dict, unsigned len, const ch |
2172 | 2172 |
if (!strcmp(key, "Identity")) |
2173 | 2173 |
return ENC_IDENTITY; |
2174 | 2174 |
|
2175 |
- q = pdf_getdict(dict, &len, key); |
|
2175 |
+ q = pdf_getdict(dict, (int *)(&len), key); |
|
2176 | 2176 |
if (!q) |
2177 | 2177 |
return def; |
2178 | 2178 |
|
... | ... |
@@ -2197,7 +2245,7 @@ static enum enc_method parse_enc_method(const char *dict, unsigned len, const ch |
2197 | 2197 |
static void pdf_handle_enc(struct pdf_struct *pdf) |
2198 | 2198 |
{ |
2199 | 2199 |
struct pdf_obj *obj; |
2200 |
- uint32_t len, required_flags, n, R, P, length, EM = 1, i, oulen; |
|
2200 |
+ uint32_t len, n, R, P, length, EM = 1, i, oulen; |
|
2201 | 2201 |
char *O, *U, *UE, *StmF, *StrF, *EFF; |
2202 | 2202 |
const char *q, *q2; |
2203 | 2203 |
|
... | ... |
@@ -2280,7 +2328,7 @@ static void pdf_handle_enc(struct pdf_struct *pdf) |
2280 | 2280 |
StrF = pdf_readval(q, len, "/StrF"); |
2281 | 2281 |
EFF = pdf_readval(q, len, "/EFF"); |
2282 | 2282 |
n = len; |
2283 |
- pdf->CF = pdf_getdict(q, &n, "/CF"); |
|
2283 |
+ pdf->CF = pdf_getdict(q, (int *)(&n), "/CF"); |
|
2284 | 2284 |
pdf->CF_n = n; |
2285 | 2285 |
|
2286 | 2286 |
if (StmF) |
... | ... |
@@ -2410,7 +2458,9 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset) |
2410 | 2410 |
if (!pdfver) { |
2411 | 2411 |
cli_dbgmsg("cli_pdf: no PDF- header found\n"); |
2412 | 2412 |
noisy_warnmsg("cli_pdf: no PDF- header found\n"); |
2413 |
+#if HAVE_JSON |
|
2413 | 2414 |
pdf_export_json(&pdf); |
2415 |
+#endif |
|
2414 | 2416 |
return CL_SUCCESS; |
2415 | 2417 |
} |
2416 | 2418 |
|
... | ... |
@@ -2461,7 +2511,9 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset) |
2461 | 2461 |
eofmap = fmap_need_off_once(map, map_off, bytesleft); |
2462 | 2462 |
if (!eofmap) { |
2463 | 2463 |
cli_errmsg("cli_pdf: mmap() failed (2)\n"); |
2464 |
+#if HAVE_JSON |
|
2464 | 2465 |
pdf_export_json(&pdf); |
2466 |
+#endif |
|
2465 | 2467 |
return CL_EMAP; |
2466 | 2468 |
} |
2467 | 2469 |
|
... | ... |
@@ -2524,7 +2576,9 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset) |
2524 | 2524 |
pdf.map = fmap_need_off(map, offset, size); |
2525 | 2525 |
if (!pdf.map) { |
2526 | 2526 |
cli_errmsg("cli_pdf: mmap() failed (3)\n"); |
2527 |
+#if HAVE_JSON |
|
2527 | 2528 |
pdf_export_json(&pdf); |
2529 |
+#endif |
|
2528 | 2530 |
return CL_EMAP; |
2529 | 2531 |
} |
2530 | 2532 |
|
... | ... |
@@ -2537,7 +2591,9 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset) |
2537 | 2537 |
rc = CL_CLEAN; |
2538 | 2538 |
} else if (rc) { |
2539 | 2539 |
cli_dbgmsg("cli_pdf: (pre hooks) returning %d\n", rc); |
2540 |
+#if HAVE_JSON |
|
2540 | 2541 |
pdf_export_json(&pdf); |
2542 |
+#endif |
|
2541 | 2543 |
return rc == CL_BREAK ? CL_CLEAN : rc; |
2542 | 2544 |
} |
2543 | 2545 |
|
... | ... |
@@ -2560,7 +2616,9 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset) |
2560 | 2560 |
|
2561 | 2561 |
if (cli_checktimelimit(ctx) != CL_SUCCESS) { |
2562 | 2562 |
cli_errmsg("Timeout reached in the PDF parser\n"); |
2563 |
+#if HAVE_JSON |
|
2563 | 2564 |
pdf_export_json(&pdf); |
2565 |
+#endif |
|
2564 | 2566 |
free(pdf.objs); |
2565 | 2567 |
if (pdf.fileID) |
2566 | 2568 |
free(pdf.fileID); |
... | ... |
@@ -2607,7 +2665,9 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset) |
2607 | 2607 |
|
2608 | 2608 |
if (cli_checktimelimit(ctx) != CL_SUCCESS) { |
2609 | 2609 |
cli_errmsg("Timeout reached in the PDF parser\n"); |
2610 |
+#if HAVE_JSON |
|
2610 | 2611 |
pdf_export_json(&pdf); |
2612 |
+#endif |
|
2611 | 2613 |
free(pdf.objs); |
2612 | 2614 |
if (pdf.fileID) |
2613 | 2615 |
free(pdf.fileID); |
... | ... |
@@ -2679,7 +2739,9 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset) |
2679 | 2679 |
rc = CL_EFORMAT; |
2680 | 2680 |
} |
2681 | 2681 |
|
2682 |
+#if HAVE_JSON |
|
2682 | 2683 |
pdf_export_json(&pdf); |
2684 |
+#endif |
|
2683 | 2685 |
|
2684 | 2686 |
cli_dbgmsg("cli_pdf: returning %d\n", rc); |
2685 | 2687 |
free(pdf.objs); |
... | ... |
@@ -2870,74 +2932,117 @@ pdf_nextobject(const char *ptr, size_t len) |
2870 | 2870 |
} |
2871 | 2871 |
|
2872 | 2872 |
/* PDF statistics */ |
2873 |
+#if HAVE_JSON |
|
2873 | 2874 |
static void ASCIIHexDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2874 | 2875 |
{ |
2876 |
+ UNUSEDPARAM(obj); |
|
2877 |
+ UNUSEDPARAM(act); |
|
2878 |
+ |
|
2875 | 2879 |
if (!(pdf)) |
2876 | 2880 |
return; |
2877 | 2881 |
|
2878 | 2882 |
pdf->stats.nasciihexdecode++; |
2879 | 2883 |
} |
2884 |
+#endif |
|
2880 | 2885 |
|
2886 |
+#if HAVE_JSON |
|
2881 | 2887 |
static void ASCII85Decode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2882 | 2888 |
{ |
2889 |
+ UNUSEDPARAM(obj); |
|
2890 |
+ UNUSEDPARAM(act); |
|
2891 |
+ |
|
2883 | 2892 |
if (!(pdf)) |
2884 | 2893 |
return; |
2885 | 2894 |
|
2886 | 2895 |
pdf->stats.nascii85decode++; |
2887 | 2896 |
} |
2897 |
+#endif |
|
2888 | 2898 |
|
2899 |
+#if HAVE_JSON |
|
2889 | 2900 |
static void EmbeddedFile_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2890 | 2901 |
{ |
2902 |
+ UNUSEDPARAM(obj); |
|
2903 |
+ UNUSEDPARAM(act); |
|
2904 |
+ |
|
2891 | 2905 |
if (!(pdf)) |
2892 | 2906 |
return; |
2893 | 2907 |
|
2894 | 2908 |
pdf->stats.nembeddedfile++; |
2895 | 2909 |
} |
2910 |
+#endif |
|
2896 | 2911 |
|
2912 |
+#if HAVE_JSON |
|
2897 | 2913 |
static void FlateDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2898 | 2914 |
{ |
2915 |
+ UNUSEDPARAM(obj); |
|
2916 |
+ UNUSEDPARAM(act); |
|
2917 |
+ |
|
2899 | 2918 |
if (!(pdf)) |
2900 | 2919 |
return; |
2901 | 2920 |
|
2902 | 2921 |
pdf->stats.nflate++; |
2903 | 2922 |
} |
2923 |
+#endif |
|
2904 | 2924 |
|
2925 |
+#if HAVE_JSON |
|
2905 | 2926 |
static void Image_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2906 | 2927 |
{ |
2928 |
+ UNUSEDPARAM(obj); |
|
2929 |
+ UNUSEDPARAM(act); |
|
2930 |
+ |
|
2907 | 2931 |
if (!(pdf)) |
2908 | 2932 |
return; |
2909 | 2933 |
|
2910 | 2934 |
pdf->stats.nimage++; |
2911 | 2935 |
} |
2936 |
+#endif |
|
2912 | 2937 |
|
2938 |
+#if HAVE_JSON |
|
2913 | 2939 |
static void LZWDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2914 | 2940 |
{ |
2941 |
+ UNUSEDPARAM(obj); |
|
2942 |
+ UNUSEDPARAM(act); |
|
2943 |
+ |
|
2915 | 2944 |
if (!(pdf)) |
2916 | 2945 |
return; |
2917 | 2946 |
|
2918 | 2947 |
pdf->stats.nlzw++; |
2919 | 2948 |
} |
2949 |
+#endif |
|
2920 | 2950 |
|
2951 |
+#if HAVE_JSON |
|
2921 | 2952 |
static void RunLengthDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2922 | 2953 |
{ |
2954 |
+ UNUSEDPARAM(obj); |
|
2955 |
+ UNUSEDPARAM(act); |
|
2956 |
+ |
|
2923 | 2957 |
if (!(pdf)) |
2924 | 2958 |
return; |
2925 | 2959 |
|
2926 | 2960 |
pdf->stats.nrunlengthdecode++; |
2927 | 2961 |
} |
2962 |
+#endif |
|
2928 | 2963 |
|
2964 |
+#if HAVE_JSON |
|
2929 | 2965 |
static void CCITTFaxDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2930 | 2966 |
{ |
2967 |
+ UNUSEDPARAM(obj); |
|
2968 |
+ UNUSEDPARAM(act); |
|
2969 |
+ |
|
2931 | 2970 |
if (!(pdf)) |
2932 | 2971 |
return; |
2933 | 2972 |
|
2934 | 2973 |
pdf->stats.nfaxdecode++; |
2935 | 2974 |
} |
2975 |
+#endif |
|
2936 | 2976 |
|
2977 |
+#if HAVE_JSON |
|
2937 | 2978 |
static void JBIG2Decode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2938 | 2979 |
{ |
2939 |
-#if HAVE_JSON |
|
2940 |
- struct json_object *pdfobj, *jbig2arr, *jbig2obj; |
|
2980 |
+ struct json_object *pdfobj, *jbig2arr; |
|
2981 |
+ |
|
2982 |
+ UNUSEDPARAM(obj); |
|
2983 |
+ UNUSEDPARAM(act); |
|
2941 | 2984 |
|
2942 | 2985 |
if (!(pdf)) |
2943 | 2986 |
return; |
... | ... |
@@ -2959,53 +3064,80 @@ static void JBIG2Decode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct p |
2959 | 2959 |
cli_jsonint_array(jbig2arr, obj->id>>8); |
2960 | 2960 |
|
2961 | 2961 |
pdf->stats.njbig2decode++; |
2962 |
-#endif |
|
2963 | 2962 |
} |
2963 |
+#endif |
|
2964 | 2964 |
|
2965 |
+#if HAVE_JSON |
|
2965 | 2966 |
static void DCTDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2966 | 2967 |
{ |
2968 |
+ UNUSEDPARAM(obj); |
|
2969 |
+ UNUSEDPARAM(act); |
|
2970 |
+ |
|
2967 | 2971 |
if (!(pdf)) |
2968 | 2972 |
return; |
2969 | 2973 |
|
2970 | 2974 |
pdf->stats.ndctdecode++; |
2971 | 2975 |
} |
2976 |
+#endif |
|
2972 | 2977 |
|
2978 |
+#if HAVE_JSON |
|
2973 | 2979 |
static void JPXDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2974 | 2980 |
{ |
2981 |
+ UNUSEDPARAM(obj); |
|
2982 |
+ UNUSEDPARAM(act); |
|
2983 |
+ |
|
2975 | 2984 |
if (!(pdf)) |
2976 | 2985 |
return; |
2977 | 2986 |
|
2978 | 2987 |
pdf->stats.njpxdecode++; |
2979 | 2988 |
} |
2989 |
+#endif |
|
2980 | 2990 |
|
2991 |
+#if HAVE_JSON |
|
2981 | 2992 |
static void Crypt_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2982 | 2993 |
{ |
2994 |
+ UNUSEDPARAM(obj); |
|
2995 |
+ UNUSEDPARAM(act); |
|
2996 |
+ |
|
2983 | 2997 |
if (!(pdf)) |
2984 | 2998 |
return; |
2985 | 2999 |
|
2986 | 3000 |
pdf->stats.ncrypt++; |
2987 | 3001 |
} |
3002 |
+#endif |
|
2988 | 3003 |
|
3004 |
+#if HAVE_JSON |
|
2989 | 3005 |
static void Standard_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2990 | 3006 |
{ |
3007 |
+ UNUSEDPARAM(obj); |
|
3008 |
+ UNUSEDPARAM(act); |
|
3009 |
+ |
|
2991 | 3010 |
if (!(pdf)) |
2992 | 3011 |
return; |
2993 | 3012 |
|
2994 | 3013 |
pdf->stats.nstandard++; |
2995 | 3014 |
} |
3015 |
+#endif |
|
2996 | 3016 |
|
3017 |
+#if HAVE_JSON |
|
2997 | 3018 |
static void Sig_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
2998 | 3019 |
{ |
3020 |
+ UNUSEDPARAM(obj); |
|
3021 |
+ UNUSEDPARAM(act); |
|
3022 |
+ |
|
2999 | 3023 |
if (!(pdf)) |
3000 | 3024 |
return; |
3001 | 3025 |
|
3002 | 3026 |
pdf->stats.nsigned++; |
3003 | 3027 |
} |
3028 |
+#endif |
|
3004 | 3029 |
|
3030 |
+#if HAVE_JSON |
|
3005 | 3031 |
static void JavaScript_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3006 | 3032 |
{ |
3007 |
-#if HAVE_JSON |
|
3008 |
- struct json_object *pdfobj, *jbig2arr, *jbig2obj; |
|
3033 |
+ struct json_object *pdfobj, *jbig2arr; |
|
3034 |
+ |
|
3035 |
+ UNUSEDPARAM(act); |
|
3009 | 3036 |
|
3010 | 3037 |
if (!(pdf)) |
3011 | 3038 |
return; |
... | ... |
@@ -3027,36 +3159,53 @@ static void JavaScript_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pd |
3027 | 3027 |
cli_jsonint_array(jbig2arr, obj->id>>8); |
3028 | 3028 |
|
3029 | 3029 |
pdf->stats.njs++; |
3030 |
-#endif |
|
3031 | 3030 |
} |
3031 |
+#endif |
|
3032 | 3032 |
|
3033 |
+#if HAVE_JSON |
|
3033 | 3034 |
static void OpenAction_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3034 | 3035 |
{ |
3036 |
+ UNUSEDPARAM(obj); |
|
3037 |
+ UNUSEDPARAM(act); |
|
3038 |
+ |
|
3035 | 3039 |
if (!(pdf)) |
3036 | 3040 |
return; |
3037 | 3041 |
|
3038 | 3042 |
pdf->stats.nopenaction++; |
3039 | 3043 |
} |
3044 |
+#endif |
|
3040 | 3045 |
|
3046 |
+#if HAVE_JSON |
|
3041 | 3047 |
static void Launch_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3042 | 3048 |
{ |
3049 |
+ UNUSEDPARAM(obj); |
|
3050 |
+ UNUSEDPARAM(act); |
|
3051 |
+ |
|
3043 | 3052 |
if (!(pdf)) |
3044 | 3053 |
return; |
3045 | 3054 |
|
3046 | 3055 |
pdf->stats.nlaunch++; |
3047 | 3056 |
} |
3057 |
+#endif |
|
3048 | 3058 |
|
3059 |
+#if HAVE_JSON |
|
3049 | 3060 |
static void Page_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3050 | 3061 |
{ |
3062 |
+ UNUSEDPARAM(obj); |
|
3063 |
+ UNUSEDPARAM(act); |
|
3064 |
+ |
|
3051 | 3065 |
if (!(pdf)) |
3052 | 3066 |
return; |
3053 | 3067 |
|
3054 | 3068 |
pdf->stats.npage++; |
3055 | 3069 |
} |
3070 |
+#endif |
|
3056 | 3071 |
|
3072 |
+#if HAVE_JSON |
|
3057 | 3073 |
static void Author_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3058 | 3074 |
{ |
3059 |
-#if HAVE_JSON |
|
3075 |
+ UNUSEDPARAM(act); |
|
3076 |
+ |
|
3060 | 3077 |
if (!(pdf)) |
3061 | 3078 |
return; |
3062 | 3079 |
|
... | ... |
@@ -3065,12 +3214,14 @@ static void Author_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfnam |
3065 | 3065 |
|
3066 | 3066 |
if (!(pdf->stats.author)) |
3067 | 3067 |
pdf->stats.author = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Author", NULL); |
3068 |
-#endif |
|
3069 | 3068 |
} |
3069 |
+#endif |
|
3070 | 3070 |
|
3071 |
+#if HAVE_JSON |
|
3071 | 3072 |
static void Creator_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3072 | 3073 |
{ |
3073 |
-#if HAVE_JSON |
|
3074 |
+ UNUSEDPARAM(act); |
|
3075 |
+ |
|
3074 | 3076 |
if (!(pdf)) |
3075 | 3077 |
return; |
3076 | 3078 |
|
... | ... |
@@ -3079,12 +3230,14 @@ static void Creator_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfna |
3079 | 3079 |
|
3080 | 3080 |
if (!(pdf->stats.creator)) |
3081 | 3081 |
pdf->stats.creator = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Creator", NULL); |
3082 |
-#endif |
|
3083 | 3082 |
} |
3083 |
+#endif |
|
3084 | 3084 |
|
3085 |
+#if HAVE_JSON |
|
3085 | 3086 |
static void ModificationDate_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3086 | 3087 |
{ |
3087 |
-#if HAVE_JSON |
|
3088 |
+ UNUSEDPARAM(act); |
|
3089 |
+ |
|
3088 | 3090 |
if (!(pdf)) |
3089 | 3091 |
return; |
3090 | 3092 |
|
... | ... |
@@ -3093,12 +3246,14 @@ static void ModificationDate_cb(struct pdf_struct *pdf, struct pdf_obj *obj, str |
3093 | 3093 |
|
3094 | 3094 |
if (!(pdf->stats.modificationdate)) |
3095 | 3095 |
pdf->stats.modificationdate = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/ModDate", NULL); |
3096 |
-#endif |
|
3097 | 3096 |
} |
3097 |
+#endif |
|
3098 | 3098 |
|
3099 |
+#if HAVE_JSON |
|
3099 | 3100 |
static void CreationDate_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3100 | 3101 |
{ |
3101 |
-#if HAVE_JSON |
|
3102 |
+ UNUSEDPARAM(act); |
|
3103 |
+ |
|
3102 | 3104 |
if (!(pdf)) |
3103 | 3105 |
return; |
3104 | 3106 |
|
... | ... |
@@ -3107,12 +3262,14 @@ static void CreationDate_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct |
3107 | 3107 |
|
3108 | 3108 |
if (!(pdf->stats.creationdate)) |
3109 | 3109 |
pdf->stats.creationdate = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/CreationDate", NULL); |
3110 |
-#endif |
|
3111 | 3110 |
} |
3111 |
+#endif |
|
3112 | 3112 |
|
3113 |
+#if HAVE_JSON |
|
3113 | 3114 |
static void Producer_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3114 | 3115 |
{ |
3115 |
-#if HAVE_JSON |
|
3116 |
+ UNUSEDPARAM(act); |
|
3117 |
+ |
|
3116 | 3118 |
if (!(pdf)) |
3117 | 3119 |
return; |
3118 | 3120 |
|
... | ... |
@@ -3121,12 +3278,14 @@ static void Producer_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfn |
3121 | 3121 |
|
3122 | 3122 |
if (!(pdf->stats.producer)) |
3123 | 3123 |
pdf->stats.producer = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Producer", NULL); |
3124 |
-#endif |
|
3125 | 3124 |
} |
3125 |
+#endif |
|
3126 | 3126 |
|
3127 |
+#if HAVE_JSON |
|
3127 | 3128 |
static void Title_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3128 | 3129 |
{ |
3129 |
-#if HAVE_JSON |
|
3130 |
+ UNUSEDPARAM(act); |
|
3131 |
+ |
|
3130 | 3132 |
if (!(pdf)) |
3131 | 3133 |
return; |
3132 | 3134 |
|
... | ... |
@@ -3135,12 +3294,14 @@ static void Title_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname |
3135 | 3135 |
|
3136 | 3136 |
if (!(pdf->stats.title)) |
3137 | 3137 |
pdf->stats.title = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Title", NULL); |
3138 |
-#endif |
|
3139 | 3138 |
} |
3139 |
+#endif |
|
3140 | 3140 |
|
3141 |
+#if HAVE_JSON |
|
3141 | 3142 |
static void Keywords_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3142 | 3143 |
{ |
3143 |
-#if HAVE_JSON |
|
3144 |
+ UNUSEDPARAM(act); |
|
3145 |
+ |
|
3144 | 3146 |
if (!(pdf)) |
3145 | 3147 |
return; |
3146 | 3148 |
|
... | ... |
@@ -3149,12 +3310,14 @@ static void Keywords_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfn |
3149 | 3149 |
|
3150 | 3150 |
if (!(pdf->stats.keywords)) |
3151 | 3151 |
pdf->stats.keywords = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Keywords", NULL); |
3152 |
-#endif |
|
3153 | 3152 |
} |
3153 |
+#endif |
|
3154 | 3154 |
|
3155 |
+#if HAVE_JSON |
|
3155 | 3156 |
static void Subject_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3156 | 3157 |
{ |
3157 |
-#if HAVE_JSON |
|
3158 |
+ UNUSEDPARAM(act); |
|
3159 |
+ |
|
3158 | 3160 |
if (!(pdf)) |
3159 | 3161 |
return; |
3160 | 3162 |
|
... | ... |
@@ -3163,45 +3326,61 @@ static void Subject_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfna |
3163 | 3163 |
|
3164 | 3164 |
if (!(pdf->stats.subject)) |
3165 | 3165 |
pdf->stats.subject = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Subject", NULL); |
3166 |
-#endif |
|
3167 | 3166 |
} |
3167 |
+#endif |
|
3168 | 3168 |
|
3169 |
+#if HAVE_JSON |
|
3169 | 3170 |
static void RichMedia_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3170 | 3171 |
{ |
3172 |
+ UNUSEDPARAM(obj); |
|
3173 |
+ UNUSEDPARAM(act); |
|
3174 |
+ |
|
3171 | 3175 |
if (!(pdf)) |
3172 | 3176 |
return; |
3173 | 3177 |
|
3174 | 3178 |
pdf->stats.nrichmedia++; |
3175 | 3179 |
} |
3180 |
+#endif |
|
3176 | 3181 |
|
3182 |
+#if HAVE_JSON |
|
3177 | 3183 |
static void AcroForm_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3178 | 3184 |
{ |
3185 |
+ UNUSEDPARAM(obj); |
|
3186 |
+ UNUSEDPARAM(act); |
|
3187 |
+ |
|
3179 | 3188 |
if (!(pdf)) |
3180 | 3189 |
return; |
3181 | 3190 |
|
3182 | 3191 |
pdf->stats.nacroform++; |
3183 | 3192 |
} |
3193 |
+#endif |
|
3184 | 3194 |
|
3195 |
+#if HAVE_JSON |
|
3185 | 3196 |
static void XFA_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3186 | 3197 |
{ |
3198 |
+ UNUSEDPARAM(obj); |
|
3199 |
+ UNUSEDPARAM(act); |
|
3200 |
+ |
|
3187 | 3201 |
if (!(pdf)) |
3188 | 3202 |
return; |
3189 | 3203 |
|
3190 | 3204 |
pdf->stats.nxfa++; |
3191 | 3205 |
} |
3206 |
+#endif |
|
3192 | 3207 |
|
3208 |
+#if HAVE_JSON |
|
3193 | 3209 |
static void Pages_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3194 | 3210 |
{ |
3195 |
-#if HAVE_JSON |
|
3196 | 3211 |
struct pdf_array *array; |
3197 | 3212 |
const char *objstart = (const char *)(obj->start + pdf->map); |
3198 | 3213 |
const char *begin; |
3199 |
- unsigned int objsz = obj_size(pdf, obj, 1); |
|
3214 |
+ unsigned int objsz; |
|
3200 | 3215 |
unsigned long npages=0, count; |
3201 | 3216 |
struct pdf_array_node *node; |
3202 |
- struct pdf_dict *dict; |
|
3203 | 3217 |
json_object *pdfobj; |
3204 | 3218 |
|
3219 |
+ UNUSEDPARAM(act); |
|
3220 |
+ |
|
3205 | 3221 |
if (!(pdf) || !(pdf->ctx->wrkproperty)) |
3206 | 3222 |
return; |
3207 | 3223 |
|
... | ... |
@@ -3220,7 +3399,7 @@ static void Pages_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname |
3220 | 3220 |
|
3221 | 3221 |
begin += 5; |
3222 | 3222 |
|
3223 |
- array = pdf_parse_array(pdf, obj, objsz, begin, NULL); |
|
3223 |
+ array = pdf_parse_array(pdf, obj, objsz, (char *)begin, NULL); |
|
3224 | 3224 |
if (!(array)) { |
3225 | 3225 |
cli_jsonbool(pdfobj, "IncorrectPagesCount", 1); |
3226 | 3226 |
return; |
... | ... |
@@ -3251,16 +3430,18 @@ static void Pages_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname |
3251 | 3251 |
|
3252 | 3252 |
cleanup: |
3253 | 3253 |
pdf_free_array(array); |
3254 |
-#endif |
|
3255 | 3254 |
} |
3255 |
+#endif |
|
3256 | 3256 |
|
3257 |
+#if HAVE_JSON |
|
3257 | 3258 |
static void Colors_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act) |
3258 | 3259 |
{ |
3259 |
-#if HAVE_JSON |
|
3260 | 3260 |
json_object *colorsobj, *pdfobj; |
3261 | 3261 |
unsigned long ncolors; |
3262 | 3262 |
char *start, *p1; |
3263 |
- size_t objsz = obj_size(pdf, obj, 1); |
|
3263 |
+ size_t objsz; |
|
3264 |
+ |
|
3265 |
+ UNUSEDPARAM(act); |
|
3264 | 3266 |
|
3265 | 3267 |
if (!(pdf) || !(pdf->ctx) || !(pdf->ctx->wrkproperty)) |
3266 | 3268 |
return; |
... | ... |
@@ -3268,9 +3449,11 @@ static void Colors_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfnam |
3268 | 3268 |
if (!(pdf->ctx->options & CL_SCAN_FILE_PROPERTIES)) |
3269 | 3269 |
return; |
3270 | 3270 |
|
3271 |
- start = obj->start + pdf->map; |
|
3271 |
+ objsz = obj_size(pdf, obj, 1); |
|
3272 |
+ |
|
3273 |
+ start = (char *)(obj->start + pdf->map); |
|
3272 | 3274 |
|
3273 |
- p1 = cli_memstr(start, objsz, "/Colors", 7); |
|
3275 |
+ p1 = (char *)cli_memstr(start, objsz, "/Colors", 7); |
|
3274 | 3276 |
if (!(p1)) |
3275 | 3277 |
return; |
3276 | 3278 |
|
... | ... |
@@ -3283,7 +3466,7 @@ static void Colors_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfnam |
3283 | 3283 |
while (p1 - start < objsz && isspace(p1[0])) |
3284 | 3284 |
p1++; |
3285 | 3285 |
|
3286 |
- if (p1 - start == objsz) |
|
3286 |
+ if ((size_t)(p1 - start) == objsz) |
|
3287 | 3287 |
return; |
3288 | 3288 |
|
3289 | 3289 |
ncolors = strtoul(p1, NULL, 10); |
... | ... |
@@ -3301,12 +3484,12 @@ static void Colors_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfnam |
3301 | 3301 |
return; |
3302 | 3302 |
|
3303 | 3303 |
cli_jsonint_array(colorsobj, obj->id>>8); |
3304 |
-#endif |
|
3305 | 3304 |
} |
3305 |
+#endif |
|
3306 | 3306 |
|
3307 |
+#if HAVE_JSON |
|
3307 | 3308 |
static void pdf_export_json(struct pdf_struct *pdf) |
3308 | 3309 |
{ |
3309 |
-#if HAVE_JSON |
|
3310 | 3310 |
json_object *pdfobj; |
3311 | 3311 |
unsigned long i; |
3312 | 3312 |
|
... | ... |
@@ -3458,5 +3641,5 @@ cleanup: |
3458 | 3458 |
free(pdf->stats.keywords); |
3459 | 3459 |
pdf->stats.keywords = NULL; |
3460 | 3460 |
} |
3461 |
-#endif |
|
3462 | 3461 |
} |
3462 |
+#endif |
... | ... |
@@ -69,6 +69,8 @@ |
69 | 69 |
#include "textnorm.h" |
70 | 70 |
#include "json_api.h" |
71 | 71 |
|
72 |
+char *pdf_convert_utf(char *begin, size_t sz); |
|
73 |
+ |
|
72 | 74 |
char *pdf_convert_utf(char *begin, size_t sz) |
73 | 75 |
{ |
74 | 76 |
char *res=NULL; |
... | ... |
@@ -105,7 +107,7 @@ char *pdf_convert_utf(char *begin, size_t sz) |
105 | 105 |
continue; |
106 | 106 |
} |
107 | 107 |
|
108 |
- iconv(cd, &p1, &inlen, &p2, &outlen); |
|
108 |
+ iconv(cd, (const char **)(&p1), &inlen, &p2, &outlen); |
|
109 | 109 |
|
110 | 110 |
if (outlen == sz) { |
111 | 111 |
/* Decoding unsuccessful right from the start */ |
... | ... |
@@ -223,10 +225,9 @@ char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char * |
223 | 223 |
{ |
224 | 224 |
const char *q = objstart; |
225 | 225 |
char *p1, *p2; |
226 |
- size_t inlen, outlen, len, checklen; |
|
227 |
- char *buf, *outbuf, *res; |
|
226 |
+ size_t len, checklen; |
|
227 |
+ char *res; |
|
228 | 228 |
int likelyutf = 0; |
229 |
- unsigned int i; |
|
230 | 229 |
uint32_t objid; |
231 | 230 |
|
232 | 231 |
/* |
... | ... |
@@ -247,22 +248,22 @@ char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char * |
247 | 247 |
if (objsize < strlen(str) + 3) |
248 | 248 |
return NULL; |
249 | 249 |
|
250 |
- for (p1=(char *)q; (p1 - q) < objsize-checklen; p1++) |
|
250 |
+ for (p1=(char *)q; (size_t)(p1 - q) < objsize-checklen; p1++) |
|
251 | 251 |
if (!strncmp(p1, str, checklen)) |
252 | 252 |
break; |
253 | 253 |
|
254 |
- if (p1 - q == objsize - checklen) |
|
254 |
+ if ((size_t)(p1 - q) == objsize - checklen) |
|
255 | 255 |
return NULL; |
256 | 256 |
|
257 | 257 |
p1 += checklen; |
258 | 258 |
} else { |
259 |
- p1 = q; |
|
259 |
+ p1 = (char *)q; |
|
260 | 260 |
} |
261 | 261 |
|
262 |
- while ((p1 - q) < objsize && isspace(p1[0])) |
|
262 |
+ while ((size_t)(p1 - q) < objsize && isspace(p1[0])) |
|
263 | 263 |
p1++; |
264 | 264 |
|
265 |
- if ((p1 - q) == objsize) |
|
265 |
+ if ((size_t)(p1 - q) == objsize) |
|
266 | 266 |
return NULL; |
267 | 267 |
|
268 | 268 |
/* |
... | ... |
@@ -272,10 +273,10 @@ char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char * |
272 | 272 |
* We should be at the start of the string |
273 | 273 |
*/ |
274 | 274 |
|
275 |
- p2 = q + objsize; |
|
275 |
+ p2 = (char *)(q + objsize); |
|
276 | 276 |
if (is_object_reference(p1, &p2, &objid)) { |
277 | 277 |
struct pdf_obj *newobj; |
278 |
- char *end, *begin; |
|
278 |
+ char *begin; |
|
279 | 279 |
STATBUF sb; |
280 | 280 |
uint32_t objflags; |
281 | 281 |
int fd; |
... | ... |
@@ -368,15 +369,13 @@ char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char * |
368 | 368 |
} |
369 | 369 |
|
370 | 370 |
if (*p1 == '<') { |
371 |
- size_t sz; |
|
372 |
- |
|
373 | 371 |
/* Hex string */ |
374 | 372 |
|
375 | 373 |
p2 = p1+1; |
376 |
- while ((p2 - q) < objsize && *p2 != '>') |
|
374 |
+ while ((size_t)(p2 - q) < objsize && *p2 != '>') |
|
377 | 375 |
p2++; |
378 | 376 |
|
379 |
- if (p2 - q == objsize) { |
|
377 |
+ if ((size_t)(p2 - q) == objsize) { |
|
380 | 378 |
return NULL; |
381 | 379 |
} |
382 | 380 |
|
... | ... |
@@ -461,7 +460,7 @@ struct pdf_dict *pdf_parse_dict(struct pdf_struct *pdf, struct pdf_obj *obj, siz |
461 | 461 |
|
462 | 462 |
objstart = (const char *)(obj->start + pdf->map); |
463 | 463 |
|
464 |
- if (begin < objstart || begin - objstart >= objsz - 2) |
|
464 |
+ if (begin < objstart || (size_t)(begin - objstart) >= objsz - 2) |
|
465 | 465 |
return NULL; |
466 | 466 |
|
467 | 467 |
if (begin[0] != '<' || begin[1] != '<') |
... | ... |
@@ -469,7 +468,7 @@ struct pdf_dict *pdf_parse_dict(struct pdf_struct *pdf, struct pdf_obj *obj, siz |
469 | 469 |
|
470 | 470 |
/* Find the end of the dictionary */ |
471 | 471 |
end = begin; |
472 |
- while (end - objstart < objsz) { |
|
472 |
+ while ((size_t)(end - objstart) < objsz) { |
|
473 | 473 |
int increment=1; |
474 | 474 |
if (in_string) { |
475 | 475 |
if (*end == '\\') { |
... | ... |
@@ -489,18 +488,18 @@ struct pdf_dict *pdf_parse_dict(struct pdf_struct *pdf, struct pdf_obj *obj, siz |
489 | 489 |
in_string=1; |
490 | 490 |
break; |
491 | 491 |
case '<': |
492 |
- if (end - objstart <= objsz - 2 && end[1] == '<') |
|
492 |
+ if ((size_t)(end - objstart) <= objsz - 2 && end[1] == '<') |
|
493 | 493 |
ninner++; |
494 | 494 |
increment=2; |
495 | 495 |
break; |
496 | 496 |
case '>': |
497 |
- if (end - objstart <= objsz - 2 && end[1] == '>') |
|
497 |
+ if ((size_t)(end - objstart) <= objsz - 2 && end[1] == '>') |
|
498 | 498 |
ninner--; |
499 | 499 |
increment=2; |
500 | 500 |
break; |
501 | 501 |
} |
502 | 502 |
|
503 |
- if (end - objstart <= objsz - 2) |
|
503 |
+ if ((size_t)(end - objstart) <= objsz - 2) |
|
504 | 504 |
if (end[0] == '>' && end[1] == '>' && ninner == 0) |
505 | 505 |
break; |
506 | 506 |
|
... | ... |
@@ -508,7 +507,7 @@ struct pdf_dict *pdf_parse_dict(struct pdf_struct *pdf, struct pdf_obj *obj, siz |
508 | 508 |
} |
509 | 509 |
|
510 | 510 |
/* More sanity checking */ |
511 |
- if (end - objstart >= objsz - 2) |
|
511 |
+ if ((size_t)(end - objstart) >= objsz - 2) |
|
512 | 512 |
return NULL; |
513 | 513 |
|
514 | 514 |
if (end[0] != '>' || end[1] != '>') |
... | ... |
@@ -609,7 +608,7 @@ struct pdf_dict *pdf_parse_dict(struct pdf_struct *pdf, struct pdf_obj *obj, siz |
609 | 609 |
begin = p1+1; |
610 | 610 |
break; |
611 | 611 |
case '<': |
612 |
- if (begin - objstart < objsz - 2) { |
|
612 |
+ if ((size_t)(begin - objstart) < objsz - 2) { |
|
613 | 613 |
if (begin[1] == '<') { |
614 | 614 |
dict = pdf_parse_dict(pdf, obj, objsz, begin, &p1); |
615 | 615 |
begin = p1+2; |
... | ... |
@@ -717,7 +716,7 @@ struct pdf_array *pdf_parse_array(struct pdf_struct *pdf, struct pdf_obj *obj, s |
717 | 717 |
struct pdf_array *res=NULL; |
718 | 718 |
struct pdf_array_node *node=NULL; |
719 | 719 |
const char *objstart; |
720 |
- char *end, *tempend; |
|
720 |
+ char *end; |
|
721 | 721 |
int in_string=0, ninner=0; |
722 | 722 |
|
723 | 723 |
/* Sanity checking */ |
... | ... |
@@ -726,7 +725,7 @@ struct pdf_array *pdf_parse_array(struct pdf_struct *pdf, struct pdf_obj *obj, s |
726 | 726 |
|
727 | 727 |
objstart = obj->start + pdf->map; |
728 | 728 |
|
729 |
- if (begin < objstart || begin - objstart >= objsz) |
|
729 |
+ if (begin < objstart || (size_t)(begin - objstart) >= objsz) |
|
730 | 730 |
return NULL; |
731 | 731 |
|
732 | 732 |
if (begin[0] != '[') |
... | ... |
@@ -734,7 +733,7 @@ struct pdf_array *pdf_parse_array(struct pdf_struct *pdf, struct pdf_obj *obj, s |
734 | 734 |
|
735 | 735 |
/* Find the end of the array */ |
736 | 736 |
end = begin; |
737 |
- while (end - objstart < objsz) { |
|
737 |
+ while ((size_t)(end - objstart) < objsz) { |
|
738 | 738 |
if (in_string) { |
739 | 739 |
if (*end == '\\') { |
740 | 740 |
end += 2; |
... | ... |
@@ -767,7 +766,7 @@ struct pdf_array *pdf_parse_array(struct pdf_struct *pdf, struct pdf_obj *obj, s |
767 | 767 |
} |
768 | 768 |
|
769 | 769 |
/* More sanity checking */ |
770 |
- if (end - objstart == objsz) |
|
770 |
+ if ((size_t)(end - objstart) == objsz) |
|
771 | 771 |
return NULL; |
772 | 772 |
|
773 | 773 |
if (*end != ']') |
... | ... |
@@ -791,7 +790,7 @@ struct pdf_array *pdf_parse_array(struct pdf_struct *pdf, struct pdf_obj *obj, s |
791 | 791 |
|
792 | 792 |
switch (begin[0]) { |
793 | 793 |
case '<': |
794 |
- if (begin - objstart < objsz - 2 && begin[1] == '<') { |
|
794 |
+ if ((size_t)(begin - objstart) < objsz - 2 && begin[1] == '<') { |
|
795 | 795 |
dict = pdf_parse_dict(pdf, obj, objsz, begin, &begin); |
796 | 796 |
begin+=2; |
797 | 797 |
break; |
... | ... |
@@ -21,11 +21,18 @@ |
21 | 21 |
#if HAVE_CONFIG_H |
22 | 22 |
#include "clamav-config.h" |
23 | 23 |
#endif |
24 |
+ |
|
25 |
+/* |
|
24 | 26 |
#define _XOPEN_SOURCE 500 |
27 |
+*/ |
|
28 |
+ |
|
25 | 29 |
#include <stdio.h> |
30 |
+#include <stdlib.h> |
|
31 |
+ |
|
26 | 32 |
#if HAVE_STRING_H |
27 | 33 |
#include <string.h> |
28 | 34 |
#endif |
35 |
+ |
|
29 | 36 |
#include <sys/types.h> |
30 | 37 |
#include <sys/stat.h> |
31 | 38 |
#include <fcntl.h> |
... | ... |
@@ -739,7 +746,6 @@ int cli_scanpe(cli_ctx *ctx) |
739 | 739 |
size_t fsize; |
740 | 740 |
uint32_t valign, falign, hdr_size, j; |
741 | 741 |
struct cli_exe_section *exe_sections; |
742 |
- struct cli_matcher *mdb_sect; |
|
743 | 742 |
char timestr[32]; |
744 | 743 |
struct pe_image_data_dir *dirs; |
745 | 744 |
struct cli_bc_ctx *bc_ctx; |
... | ... |
@@ -748,8 +754,7 @@ int cli_scanpe(cli_ctx *ctx) |
748 | 748 |
#ifdef HAVE__INTERNAL__SHA_COLLECT |
749 | 749 |
int sha_collect = ctx->sha_collect; |
750 | 750 |
#endif |
751 |
- const char * virname = NULL; |
|
752 |
- const char *archtype=NULL, *subsystem=NULL; |
|
751 |
+ const char *archtype=NULL, *subsystem=NULL; |
|
753 | 752 |
uint32_t viruses_found = 0; |
754 | 753 |
#if HAVE_JSON |
755 | 754 |
int toval = 0; |
... | ... |
@@ -1869,7 +1874,7 @@ int cli_scanpe(cli_ctx *ctx) |
1869 | 1869 |
return CL_EMEM; |
1870 | 1870 |
} |
1871 | 1871 |
|
1872 |
- if(fmap_readn(map, dest, 0, ssize) != ssize) { |
|
1872 |
+ if((unsigned int)fmap_readn(map, dest, 0, ssize) != ssize) { |
|
1873 | 1873 |
cli_dbgmsg("Upack: Can't read raw data of section 0\n"); |
1874 | 1874 |
free(dest); |
1875 | 1875 |
break; |
... | ... |
@@ -1877,7 +1882,7 @@ int cli_scanpe(cli_ctx *ctx) |
1877 | 1877 |
|
1878 | 1878 |
if(upack) memmove(dest + exe_sections[2].rva - exe_sections[0].rva, dest, ssize); |
1879 | 1879 |
|
1880 |
- if(fmap_readn(map, dest + exe_sections[1].rva - off, exe_sections[1].uraw, exe_sections[1].ursz) != exe_sections[1].ursz) { |
|
1880 |
+ if((unsigned int)fmap_readn(map, dest + exe_sections[1].rva - off, exe_sections[1].uraw, exe_sections[1].ursz) != exe_sections[1].ursz) { |
|
1881 | 1881 |
cli_dbgmsg("Upack: Can't read raw data of section 1\n"); |
1882 | 1882 |
free(dest); |
1883 | 1883 |
break; |
... | ... |
@@ -2052,7 +2057,7 @@ int cli_scanpe(cli_ctx *ctx) |
2052 | 2052 |
} |
2053 | 2053 |
|
2054 | 2054 |
if((sections = (struct cli_exe_section *) cli_malloc((sectcnt + 1) * sizeof(struct cli_exe_section))) == NULL) { |
2055 |
- cli_errmsg("FSG: Unable to allocate memory for sections %u\n", (sectcnt + 1) * sizeof(struct cli_exe_section)); |
|
2055 |
+ cli_errmsg("FSG: Unable to allocate memory for sections %lu\n", (sectcnt + 1) * sizeof(struct cli_exe_section)); |
|
2056 | 2056 |
free(exe_sections); |
2057 | 2057 |
return CL_EMEM; |
2058 | 2058 |
} |
... | ... |
@@ -2156,7 +2161,7 @@ int cli_scanpe(cli_ctx *ctx) |
2156 | 2156 |
} |
2157 | 2157 |
|
2158 | 2158 |
if((sections = (struct cli_exe_section *) cli_malloc((sectcnt + 1) * sizeof(struct cli_exe_section))) == NULL) { |
2159 |
- cli_errmsg("FSG: Unable to allocate memory for sections %u\n", (sectcnt + 1) * sizeof(struct cli_exe_section)); |
|
2159 |
+ cli_errmsg("FSG: Unable to allocate memory for sections %lu\n", (sectcnt + 1) * sizeof(struct cli_exe_section)); |
|
2160 | 2160 |
free(exe_sections); |
2161 | 2161 |
return CL_EMEM; |
2162 | 2162 |
} |
... | ... |
@@ -2239,7 +2244,7 @@ int cli_scanpe(cli_ctx *ctx) |
2239 | 2239 |
|
2240 | 2240 |
if(epbuff[1] != '\xbe' || skew <= 0 || skew > 0xfff) { /* FIXME: legit skews?? */ |
2241 | 2241 |
skew = 0; |
2242 |
- } else if (skew > ssize) { |
|
2242 |
+ } else if ((unsigned int)skew > ssize) { |
|
2243 | 2243 |
/* Ignore suggested skew larger than section size */ |
2244 | 2244 |
skew = 0; |
2245 | 2245 |
} else { |
... | ... |
@@ -2395,7 +2400,7 @@ int cli_scanpe(cli_ctx *ctx) |
2395 | 2395 |
|
2396 | 2396 |
for(i = 0 ; i < nsections; i++) { |
2397 | 2397 |
if(exe_sections[i].raw) { |
2398 |
- if(!exe_sections[i].rsz || fmap_readn(map, dest + exe_sections[i].rva - min, exe_sections[i].raw, exe_sections[i].ursz) != exe_sections[i].ursz) { |
|
2398 |
+ if(!exe_sections[i].rsz || (unsigned int)fmap_readn(map, dest + exe_sections[i].rva - min, exe_sections[i].raw, exe_sections[i].ursz) != exe_sections[i].ursz) { |
|
2399 | 2399 |
free(exe_sections); |
2400 | 2400 |
free(dest); |
2401 | 2401 |
return CL_CLEAN; |
... | ... |
@@ -2549,7 +2554,7 @@ int cli_scanpe(cli_ctx *ctx) |
2549 | 2549 |
for(i = 0 ; i < (unsigned int)nsections-1; i++) { |
2550 | 2550 |
if(!exe_sections[i].rsz) continue; |
2551 | 2551 |
if(!CLI_ISCONTAINED(src, ssize, src+exe_sections[i].rva, exe_sections[i].rsz)) break; |
2552 |
- if(fmap_readn(map, src+exe_sections[i].rva, exe_sections[i].raw, exe_sections[i].rsz)!=exe_sections[i].rsz) break; |
|
2552 |
+ if((unsigned int)fmap_readn(map, src+exe_sections[i].rva, exe_sections[i].raw, exe_sections[i].rsz)!=exe_sections[i].rsz) break; |
|
2553 | 2553 |
} |
2554 | 2554 |
if(i+1!=nsections) { |
2555 | 2555 |
cli_dbgmsg("WWpack: Probably hacked/damaged file.\n"); |
... | ... |
@@ -2599,7 +2604,7 @@ int cli_scanpe(cli_ctx *ctx) |
2599 | 2599 |
for(i = 0 ; i < (unsigned int)nsections; i++) { |
2600 | 2600 |
if(!exe_sections[i].rsz) continue; |
2601 | 2601 |
if(!CLI_ISCONTAINED(src, ssize, src+exe_sections[i].rva, exe_sections[i].rsz)) break; |
2602 |
- if(fmap_readn(map, src+exe_sections[i].rva, exe_sections[i].raw, exe_sections[i].rsz)!=exe_sections[i].rsz) break; |
|
2602 |
+ if((unsigned int)fmap_readn(map, src+exe_sections[i].rva, exe_sections[i].raw, exe_sections[i].rsz)!=exe_sections[i].rsz) break; |
|
2603 | 2603 |
} |
2604 | 2604 |
if(i!=nsections) { |
2605 | 2605 |
cli_dbgmsg("Aspack: Probably hacked/damaged Aspack file.\n"); |
... | ... |
@@ -2743,7 +2748,7 @@ int cli_peheader(fmap_t *map, struct cli_exe_info *peinfo) |
2743 | 2743 |
struct pe_image_optional_hdr32 opt32; |
2744 | 2744 |
} pe_opt; |
2745 | 2745 |
struct pe_image_section_hdr *section_hdr; |
2746 |
- int i; |
|
2746 |
+ unsigned int i; |
|
2747 | 2747 |
unsigned int err, pe_plus = 0; |
2748 | 2748 |
uint32_t valign, falign, hdr_size; |
2749 | 2749 |
size_t fsize; |
... | ... |
@@ -2939,7 +2944,7 @@ int cli_peheader(fmap_t *map, struct cli_exe_info *peinfo) |
2939 | 2939 |
if(vinfo_sz <= 6 + 0x20 + 2 + 0x34 || |
2940 | 2940 |
vinfo_val_sz != 0x34 || |
2941 | 2941 |
memcmp(vptr+6, "V\0S\0_\0V\0E\0R\0S\0I\0O\0N\0_\0I\0N\0F\0O\0\0\0", 0x20) || |
2942 |
- cli_readint32(vptr + 0x28) != 0xfeef04bd) { |
|
2942 |
+ (unsigned int)cli_readint32(vptr + 0x28) != 0xfeef04bd) { |
|
2943 | 2943 |
/* - there should be enough room for the header(6), the key "VS_VERSION_INFO"(20), the padding(2) and the value(34) |
2944 | 2944 |
* - the value should be sizeof(fixedfileinfo) |
2945 | 2945 |
* - the key should match |
... | ... |
@@ -3162,7 +3167,7 @@ int cli_checkfp_pe(cli_ctx *ctx, uint8_t *authsha1, stats_section_t *hashes, uin |
3162 | 3162 |
} else { /* PE+ */ |
3163 | 3163 |
size_t readlen = sizeof(struct pe_image_optional_hdr64) - sizeof(struct pe_image_optional_hdr32); |
3164 | 3164 |
/* read the remaining part of the header */ |
3165 |
- if(fmap_readn(map, &optional_hdr32 + 1, at, readlen) != readlen) |
|
3165 |
+ if((size_t)fmap_readn(map, &optional_hdr32 + 1, at, readlen) != readlen) |
|
3166 | 3166 |
return CL_EFORMAT; |
3167 | 3167 |
|
3168 | 3168 |
at += sizeof(struct pe_image_optional_hdr64) - sizeof(struct pe_image_optional_hdr32); |
... | ... |
@@ -3257,12 +3262,12 @@ int cli_checkfp_pe(cli_ctx *ctx, uint8_t *authsha1, stats_section_t *hashes, uin |
3257 | 3257 |
return CL_EFORMAT; \ |
3258 | 3258 |
} \ |
3259 | 3259 |
if (flags & CL_CHECKFP_PE_FLAG_AUTHENTICODE && hashctx) \ |
3260 |
- cl_update_hash(hashctx, hptr, size); \ |
|
3260 |
+ cl_update_hash(hashctx, (void *)hptr, size); \ |
|
3261 | 3261 |
if (isStatAble && flags & CL_CHECKFP_PE_FLAG_STATS) { \ |
3262 | 3262 |
void *md5ctx; \ |
3263 | 3263 |
md5ctx = cl_hash_init("md5"); \ |
3264 | 3264 |
if (md5ctx) { \ |
3265 |
- cl_update_hash(md5ctx, hptr, size); \ |
|
3265 |
+ cl_update_hash(md5ctx, (void *)hptr, size); \ |
|
3266 | 3266 |
cl_finish_hash(md5ctx, hashes->sections[section].md5); \ |
3267 | 3267 |
} \ |
3268 | 3268 |
} \ |
... | ... |
@@ -3314,7 +3319,7 @@ int cli_checkfp_pe(cli_ctx *ctx, uint8_t *authsha1, stats_section_t *hashes, uin |
3314 | 3314 |
} |
3315 | 3315 |
|
3316 | 3316 |
while (flags & CL_CHECKFP_PE_FLAG_AUTHENTICODE) { |
3317 |
- if(at < fsize) { |
|
3317 |
+ if((size_t)at < fsize) { |
|
3318 | 3318 |
hlen = fsize - at; |
3319 | 3319 |
if(dirs[4].Size > hlen) { |
3320 | 3320 |
if (flags & CL_CHECKFP_PE_FLAG_STATS) { |
... | ... |
@@ -67,7 +67,9 @@ int cli_groupiconscan(struct ICON_ENV *icon_env, uint32_t rva); |
67 | 67 |
static int groupicon_scan_cb(void *ptr, uint32_t type, uint32_t name, uint32_t lang, uint32_t rva) { |
68 | 68 |
struct ICON_ENV *icon_env = ptr; |
69 | 69 |
int ret = CL_CLEAN; |
70 |
- type = type; lang = lang; /* Prevent compiler warnings regarding unused variables */ |
|
70 |
+ |
|
71 |
+ UNUSEDPARAM(type); |
|
72 |
+ UNUSEDPARAM(lang); |
|
71 | 73 |
|
72 | 74 |
cli_dbgmsg("groupicon_cb: scanning group %x\n", name); |
73 | 75 |
if(!icon_env->gcnt || icon_env->lastg == name) { |
... | ... |
@@ -89,8 +91,10 @@ static int parseicon(struct ICON_ENV *icon_env, uint32_t rva); |
89 | 89 |
|
90 | 90 |
static int icon_scan_cb(void *ptr, uint32_t type, uint32_t name, uint32_t lang, uint32_t rva) { |
91 | 91 |
struct ICON_ENV *icon_env = ptr; |
92 |
- type = type; lang = lang; /* Prevent compiler warnings regarding unused variables */ |
|
93 |
- //cli_dbgmsg("icon_cb: scanning icon %x\n", name); |
|
92 |
+ |
|
93 |
+ UNUSEDPARAM(type); |
|
94 |
+ UNUSEDPARAM(lang); |
|
95 |
+ UNUSEDPARAM(name); |
|
94 | 96 |
|
95 | 97 |
/* scan icon */ |
96 | 98 |
icon_env->result = parseicon(icon_env, rva); |
... | ... |
@@ -164,7 +168,6 @@ int cli_scanicon(icon_groupset *set, uint32_t resdir_rva, cli_ctx *ctx, struct c |
164 | 164 |
int cli_groupiconscan(struct ICON_ENV *icon_env, uint32_t rva) |
165 | 165 |
{ |
166 | 166 |
/* import environment */ |
167 |
- icon_groupset *set = icon_env->set; |
|
168 | 167 |
uint32_t resdir_rva = icon_env->resdir_rva; |
169 | 168 |
cli_ctx *ctx = icon_env->ctx; |
170 | 169 |
struct cli_exe_section *exe_sections = icon_env->exe_sections; |
... | ... |
@@ -173,7 +176,7 @@ int cli_groupiconscan(struct ICON_ENV *icon_env, uint32_t rva) |
173 | 173 |
|
174 | 174 |
int err = 0; |
175 | 175 |
fmap_t *map = *ctx->fmap; |
176 |
- const uint8_t *grp = fmap_need_off_once(map, cli_rawaddr(rva, exe_sections, nsections, &err, map->len, hdr_size), 16); |
|
176 |
+ const uint8_t *grp = fmap_need_off_once(map, cli_rawaddr(rva, exe_sections, nsections, (unsigned int *)(&err), map->len, hdr_size), 16); |
|
177 | 177 |
|
178 | 178 |
if(grp && !err) { |
179 | 179 |
uint32_t gsz = cli_readint32(grp + 4); |
... | ... |
@@ -191,7 +194,7 @@ int cli_groupiconscan(struct ICON_ENV *icon_env, uint32_t rva) |
191 | 191 |
uint16_t id; |
192 | 192 |
} *dir; |
193 | 193 |
|
194 |
- raddr = cli_rawaddr(cli_readint32(grp), exe_sections, nsections, &err, map->len, hdr_size); |
|
194 |
+ raddr = cli_rawaddr(cli_readint32(grp), exe_sections, nsections, (unsigned int *)(&err), map->len, hdr_size); |
|
195 | 195 |
cli_dbgmsg("cli_scanicon: icon group @%x\n", raddr); |
196 | 196 |
grp = fmap_need_off_once(map, raddr, gsz); |
197 | 197 |
if(grp && !err) { |
... | ... |
@@ -776,7 +779,7 @@ static void makebmp(const char *step, const char *tempd, int w, int h, void *dat |
776 | 776 |
return; |
777 | 777 |
} |
778 | 778 |
|
779 |
- for(y=h-1; y<h; y--) |
|
779 |
+ for(y=h-1; y<(unsigned int)h; y--) |
|
780 | 780 |
#if WORDS_BIGENDIAN == 0 |
781 | 781 |
if(!fwrite(&((unsigned int *)data)[y*w], w*4, 1, f)) |
782 | 782 |
break; |
... | ... |
@@ -793,7 +796,7 @@ static void makebmp(const char *step, const char *tempd, int w, int h, void *dat |
793 | 793 |
} |
794 | 794 |
#endif |
795 | 795 |
fclose(f); |
796 |
- if(y<h) |
|
796 |
+ if(y<(unsigned int)h) |
|
797 | 797 |
cli_unlink(fname); |
798 | 798 |
else |
799 | 799 |
cli_dbgmsg("makebmp: Image %s dumped to %s\n", step, fname); |
... | ... |
@@ -1047,7 +1050,7 @@ static int getmetrics(unsigned int side, unsigned int *imagedata, struct icomtr |
1047 | 1047 |
#ifdef USE_FLOATS |
1048 | 1048 |
sobel = cli_malloc(side * side * sizeof(double)); |
1049 | 1049 |
if(!sobel) { |
1050 |
- cli_errmsg("getmetrics: Unable to allocate memory for edge detection %u\n", (side * side * sizeof(double))); |
|
1050 |
+ cli_errmsg("getmetrics: Unable to allocate memory for edge detection %lu\n", (side * side * sizeof(double))); |
|
1051 | 1051 |
free(tmp); |
1052 | 1052 |
return CL_EMEM; |
1053 | 1053 |
} |
... | ... |
@@ -1341,7 +1344,7 @@ static int parseicon(struct ICON_ENV *icon_env, uint32_t rva) { |
1341 | 1341 |
return CL_SUCCESS; |
1342 | 1342 |
} |
1343 | 1343 |
|
1344 |
- if(READ32(bmphdr.sz) < sizeof(bmphdr)) { |
|
1344 |
+ if((size_t)READ32(bmphdr.sz) < sizeof(bmphdr)) { |
|
1345 | 1345 |
icon_env->err_bhts++; |
1346 | 1346 |
//cli_dbgmsg("parseicon: BMP header too small\n"); |
1347 | 1347 |
return CL_SUCCESS; |
... | ... |
@@ -1193,6 +1193,8 @@ static int hash_match(const struct regex_matcher *rlist, const char *host, size_ |
1193 | 1193 |
s[hlen+plen] = '\0'; |
1194 | 1194 |
cli_dbgmsg("hash lookup for: %s\n",s); |
1195 | 1195 |
#endif |
1196 |
+ UNUSEDPARAM(prefix_matched); |
|
1197 |
+ |
|
1196 | 1198 |
if(rlist->sha256_hashes.bm_patterns) { |
1197 | 1199 |
const char hexchars[] = "0123456789ABCDEF"; |
1198 | 1200 |
unsigned char h[65]; |
... | ... |
@@ -1204,8 +1206,8 @@ static int hash_match(const struct regex_matcher *rlist, const char *host, size_ |
1204 | 1204 |
if (!(sha256)) |
1205 | 1205 |
return CL_EMEM; |
1206 | 1206 |
|
1207 |
- cl_update_hash(sha256, host, hlen); |
|
1208 |
- cl_update_hash(sha256, path, plen); |
|
1207 |
+ cl_update_hash(sha256, (void *)host, hlen); |
|
1208 |
+ cl_update_hash(sha256, (void *)path, plen); |
|
1209 | 1209 |
cl_finish_hash(sha256, sha256_dig); |
1210 | 1210 |
|
1211 | 1211 |
for(i=0;i<32;i++) { |
... | ... |
@@ -56,11 +56,6 @@ typedef unsigned long ulg; |
56 | 56 |
#define CRITICAL(chunkID) (!ANCILLARY(chunkID)) |
57 | 57 |
#define PUBLIC(chunkID) (!PRIVATE(chunkID)) |
58 | 58 |
|
59 |
-/* what the PNG, MNG and JNG magic numbers should be */ |
|
60 |
-static const uch good_PNG_magic[8] = {137, 80, 78, 71, 13, 10, 26, 10}; |
|
61 |
-static const uch good_MNG_magic[8] = {138, 77, 78, 71, 13, 10, 26, 10}; |
|
62 |
-static const uch good_JNG_magic[8] = {139, 74, 78, 71, 13, 10, 26, 10}; |
|
63 |
- |
|
64 | 59 |
/* GRR FIXME: could merge all three of these into single table (bit fields) */ |
65 | 60 |
|
66 | 61 |
/* GRR 20061203: for "isalpha()" that works even on EBCDIC machines */ |
... | ... |
@@ -51,13 +51,13 @@ int prtn_intxn_list_check(prtn_intxn_list_t* list, unsigned *pitxn, off_t start, |
51 | 51 |
(*pitxn)--; |
52 | 52 |
|
53 | 53 |
if (start > check_node->Start) { |
54 |
- if (check_node->Start+check_node->Size > start) { |
|
54 |
+ if (check_node->Start+check_node->Size > (unsigned long)start) { |
|
55 | 55 |
ret = CL_VIRUS; |
56 | 56 |
break; |
57 | 57 |
} |
58 | 58 |
} |
59 | 59 |
else if (start < check_node->Start) { |
60 |
- if (start+size > check_node->Start) { |
|
60 |
+ if (start+size > (unsigned long)(check_node->Start)) { |
|
61 | 61 |
ret = CL_VIRUS; |
62 | 62 |
break; |
63 | 63 |
} |
... | ... |
@@ -348,6 +348,7 @@ int cli_initroots(struct cl_engine *engine, unsigned int options) |
348 | 348 |
int i, ret; |
349 | 349 |
struct cli_matcher *root; |
350 | 350 |
|
351 |
+ UNUSEDPARAM(options); |
|
351 | 352 |
|
352 | 353 |
for(i = 0; i < CLI_MTARGETS; i++) { |
353 | 354 |
if(!engine->root[i]) { |
... | ... |
@@ -546,6 +547,7 @@ static int cli_loaddb(FILE *fs, struct cl_engine *engine, unsigned int *signo, u |
546 | 546 |
int ret = 0; |
547 | 547 |
struct cli_matcher *root; |
548 | 548 |
|
549 |
+ UNUSEDPARAM(dbname); |
|
549 | 550 |
|
550 | 551 |
if((ret = cli_initroots(engine, options))) |
551 | 552 |
return ret; |
... | ... |
@@ -900,6 +902,7 @@ static int cli_loadndb(FILE *fs, struct cl_engine *engine, unsigned int *signo, |
900 | 900 |
unsigned short target; |
901 | 901 |
unsigned int phish = options & CL_DB_PHISHING; |
902 | 902 |
|
903 |
+ UNUSEDPARAM(dbname); |
|
903 | 904 |
|
904 | 905 |
if((ret = cli_initroots(engine, options))) |
905 | 906 |
return ret; |
... | ... |
@@ -1243,6 +1246,8 @@ static int load_oneldb(char *buffer, int chkpua, struct cl_engine *engine, unsig |
1243 | 1243 |
uint32_t lsigid[2]; |
1244 | 1244 |
int ret; |
1245 | 1245 |
|
1246 |
+ UNUSEDPARAM(dbname); |
|
1247 |
+ |
|
1246 | 1248 |
tokens_count = cli_strtokenize(buffer, ';', LDB_TOKENS + 1, (const char **) tokens); |
1247 | 1249 |
if(tokens_count < 4) { |
1248 | 1250 |
return CL_EMALFDB; |
... | ... |
@@ -1850,6 +1855,8 @@ static int cli_loadign(FILE *fs, struct cl_engine *engine, unsigned int options, |
1850 | 1850 |
struct cli_bm_patt *new; |
1851 | 1851 |
int ret = CL_SUCCESS; |
1852 | 1852 |
|
1853 |
+ UNUSEDPARAM(options); |
|
1854 |
+ |
|
1853 | 1855 |
if(!engine->ignored) { |
1854 | 1856 |
engine->ignored = (struct cli_matcher *) mpool_calloc(engine->mempool, 1, sizeof(struct cli_matcher)); |
1855 | 1857 |
if(!engine->ignored) |
... | ... |
@@ -2000,7 +2007,7 @@ static int cli_loadhash(FILE *fs, struct cl_engine *engine, unsigned int *signo, |
2000 | 2000 |
continue; |
2001 | 2001 |
if(tokens_count == MD5_TOKENS) { |
2002 | 2002 |
int max_fl = atoi(tokens[MD5_TOKENS - 1]); |
2003 |
- if(cl_retflevel() > max_fl) |
|
2003 |
+ if(cl_retflevel() > (unsigned int)max_fl) |
|
2004 | 2004 |
continue; |
2005 | 2005 |
} |
2006 | 2006 |
} |
... | ... |
@@ -2085,6 +2092,7 @@ static int cli_loadmd(FILE *fs, struct cl_engine *engine, unsigned int *signo, i |
2085 | 2085 |
int ret = CL_SUCCESS; |
2086 | 2086 |
struct cli_cdb *new; |
2087 | 2087 |
|
2088 |
+ UNUSEDPARAM(dbname); |
|
2088 | 2089 |
|
2089 | 2090 |
if(engine->ignored) |
2090 | 2091 |
if(!(buffer_cpy = cli_malloc(FILEBUFF))) { |
... | ... |
@@ -2418,12 +2426,11 @@ static int cli_loadcdb(FILE *fs, struct cl_engine *engine, unsigned int *signo, |
2418 | 2418 |
static int cli_loadcrt(FILE *fs, struct cl_engine *engine, struct cli_dbio *dbio) { |
2419 | 2419 |
char buffer[FILEBUFF]; |
2420 | 2420 |
char *tokens[CRT_TOKENS+1]; |
2421 |
- size_t line=0, tokens_count, i, j; |
|
2421 |
+ size_t line=0, tokens_count; |
|
2422 | 2422 |
cli_crt ca; |
2423 | 2423 |
int ret=CL_SUCCESS; |
2424 |
- char *subject=NULL, *pubkey=NULL, *exponent=NULL, *serial=NULL; |
|
2424 |
+ char *subject=NULL, *pubkey=NULL, *serial=NULL; |
|
2425 | 2425 |
const uint8_t exp[] = "\x01\x00\x01"; |
2426 |
- char c; |
|
2427 | 2426 |
|
2428 | 2427 |
cli_crt_init(&ca); |
2429 | 2428 |
memset(ca.issuer, 0xca, sizeof(ca.issuer)); |
... | ... |
@@ -2512,7 +2519,7 @@ static int cli_loadcrt(FILE *fs, struct cl_engine *engine, struct cli_dbio *dbio |
2512 | 2512 |
} |
2513 | 2513 |
|
2514 | 2514 |
memcpy(ca.subject, subject, sizeof(ca.subject)); |
2515 |
- if (mp_read_unsigned_bin(&(ca.n), pubkey, strlen(tokens[4])/2) || mp_read_unsigned_bin(&(ca.e), exp, sizeof(exp)-1)) { |
|
2515 |
+ if (mp_read_unsigned_bin(&(ca.n), (const unsigned char *)pubkey, strlen(tokens[4])/2) || mp_read_unsigned_bin(&(ca.e), exp, sizeof(exp)-1)) { |
|
2516 | 2516 |
cli_errmsg("cli_loadcrt: line %u: Cannot convert exponent to binary data\n", (unsigned int)line); |
2517 | 2517 |
ret = CL_EMALFDB; |
2518 | 2518 |
goto end; |
... | ... |
@@ -2587,6 +2594,9 @@ end: |
2587 | 2587 |
static int cli_loadmscat(FILE *fs, const char *dbname, struct cl_engine *engine, unsigned int options, struct cli_dbio *dbio) { |
2588 | 2588 |
fmap_t *map; |
2589 | 2589 |
|
2590 |
+ UNUSEDPARAM(options); |
|
2591 |
+ UNUSEDPARAM(dbio); |
|
2592 |
+ |
|
2590 | 2593 |
if(!(map = fmap(fileno(fs), 0, 0))) { |
2591 | 2594 |
cli_dbgmsg("Can't map cat: %s\n", dbname); |
2592 | 2595 |
return 0; |
... | ... |
@@ -448,12 +448,12 @@ dissect(struct match *m, char *start, char *stop, sopno startst, sopno stopst) |
448 | 448 |
break; |
449 | 449 |
case OLPAREN: |
450 | 450 |
i = OPND(m->g->strip[ss]); |
451 |
- assert(0 < i && i <= m->g->nsub); |
|
451 |
+ assert(0 < i && (size_t)i <= m->g->nsub); |
|
452 | 452 |
m->pmatch[i].rm_so = sp - m->offp; |
453 | 453 |
break; |
454 | 454 |
case ORPAREN: |
455 | 455 |
i = OPND(m->g->strip[ss]); |
456 |
- assert(0 < i && i <= m->g->nsub); |
|
456 |
+ assert(0 < i && (size_t)i <= m->g->nsub); |
|
457 | 457 |
m->pmatch[i].rm_eo = sp - m->offp; |
458 | 458 |
break; |
459 | 459 |
default: /* uh oh */ |
... | ... |
@@ -572,14 +572,14 @@ backref(struct match *m, char *start, char *stop, sopno startst, sopno stopst, |
572 | 572 |
switch (OP(s)) { |
573 | 573 |
case OBACK_: /* the vilest depths */ |
574 | 574 |
i = OPND(s); |
575 |
- assert(0 < i && i <= m->g->nsub); |
|
575 |
+ assert(0 < i && (size_t)i <= m->g->nsub); |
|
576 | 576 |
if (m->pmatch[i].rm_eo == -1) |
577 | 577 |
return(NULL); |
578 | 578 |
assert(m->pmatch[i].rm_so != -1); |
579 | 579 |
len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so; |
580 | 580 |
if (len == 0 && rec++ > MAX_RECURSION) |
581 | 581 |
return(NULL); |
582 |
- assert(stop - m->beginp >= len); |
|
582 |
+ assert((size_t)(stop - m->beginp) >= len); |
|
583 | 583 |
if (sp > stop - len) |
584 | 584 |
return(NULL); /* not enough left to match */ |
585 | 585 |
ssp = m->offp + m->pmatch[i].rm_so; |
... | ... |
@@ -635,7 +635,7 @@ backref(struct match *m, char *start, char *stop, sopno startst, sopno stopst, |
635 | 635 |
break; |
636 | 636 |
case OLPAREN: /* must undo assignment if rest fails */ |
637 | 637 |
i = OPND(s); |
638 |
- assert(0 < i && i <= m->g->nsub); |
|
638 |
+ assert(0 < i && (size_t)i <= m->g->nsub); |
|
639 | 639 |
offsave = m->pmatch[i].rm_so; |
640 | 640 |
m->pmatch[i].rm_so = sp - m->offp; |
641 | 641 |
dp = backref(m, sp, stop, ss+1, stopst, lev, rec); |
... | ... |
@@ -646,7 +646,7 @@ backref(struct match *m, char *start, char *stop, sopno startst, sopno stopst, |
646 | 646 |
break; |
647 | 647 |
case ORPAREN: /* must undo assignment if rest fails */ |
648 | 648 |
i = OPND(s); |
649 |
- assert(0 < i && i <= m->g->nsub); |
|
649 |
+ assert(0 < i && (size_t)i <= m->g->nsub); |
|
650 | 650 |
offsave = m->pmatch[i].rm_eo; |
651 | 651 |
m->pmatch[i].rm_eo = sp - m->offp; |
652 | 652 |
dp = backref(m, sp, stop, ss+1, stopst, lev, rec); |
... | ... |
@@ -553,7 +553,7 @@ p_simp_re(struct parse *p, |
553 | 553 |
i = (c&~BACKSL) - '0'; |
554 | 554 |
assert(i < NPAREN); |
555 | 555 |
if (p->pend[i] != 0) { |
556 |
- assert(i <= p->g->nsub); |
|
556 |
+ assert((size_t)i <= p->g->nsub); |
|
557 | 557 |
EMIT(OBACK_, i); |
558 | 558 |
assert(p->pbegin[i] != 0); |
559 | 559 |
assert(OP(p->strip[p->pbegin[i]]) == OLPAREN); |
... | ... |
@@ -1196,6 +1196,7 @@ mcadd( struct parse *p, cset *cs, const char *cp) |
1196 | 1196 |
static void |
1197 | 1197 |
mcinvert(struct parse *p, cset *cs) |
1198 | 1198 |
{ |
1199 |
+ UNUSEDPARAM(p); |
|
1199 | 1200 |
assert(cs->multis == NULL); /* xxx */ |
1200 | 1201 |
} |
1201 | 1202 |
|
... | ... |
@@ -1209,6 +1210,7 @@ mcinvert(struct parse *p, cset *cs) |
1209 | 1209 |
static void |
1210 | 1210 |
mccase(struct parse *p, cset *cs) |
1211 | 1211 |
{ |
1212 |
+ UNUSEDPARAM(p); |
|
1212 | 1213 |
assert(cs->multis == NULL); /* xxx */ |
1213 | 1214 |
} |
1214 | 1215 |
|
... | ... |
@@ -157,7 +157,7 @@ cli_regexec(const regex_t *preg, const char *string, size_t nmatch, |
157 | 157 |
return(REG_BADPAT); |
158 | 158 |
eflags = GOODFLAGS(eflags); |
159 | 159 |
|
160 |
- if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE)) |
|
160 |
+ if ((unsigned long)(g->nstates) <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE)) |
|
161 | 161 |
return(smatcher(g, (char *)string, nmatch, pmatch, eflags)); |
162 | 162 |
else |
163 | 163 |
return(lmatcher(g, (char *)string, nmatch, pmatch, eflags)); |
... | ... |
@@ -704,6 +704,9 @@ static const u32 rcon[] = |
704 | 704 |
(ciphertext)[2] = (u8)((st) >> 8); \ |
705 | 705 |
(ciphertext)[3] = (u8)(st); } |
706 | 706 |
|
707 |
+int rijndaelSetupEncrypt(u32 *rk, const u8 *key, int keybits); |
|
708 |
+void rijndaelEncrypt(const u32 *rk, int nrounds, const u8 plaintext[16], u8 ciphertext[16]); |
|
709 |
+ |
|
707 | 710 |
/** |
708 | 711 |
* Expand the cipher key into the encryption key schedule. |
709 | 712 |
* |
... | ... |
@@ -102,6 +102,8 @@ |
102 | 102 |
#include "mbr.h" |
103 | 103 |
#include "gpt.h" |
104 | 104 |
#include "apm.h" |
105 |
+#include "ooxml.h" |
|
106 |
+#include "xdp.h" |
|
105 | 107 |
#include "json_api.h" |
106 | 108 |
|
107 | 109 |
#ifdef HAVE_BZLIB_H |
... | ... |
@@ -371,6 +373,8 @@ static int cli_scanarj(cli_ctx *ctx, off_t sfx_offset, uint32_t *sfx_check) |
371 | 371 |
arj_metadata_t metadata; |
372 | 372 |
char *dir; |
373 | 373 |
|
374 |
+ UNUSEDPARAM(sfx_check); |
|
375 |
+ |
|
374 | 376 |
cli_dbgmsg("in cli_scanarj()\n"); |
375 | 377 |
|
376 | 378 |
/* generate the temporary directory */ |
... | ... |
@@ -726,15 +730,17 @@ static int cli_scanxz(cli_ctx *ctx) |
726 | 726 |
int ret = CL_CLEAN, fd, rc; |
727 | 727 |
unsigned long int size = 0; |
728 | 728 |
char *tmpname; |
729 |
- struct CLI_XZ strm = {{0}}; |
|
729 |
+ struct CLI_XZ strm; |
|
730 | 730 |
size_t off = 0; |
731 | 731 |
size_t avail; |
732 |
- unsigned char * buf = cli_malloc(CLI_XZ_OBUF_SIZE); |
|
732 |
+ unsigned char *buf; |
|
733 | 733 |
|
734 |
+ buf = cli_malloc(CLI_XZ_OBUF_SIZE); |
|
734 | 735 |
if (buf == NULL) { |
735 | 736 |
cli_errmsg("cli_scanxz: nomemory for decompress buffer.\n"); |
736 | 737 |
return CL_EMEM; |
737 | 738 |
} |
739 |
+ memset(&strm, 0x00, sizeof(struct CLI_XZ)); |
|
738 | 740 |
strm.next_out = buf; |
739 | 741 |
strm.avail_out = CLI_XZ_OBUF_SIZE; |
740 | 742 |
rc = cli_XzInit(&strm); |
... | ... |
@@ -783,7 +789,7 @@ static int cli_scanxz(cli_ctx *ctx) |
783 | 783 |
//cli_dbgmsg("Writing %li bytes to XZ decompress temp file(%li byte total)\n", |
784 | 784 |
// towrite, size); |
785 | 785 |
|
786 |
- if(cli_writen(fd, buf, towrite) != towrite) { |
|
786 |
+ if((size_t)cli_writen(fd, buf, towrite) != towrite) { |
|
787 | 787 |
cli_errmsg("cli_scanxz: Can't write to file.\n"); |
788 | 788 |
ret = CL_EWRITE; |
789 | 789 |
goto xz_exit; |
... | ... |
@@ -2164,12 +2170,12 @@ static inline void perf_nested_stop(cli_ctx* ctx, int id, int nestedid) |
2164 | 2164 |
|
2165 | 2165 |
|
2166 | 2166 |
#else |
2167 |
-static inline void perf_init(cli_ctx* ctx) {} |
|
2168 |
-static inline void perf_start(cli_ctx* ctx, int id){} |
|
2169 |
-static inline void perf_stop(cli_ctx* ctx, int id){} |
|
2170 |
-static inline void perf_nested_start(cli_ctx* ctx, int id, int nestedid){} |
|
2171 |
-static inline void perf_nested_stop(cli_ctx* ctx, int id, int nestedid){} |
|
2172 |
-static inline void perf_done(cli_ctx* ctx){} |
|
2167 |
+static inline void perf_init(cli_ctx* ctx) { UNUSEDPARAM(ctx); } |
|
2168 |
+static inline void perf_start(cli_ctx* ctx, int id){ UNUSEDPARAM(ctx); UNUSEDPARAM(id); } |
|
2169 |
+static inline void perf_stop(cli_ctx* ctx, int id){ UNUSEDPARAM(ctx); UNUSEDPARAM(id); } |
|
2170 |
+static inline void perf_nested_start(cli_ctx* ctx, int id, int nestedid){ UNUSEDPARAM(ctx); UNUSEDPARAM(id); UNUSEDPARAM(nestedid); } |
|
2171 |
+static inline void perf_nested_stop(cli_ctx* ctx, int id, int nestedid){ UNUSEDPARAM(ctx); UNUSEDPARAM(id); UNUSEDPARAM(nestedid); } |
|
2172 |
+static inline void perf_done(cli_ctx* ctx){ UNUSEDPARAM(ctx); } |
|
2173 | 2173 |
#endif |
2174 | 2174 |
|
2175 | 2175 |
|
... | ... |
@@ -2203,6 +2209,9 @@ static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_ |
2203 | 2203 |
|
2204 | 2204 |
while(fpt) { |
2205 | 2205 |
if(fpt->offset) switch(fpt->type) { |
2206 |
+ case CL_TYPE_XDP: |
|
2207 |
+ ret = cli_scanxdp(ctx); |
|
2208 |
+ break; |
|
2206 | 2209 |
case CL_TYPE_RARSFX: |
2207 | 2210 |
if(type != CL_TYPE_RAR && have_rar && SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_RAR)) { |
2208 | 2211 |
char *tmpname = NULL; |
... | ... |
@@ -2452,7 +2461,12 @@ static int magic_scandesc_cleanup(cli_ctx *ctx, cli_file_t type, unsigned char * |
2452 | 2452 |
{ |
2453 | 2453 |
#if HAVE_JSON |
2454 | 2454 |
ctx->wrkproperty = (struct json_object *)(parent_property); |
2455 |
+#else |
|
2456 |
+ UNUSEDPARAM(parent_property); |
|
2455 | 2457 |
#endif |
2458 |
+ |
|
2459 |
+ UNUSEDPARAM(type); |
|
2460 |
+ |
|
2456 | 2461 |
cli_dbgmsg("cli_magic_scandesc: returning %d %s\n", retcode, __AT__); |
2457 | 2462 |
if(ctx->engine->cb_post_scan) { |
2458 | 2463 |
perf_start(ctx, PERFT_POSTCB); |
... | ... |
@@ -2487,6 +2501,10 @@ static int dispatch_prescan(clcb_pre_scan cb, cli_ctx *ctx, const char *filetype |
2487 | 2487 |
{ |
2488 | 2488 |
int res=CL_CLEAN; |
2489 | 2489 |
|
2490 |
+ UNUSEDPARAM(parent_property); |
|
2491 |
+ UNUSEDPARAM(hash); |
|
2492 |
+ UNUSEDPARAM(hashed_size); |
|
2493 |
+ |
|
2490 | 2494 |
*run_cleanup = 0; |
2491 | 2495 |
|
2492 | 2496 |
if(cb) { |
... | ... |
@@ -2572,7 +2590,7 @@ static int magic_scandesc(cli_ctx *ctx, cli_file_t type) |
2572 | 2572 |
|
2573 | 2573 |
#if HAVE_JSON |
2574 | 2574 |
if (ctx->options & CL_SCAN_FILE_PROPERTIES) { |
2575 |
- json_object *arrobj, *ftobj, *fsobj; |
|
2575 |
+ json_object *arrobj; |
|
2576 | 2576 |
|
2577 | 2577 |
if (NULL == ctx->properties) { |
2578 | 2578 |
if (type == CL_TYPE_PDF || /* file types we collect properties about */ |
... | ... |
@@ -2728,6 +2746,10 @@ static int magic_scandesc(cli_ctx *ctx, cli_file_t type) |
2728 | 2728 |
case CL_TYPE_IGNORED: |
2729 | 2729 |
break; |
2730 | 2730 |
|
2731 |
+ case CL_TYPE_XDP: |
|
2732 |
+ ret = cli_scanxdp(ctx); |
|
2733 |
+ break; |
|
2734 |
+ |
|
2731 | 2735 |
case CL_TYPE_RAR: |
2732 | 2736 |
ctx->container_type = CL_TYPE_RAR; |
2733 | 2737 |
if(have_rar && SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_RAR)) { |
... | ... |
@@ -3205,7 +3227,7 @@ int cli_map_scan(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx, cli_ |
3205 | 3205 |
|
3206 | 3206 |
cli_dbgmsg("cli_map_scan: [%ld, +%lu)\n", |
3207 | 3207 |
(long)offset, (unsigned long)length); |
3208 |
- if (offset < 0 || offset >= old_len) { |
|
3208 |
+ if (offset < 0 || (size_t)offset >= old_len) { |
|
3209 | 3209 |
cli_dbgmsg("Invalid offset: %ld\n", (long)offset); |
3210 | 3210 |
return CL_CLEAN; |
3211 | 3211 |
} |
... | ... |
@@ -3285,7 +3307,7 @@ int cli_map_scandesc(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx, |
3285 | 3285 |
cli_dbgmsg("cli_map_scandesc: [%ld, +%lu), [%ld, +%lu)\n", |
3286 | 3286 |
(long)old_off, (unsigned long)old_len, |
3287 | 3287 |
(long)offset, (unsigned long)length); |
3288 |
- if (offset < 0 || offset >= old_len) { |
|
3288 |
+ if (offset < 0 || (size_t)offset >= old_len) { |
|
3289 | 3289 |
cli_dbgmsg("Invalid offset: %ld\n", (long)offset); |
3290 | 3290 |
return CL_CLEAN; |
3291 | 3291 |
} |
... | ... |
@@ -206,7 +206,7 @@ static char *getsistring(fmap_t *map, uint32_t ptr, uint32_t len) { |
206 | 206 |
cli_dbgmsg("SIS: OOM\n"); |
207 | 207 |
return NULL; |
208 | 208 |
} |
209 |
- if (fmap_readn(map, name, ptr, len) != len) { |
|
209 |
+ if ((uint32_t)fmap_readn(map, name, ptr, len) != len) { |
|
210 | 210 |
cli_dbgmsg("SIS: Unable to read string\n"); |
211 | 211 |
free(name); |
212 | 212 |
return NULL; |
... | ... |
@@ -310,7 +310,7 @@ static int real_scansis(cli_ctx *ctx, const char *tmpd) { |
310 | 310 |
return CL_CLEAN; |
311 | 311 |
} |
312 | 312 |
for (i = 0; i< sis.langs; i++) |
313 |
- alangs[i]=EC16(llangs[i])<MAXLANG ? sislangs[EC16(llangs[i])] : sislangs[0]; |
|
313 |
+ alangs[i]=(size_t)EC16(llangs[i])<MAXLANG ? sislangs[EC16(llangs[i])] : sislangs[0]; |
|
314 | 314 |
|
315 | 315 |
if (!sis.pnames) { |
316 | 316 |
cli_dbgmsg("SIS: Application without a name?\n"); |
... | ... |
@@ -376,7 +376,6 @@ static int real_scansis(cli_ctx *ctx, const char *tmpd) { |
376 | 376 |
const char *sftype; |
377 | 377 |
uint32_t *ptrs, *lens, *olens; |
378 | 378 |
char *fn; |
379 |
- long fpos; |
|
380 | 379 |
|
381 | 380 |
GETD(ftype); |
382 | 381 |
GETD(options); |
... | ... |
@@ -717,7 +716,7 @@ static int real_scansis9x(cli_ctx *ctx, const char *tmpd) { |
717 | 717 |
if (!(src=cli_malloc(ALIGN4(s->fsize[s->level])))) break; |
718 | 718 |
|
719 | 719 |
len = ALIGN4(s->fsize[s->level]); |
720 |
- if (fmap_readn(s->map, src, s->pos, len) != len) { |
|
720 |
+ if ((uint32_t)fmap_readn(s->map, src, s->pos, len) != len) { |
|
721 | 721 |
free(src); |
722 | 722 |
break; |
723 | 723 |
} |
... | ... |
@@ -40,6 +40,10 @@ |
40 | 40 |
#define JSON_BUFSZ 512 |
41 | 41 |
#define SAMPLE_PREFIX "sample_" |
42 | 42 |
|
43 |
+char *hex_encode(char *buf, char *data, size_t len); |
|
44 |
+char *ensure_bufsize(char *buf, size_t *oldsize, size_t used, size_t additional); |
|
45 |
+char *export_stats_to_json(struct cl_engine *engine, cli_intel_t *intel); |
|
46 |
+ |
|
43 | 47 |
char *hex_encode(char *buf, char *data, size_t len) |
44 | 48 |
{ |
45 | 49 |
size_t i; |
... | ... |
@@ -78,7 +82,7 @@ char *ensure_bufsize(char *buf, size_t *oldsize, size_t used, size_t additional) |
78 | 78 |
|
79 | 79 |
char *export_stats_to_json(struct cl_engine *engine, cli_intel_t *intel) |
80 | 80 |
{ |
81 |
- char *buf=NULL, *p, *hostid, md5[33]; |
|
81 |
+ char *buf=NULL, *hostid, md5[33]; |
|
82 | 82 |
cli_flagged_sample_t *sample; |
83 | 83 |
size_t bufsz, curused, i, j; |
84 | 84 |
|
... | ... |
@@ -146,8 +146,8 @@ static int scancws(cli_ctx *ctx, struct swf_file_hdr *hdr) |
146 | 146 |
} |
147 | 147 |
|
148 | 148 |
stream.avail_in = 0; |
149 |
- stream.next_in = inbuff; |
|
150 |
- stream.next_out = outbuff; |
|
149 |
+ stream.next_in = (Bytef *)inbuff; |
|
150 |
+ stream.next_out = (Bytef *)outbuff; |
|
151 | 151 |
stream.zalloc = (alloc_func) NULL; |
152 | 152 |
stream.zfree = (free_func) NULL; |
153 | 153 |
stream.opaque = (voidpf) 0; |
... | ... |
@@ -167,7 +167,7 @@ static int scancws(cli_ctx *ctx, struct swf_file_hdr *hdr) |
167 | 167 |
|
168 | 168 |
do { |
169 | 169 |
if(stream.avail_in == 0) { |
170 |
- stream.next_in = inbuff; |
|
170 |
+ stream.next_in = (Bytef *)inbuff; |
|
171 | 171 |
ret = fmap_readn(map, inbuff, offset, FILEBUFF); |
172 | 172 |
if(ret < 0) { |
173 | 173 |
cli_errmsg("scancws: Error reading SWF file\n"); |
... | ... |
@@ -201,7 +201,7 @@ static int scancws(cli_ctx *ctx, struct swf_file_hdr *hdr) |
201 | 201 |
} |
202 | 202 |
outsize += count; |
203 | 203 |
} |
204 |
- stream.next_out = outbuff; |
|
204 |
+ stream.next_out = (Bytef *)outbuff; |
|
205 | 205 |
stream.avail_out = FILEBUFF; |
206 | 206 |
} while(zret == Z_OK); |
207 | 207 |
|
... | ... |
@@ -22,8 +22,6 @@ |
22 | 22 |
#include "clamav-config.h" |
23 | 23 |
#endif |
24 | 24 |
|
25 |
-static char const rcsid[] = "$Id: tnef.c,v 1.41 2007/02/12 22:22:27 njh Exp $"; |
|
26 |
- |
|
27 | 25 |
#include <stdio.h> |
28 | 26 |
#include <fcntl.h> |
29 | 27 |
|
... | ... |
@@ -68,8 +66,6 @@ cli_tnef(const char *dir, cli_ctx *ctx) |
68 | 68 |
fileblob *fb; |
69 | 69 |
int ret, alldone; |
70 | 70 |
off_t fsize, pos = 0; |
71 |
- STATBUF statb; |
|
72 |
- |
|
73 | 71 |
|
74 | 72 |
fsize = ctx->fmap[0]->len; |
75 | 73 |
|
... | ... |
@@ -204,7 +200,6 @@ cli_tnef(const char *dir, cli_ctx *ctx) |
204 | 204 |
static int |
205 | 205 |
tnef_message(fmap_t *map, off_t *pos, uint16_t type, uint16_t tag, int32_t length, off_t fsize) |
206 | 206 |
{ |
207 |
- uint16_t i16; |
|
208 | 207 |
off_t offset; |
209 | 208 |
#ifdef CL_DEBUG |
210 | 209 |
uint32_t i32; |
... | ... |
@@ -252,7 +247,7 @@ tnef_message(fmap_t *map, off_t *pos, uint16_t type, uint16_t tag, int32_t lengt |
252 | 252 |
cli_errmsg("tnef_message: Unable to allocate memory for string\n"); |
253 | 253 |
return -1; |
254 | 254 |
} |
255 |
- if(fmap_readn(map, string, *pos, (uint32_t)length) != (uint32_t)length) { |
|
255 |
+ if((uint32_t)fmap_readn(map, string, *pos, (uint32_t)length) != (uint32_t)length) { |
|
256 | 256 |
free(string); |
257 | 257 |
return -1; |
258 | 258 |
} |
... | ... |
@@ -285,7 +280,6 @@ static int |
285 | 285 |
tnef_attachment(fmap_t *map, off_t *pos, uint16_t type, uint16_t tag, int32_t length, const char *dir, fileblob **fbref, off_t fsize) |
286 | 286 |
{ |
287 | 287 |
uint32_t todo; |
288 |
- uint16_t i16; |
|
289 | 288 |
off_t offset; |
290 | 289 |
char *string; |
291 | 290 |
|
... | ... |
@@ -303,7 +297,7 @@ tnef_attachment(fmap_t *map, off_t *pos, uint16_t type, uint16_t tag, int32_t le |
303 | 303 |
cli_errmsg("tnef_attachment: Unable to allocate memory for string\n"); |
304 | 304 |
return -1; |
305 | 305 |
} |
306 |
- if(fmap_readn(map, string, *pos, (uint32_t)length) != (uint32_t)length) { |
|
306 |
+ if((uint32_t)fmap_readn(map, string, *pos, (uint32_t)length) != (uint32_t)length) { |
|
307 | 307 |
free(string); |
308 | 308 |
return -1; |
309 | 309 |
} |
... | ... |
@@ -273,7 +273,7 @@ static int make_table(arj_decode_t *decode_data, int nchar, unsigned char *bitle |
273 | 273 |
if (i != (unsigned short) (1 << 16)) { |
274 | 274 |
k = 1 << tablebits; |
275 | 275 |
while (i != k) { |
276 |
- if (i >= tablesize) { |
|
276 |
+ if (i >= (unsigned int)tablesize) { |
|
277 | 277 |
cli_dbgmsg("UNARJ: bounds exceeded\n"); |
278 | 278 |
decode_data->status = CL_EUNPACK; |
279 | 279 |
return CL_EUNPACK; |
... | ... |
@@ -588,7 +588,7 @@ static int decode(arj_metadata_t *metadata) |
588 | 588 |
cli_dbgmsg("UNARJ: bounds exceeded - probably a corrupted file.\n"); |
589 | 589 |
break; |
590 | 590 |
} |
591 |
- if (out_ptr > i && out_ptr < DDICSIZ - MAXMATCH - 1) { |
|
591 |
+ if (out_ptr > (uint32_t)i && out_ptr < DDICSIZ - MAXMATCH - 1) { |
|
592 | 592 |
while ((--j >= 0) && (i < DDICSIZ) && (out_ptr < DDICSIZ)) { |
593 | 593 |
decode_data.text[out_ptr++] = decode_data.text[i++]; |
594 | 594 |
} |
... | ... |
@@ -779,7 +779,7 @@ static int arj_unstore(arj_metadata_t *metadata, int ofd, uint32_t len) |
779 | 779 |
return CL_EFORMAT; |
780 | 780 |
} |
781 | 781 |
metadata->offset += count; |
782 |
- if (cli_writen(ofd, data, count) != count) { |
|
782 |
+ if ((size_t)cli_writen(ofd, data, count) != count) { |
|
783 | 783 |
/* File writing problem */ |
784 | 784 |
return CL_EWRITE; |
785 | 785 |
} |
... | ... |
@@ -807,7 +807,6 @@ static int is_arj_archive(arj_metadata_t *metadata) |
807 | 807 |
static int arj_read_main_header(arj_metadata_t *metadata) |
808 | 808 |
{ |
809 | 809 |
uint16_t header_size, count; |
810 |
- uint32_t crc; |
|
811 | 810 |
arj_main_hdr_t main_hdr; |
812 | 811 |
const char *filename, *comment; |
813 | 812 |
off_t header_offset; |
... | ... |
@@ -984,6 +983,7 @@ static int arj_read_file_header(arj_metadata_t *metadata) |
984 | 984 |
|
985 | 985 |
int cli_unarj_open(fmap_t *map, const char *dirname, arj_metadata_t *metadata, size_t off) |
986 | 986 |
{ |
987 |
+ UNUSEDPARAM(dirname); |
|
987 | 988 |
cli_dbgmsg("in cli_unarj_open\n"); |
988 | 989 |
metadata->map = map; |
989 | 990 |
metadata->offset = off; |
... | ... |
@@ -1014,7 +1014,6 @@ int cli_unarj_prepare_file(const char *dirname, arj_metadata_t *metadata) |
1014 | 1014 |
|
1015 | 1015 |
int cli_unarj_extract_file(const char *dirname, arj_metadata_t *metadata) |
1016 | 1016 |
{ |
1017 |
- off_t offset; |
|
1018 | 1017 |
int ret = CL_SUCCESS; |
1019 | 1018 |
char filename[1024]; |
1020 | 1019 |
|
... | ... |
@@ -18,8 +18,6 @@ |
18 | 18 |
* MA 02110-1301, USA. |
19 | 19 |
*/ |
20 | 20 |
|
21 |
-static char const rcsid[] = "$Id: untar.c,v 1.35 2007/02/12 20:46:09 njh Exp $"; |
|
22 |
- |
|
23 | 21 |
#if HAVE_CONFIG_H |
24 | 22 |
#include "clamav-config.h" |
25 | 23 |
#endif |
... | ... |
@@ -316,7 +314,7 @@ cli_untar(const char *dir, unsigned int posix, cli_ctx *ctx) |
316 | 316 |
char err[128]; |
317 | 317 |
|
318 | 318 |
nbytes = size>512? 512:size; |
319 |
- if (nread && nread < nbytes) |
|
319 |
+ if (nread && nread < (size_t)nbytes) |
|
320 | 320 |
nbytes = nread; |
321 | 321 |
|
322 | 322 |
if (limitnear > 0) { |
... | ... |
@@ -501,7 +501,7 @@ int cli_unzip(cli_ctx *ctx) { |
501 | 501 |
|
502 | 502 |
cli_dbgmsg("in cli_unzip\n"); |
503 | 503 |
fsize = (uint32_t)map->len; |
504 |
- if(sizeof(off_t)!=sizeof(uint32_t) && (off_t)fsize!=map->len) { |
|
504 |
+ if(sizeof(off_t)!=sizeof(uint32_t) && (size_t)fsize!=map->len) { |
|
505 | 505 |
cli_dbgmsg("cli_unzip: file too big\n"); |
506 | 506 |
return CL_CLEAN; |
507 | 507 |
} |
... | ... |
@@ -585,7 +585,7 @@ int unzip_single_internal(cli_ctx *ctx, off_t lhoffl, zip_cb zcb) |
585 | 585 |
|
586 | 586 |
cli_dbgmsg("in cli_unzip_single\n"); |
587 | 587 |
fsize = (uint32_t)(map->len - lhoffl); |
588 |
- if (lhoffl<0 || lhoffl>map->len || (sizeof(off_t)!=sizeof(uint32_t) && (off_t)fsize!=map->len - lhoffl)) { |
|
588 |
+ if (lhoffl<0 || (size_t)lhoffl>map->len || (sizeof(off_t)!=sizeof(uint32_t) && (size_t)fsize!=map->len - lhoffl)) { |
|
589 | 589 |
cli_dbgmsg("cli_unzip: bad offset\n"); |
590 | 590 |
return CL_CLEAN; |
591 | 591 |
} |
... | ... |
@@ -623,7 +623,7 @@ int unzip_search(cli_ctx *ctx, const char *name, size_t nlen, uint32_t *loff) |
623 | 623 |
|
624 | 624 |
map = *ctx->fmap; |
625 | 625 |
fsize = map->len; |
626 |
- if(sizeof(off_t)!=sizeof(uint32_t) && (off_t)fsize!=map->len) { |
|
626 |
+ if(sizeof(off_t)!=sizeof(uint32_t) && fsize!=map->len) { |
|
627 | 627 |
cli_dbgmsg("unzip_search: file too big\n"); |
628 | 628 |
return CL_CLEAN; |
629 | 629 |
} |
... | ... |
@@ -661,7 +661,7 @@ int unzip_search(cli_ctx *ctx, const char *name, size_t nlen, uint32_t *loff) |
661 | 661 |
ret=CL_EMAXFILES; |
662 | 662 |
} |
663 | 663 |
#if HAVE_JSON |
664 |
- if (cli_json_timeout_cycle_check(ctx, &toval) != CL_SUCCESS) { |
|
664 |
+ if (cli_json_timeout_cycle_check(ctx, (int *)(&toval)) != CL_SUCCESS) { |
|
665 | 665 |
return CL_ETIMEOUT; |
666 | 666 |
} |
667 | 667 |
#endif |
... | ... |
@@ -31,6 +31,7 @@ typedef int (*zip_cb)(int fd, cli_ctx *ctx); |
31 | 31 |
#include "others.h" |
32 | 32 |
int cli_unzip(cli_ctx *); |
33 | 33 |
int cli_unzip_single_internal(cli_ctx *, off_t, zip_cb); |
34 |
+int unzip_single_internal(cli_ctx *ctx, off_t lhoffl, zip_cb zcb); |
|
34 | 35 |
int cli_unzip_single(cli_ctx *, off_t); |
35 | 36 |
int unzip_search(cli_ctx *, const char *, size_t, uint32_t *); |
36 | 37 |
|
... | ... |
@@ -318,7 +318,7 @@ int unupack(int upack, char *dest, uint32_t dsize, char *buff, uint32_t vma, uin |
318 | 318 |
save1 = cli_readint32(loc_esi); /* loc_eax = 0x400 */ |
319 | 319 |
loc_esi += 4; |
320 | 320 |
|
321 |
- for (j=0; j<count; j++, loc_edi+=4) /* checked above */ |
|
321 |
+ for (j=0; (uint32_t)j<count; j++, loc_edi+=4) /* checked above */ |
|
322 | 322 |
cli_writeint32(loc_edi, (save1)); |
323 | 323 |
|
324 | 324 |
if (!CLI_ISCONTAINED(dest, dsize, (loc_esi+0x10), 4)) |
... | ... |
@@ -363,7 +363,7 @@ int unupack(int upack, char *dest, uint32_t dsize, char *buff, uint32_t vma, uin |
363 | 363 |
for (j=0; j<4; j++, loc_edi+=4) |
364 | 364 |
cli_writeint32(loc_edi, (1)); |
365 | 365 |
|
366 |
- for (j=0; j<count; j++, loc_edi+=4) |
|
366 |
+ for (j=0; (uint32_t)j<count; j++, loc_edi+=4) |
|
367 | 367 |
cli_writeint32(loc_edi, 0x400); |
368 | 368 |
|
369 | 369 |
loc_edi = dest + cli_readint32(loc_esi) - base; /* read checked above */ |
... | ... |
@@ -244,7 +244,7 @@ int wwunpack(uint8_t *exe, uint32_t exesz, uint8_t *wwsect, struct cli_exe_secti |
244 | 244 |
} |
245 | 245 |
|
246 | 246 |
memset(structs, 0, 0x28); |
247 |
- error = cli_writen(desc, exe, exesz)!=exesz; |
|
247 |
+ error = (uint32_t)cli_writen(desc, exe, exesz)!=exesz; |
|
248 | 248 |
} |
249 | 249 |
return error; |
250 | 250 |
} |
... | ... |
@@ -264,7 +264,7 @@ void submit_post(const char *host, const char *port, const char *method, const c |
264 | 264 |
|
265 | 265 |
cli_dbgmsg("stats - Connected to %s:%s\n", host, port); |
266 | 266 |
|
267 |
- if (send(sockfd, buf, strlen(buf), 0) != strlen(buf)) { |
|
267 |
+ if ((size_t)send(sockfd, buf, strlen(buf), 0) != (size_t)strlen(buf)) { |
|
268 | 268 |
closesocket(sockfd); |
269 | 269 |
free(buf); |
270 | 270 |
return; |
... | ... |
@@ -417,12 +417,14 @@ int cli_scanxar(cli_ctx *ctx) |
417 | 417 |
fmap_t *map = *ctx->fmap; |
418 | 418 |
long length, offset, size, at; |
419 | 419 |
int encoding; |
420 |
- z_stream strm = {0}; |
|
420 |
+ z_stream strm; |
|
421 | 421 |
char *toc, *tmpname; |
422 | 422 |
xmlTextReaderPtr reader = NULL; |
423 | 423 |
int a_hash, e_hash; |
424 | 424 |
unsigned char *a_cksum = NULL, *e_cksum = NULL; |
425 | 425 |
|
426 |
+ memset(&strm, 0x00, sizeof(z_stream)); |
|
427 |
+ |
|
426 | 428 |
/* retrieve xar header */ |
427 | 429 |
if (fmap_readn(*ctx->fmap, &hdr, 0, sizeof(hdr)) != sizeof(hdr)) { |
428 | 430 |
cli_dbgmsg("cli_scanxar: Invalid header, too short.\n"); |
... | ... |
@@ -572,7 +574,7 @@ int cli_scanxar(cli_ctx *ctx) |
572 | 572 |
break; |
573 | 573 |
} |
574 | 574 |
|
575 |
- while (at < map->len && at < offset+hdr.toc_length_compressed+hdr.size+length) { |
|
575 |
+ while ((size_t)at < map->len && (unsigned long)at < offset+hdr.toc_length_compressed+hdr.size+length) { |
|
576 | 576 |
unsigned long avail_in; |
577 | 577 |
void * next_in; |
578 | 578 |
unsigned int bytes = MIN(map->len - at, map->pgsz); |
... | ... |
@@ -672,7 +674,7 @@ int cli_scanxar(cli_ctx *ctx) |
672 | 672 |
|
673 | 673 |
at += CLI_LZMA_HDR_SIZE; |
674 | 674 |
in_remaining -= CLI_LZMA_HDR_SIZE; |
675 |
- while (at < map->len && at < offset+hdr.toc_length_compressed+hdr.size+length) { |
|
675 |
+ while ((size_t)at < map->len && (unsigned long)at < offset+hdr.toc_length_compressed+hdr.size+length) { |
|
676 | 676 |
SizeT avail_in; |
677 | 677 |
SizeT avail_out; |
678 | 678 |
void * next_in; |
... | ... |
@@ -751,7 +753,7 @@ int cli_scanxar(cli_ctx *ctx) |
751 | 751 |
unsigned long write_len; |
752 | 752 |
|
753 | 753 |
if (ctx->engine->maxfilesize) |
754 |
- write_len = MIN(ctx->engine->maxfilesize, length); |
|
754 |
+ write_len = MIN((size_t)(ctx->engine->maxfilesize), (size_t)length); |
|
755 | 755 |
else |
756 | 756 |
write_len = length; |
757 | 757 |
|
758 | 758 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,155 @@ |
0 |
+/* |
|
1 |
+ * Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved. |
|
2 |
+ * |
|
3 |
+ * Author: Shawn Webb |
|
4 |
+ * |
|
5 |
+ * This program is free software; you can redistribute it and/or modify |
|
6 |
+ * it under the terms of the GNU General Public License version 2 as |
|
7 |
+ * published by the Free Software Foundation. |
|
8 |
+ * |
|
9 |
+ * This program is distributed in the hope that it will be useful, |
|
10 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
+ * GNU General Public License for more details. |
|
13 |
+ * |
|
14 |
+ * You should have received a copy of the GNU General Public License |
|
15 |
+ * along with this program; if not, write to the Free Software |
|
16 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
17 |
+ * MA 02110-1301, USA. |
|
18 |
+ * |
|
19 |
+ * In addition, as a special exception, the copyright holders give |
|
20 |
+ * permission to link the code of portions of this program with the |
|
21 |
+ * OpenSSL library under certain conditions as described in each |
|
22 |
+ * individual source file, and distribute linked combinations |
|
23 |
+ * including the two. |
|
24 |
+ * |
|
25 |
+ * You must obey the GNU General Public License in all respects |
|
26 |
+ * for all of the code used other than OpenSSL. If you modify |
|
27 |
+ * file(s) with this exception, you may extend this exception to your |
|
28 |
+ * version of the file(s), but you are not obligated to do so. If you |
|
29 |
+ * do not wish to do so, delete this exception statement from your |
|
30 |
+ * version. If you delete this exception statement from all source |
|
31 |
+ * files in the program, then also delete it here. |
|
32 |
+ */ |
|
33 |
+ |
|
34 |
+#if HAVE_CONFIG_H |
|
35 |
+#include "clamav-config.h" |
|
36 |
+#endif |
|
37 |
+ |
|
38 |
+#include <stdio.h> |
|
39 |
+#include <stdlib.h> |
|
40 |
+#if !defined(_WIN32) |
|
41 |
+#include <unistd.h> |
|
42 |
+#endif |
|
43 |
+#include <errno.h> |
|
44 |
+#include "xar.h" |
|
45 |
+#include "fmap.h" |
|
46 |
+#ifdef _WIN32 |
|
47 |
+#ifndef LIBXML_WRITER_ENABLED |
|
48 |
+#define LIBXML_WRITER_ENABLED 1 |
|
49 |
+#endif |
|
50 |
+#endif |
|
51 |
+#include <libxml/xmlreader.h> |
|
52 |
+#include "clamav.h" |
|
53 |
+#include "fmap.h" |
|
54 |
+#include "str.h" |
|
55 |
+#include "scanners.h" |
|
56 |
+#include "conv.h" |
|
57 |
+#include "xdp.h" |
|
58 |
+ |
|
59 |
+char *dump_xdp(cli_ctx *ctx, const char *start, size_t sz) |
|
60 |
+{ |
|
61 |
+ int fd; |
|
62 |
+ char *filename; |
|
63 |
+ size_t nwritten=0; |
|
64 |
+ ssize_t writeret; |
|
65 |
+ |
|
66 |
+ if (cli_gentempfd(ctx->engine->tmpdir, &filename, &fd) != CL_SUCCESS) |
|
67 |
+ return NULL; |
|
68 |
+ |
|
69 |
+ while (nwritten < sz) { |
|
70 |
+ writeret = write(fd, start+nwritten, sz-nwritten); |
|
71 |
+ if (writeret < 0) { |
|
72 |
+ if (errno == EAGAIN) |
|
73 |
+ continue; |
|
74 |
+ |
|
75 |
+ close(fd); |
|
76 |
+ cli_unlink(filename); |
|
77 |
+ free(filename); |
|
78 |
+ |
|
79 |
+ return NULL; |
|
80 |
+ } |
|
81 |
+ |
|
82 |
+ nwritten += writeret; |
|
83 |
+ } |
|
84 |
+ |
|
85 |
+ cli_dbgmsg("dump_xdp: Dumped payload to %s\n", filename); |
|
86 |
+ |
|
87 |
+ close(fd); |
|
88 |
+ |
|
89 |
+ return filename; |
|
90 |
+} |
|
91 |
+ |
|
92 |
+int cli_scanxdp(cli_ctx *ctx) |
|
93 |
+{ |
|
94 |
+#if HAVE_LIBXML2 |
|
95 |
+ xmlTextReaderPtr reader = NULL; |
|
96 |
+ fmap_t *map = *(ctx->fmap); |
|
97 |
+ const char *buf; |
|
98 |
+ const xmlChar *name, *value; |
|
99 |
+ char *decoded; |
|
100 |
+ size_t decodedlen; |
|
101 |
+ int rc = CL_SUCCESS; |
|
102 |
+ int fd; |
|
103 |
+ char *dumpname; |
|
104 |
+ |
|
105 |
+ buf = (const char *)fmap_need_off_once(map, map->offset, map->len); |
|
106 |
+ if (!(buf)) |
|
107 |
+ return CL_EREAD; |
|
108 |
+ |
|
109 |
+ if (ctx->engine->keeptmp) { |
|
110 |
+ dumpname = dump_xdp(ctx, buf, map->len); |
|
111 |
+ if (dumpname) |
|
112 |
+ free(dumpname); |
|
113 |
+ } |
|
114 |
+ |
|
115 |
+ /* |
|
116 |
+ * Since a PDF file can contain embedded XDP documents, |
|
117 |
+ * it's possible that the filetyping code matched an embedded XDP document. |
|
118 |
+ * If that's the case, then xmlReaderForMemory will throw an error. For now, |
|
119 |
+ * silently ignore the error and return CL_SUCCESS so the filetyping code can |
|
120 |
+ * continue on. |
|
121 |
+ */ |
|
122 |
+ reader = xmlReaderForMemory(buf, (int)(map->len), "noname.xml", NULL, XML_PARSE_NOERROR); |
|
123 |
+ if (!(reader)) |
|
124 |
+ return CL_SUCCESS; |
|
125 |
+ |
|
126 |
+ while (xmlTextReaderRead(reader) == 1) { |
|
127 |
+ name = xmlTextReaderConstLocalName(reader); |
|
128 |
+ if (!(name)) |
|
129 |
+ continue; |
|
130 |
+ |
|
131 |
+ if (!strcmp((const char *)name, "chunk") && xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) { |
|
132 |
+ value = xmlTextReaderReadInnerXml(reader); |
|
133 |
+ if (value) { |
|
134 |
+ decoded = cl_base64_decode((char *)value, strlen((const char *)value), NULL, &decodedlen, 0); |
|
135 |
+ if (decoded) { |
|
136 |
+ rc = cli_mem_scandesc(decoded, decodedlen, ctx); |
|
137 |
+ free(decoded); |
|
138 |
+ if (rc != CL_SUCCESS || rc == CL_BREAK) { |
|
139 |
+ xmlFree(value); |
|
140 |
+ break; |
|
141 |
+ } |
|
142 |
+ } |
|
143 |
+ xmlFree(value); |
|
144 |
+ } |
|
145 |
+ } |
|
146 |
+ } |
|
147 |
+ |
|
148 |
+ xmlFreeTextReader(reader); |
|
149 |
+ |
|
150 |
+ return rc; |
|
151 |
+#else |
|
152 |
+ return CL_SUCCESS; |
|
153 |
+#endif |
|
154 |
+} |
0 | 155 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,40 @@ |
0 |
+/* |
|
1 |
+ * Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved. |
|
2 |
+ * |
|
3 |
+ * Author: Shawn Webb |
|
4 |
+ * |
|
5 |
+ * This program is free software; you can redistribute it and/or modify |
|
6 |
+ * it under the terms of the GNU General Public License version 2 as |
|
7 |
+ * published by the Free Software Foundation. |
|
8 |
+ * |
|
9 |
+ * This program is distributed in the hope that it will be useful, |
|
10 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
+ * GNU General Public License for more details. |
|
13 |
+ * |
|
14 |
+ * You should have received a copy of the GNU General Public License |
|
15 |
+ * along with this program; if not, write to the Free Software |
|
16 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
17 |
+ * MA 02110-1301, USA. |
|
18 |
+ * |
|
19 |
+ * In addition, as a special exception, the copyright holders give |
|
20 |
+ * permission to link the code of portions of this program with the |
|
21 |
+ * OpenSSL library under certain conditions as described in each |
|
22 |
+ * individual source file, and distribute linked combinations |
|
23 |
+ * including the two. |
|
24 |
+ * |
|
25 |
+ * You must obey the GNU General Public License in all respects |
|
26 |
+ * for all of the code used other than OpenSSL. If you modify |
|
27 |
+ * file(s) with this exception, you may extend this exception to your |
|
28 |
+ * version of the file(s), but you are not obligated to do so. If you |
|
29 |
+ * do not wish to do so, delete this exception statement from your |
|
30 |
+ * version. If you delete this exception statement from all source |
|
31 |
+ * files in the program, then also delete it here. |
|
32 |
+ */ |
|
33 |
+ |
|
34 |
+#ifndef _XDP_H |
|
35 |
+#define _XDP_H |
|
36 |
+ |
|
37 |
+int cli_scanxdp(cli_ctx *ctx); |
|
38 |
+ |
|
39 |
+#endif |
... | ... |
@@ -26,10 +26,13 @@ |
26 | 26 |
#include "7z/XzCrc64.h" |
27 | 27 |
#include "xz_iface.h" |
28 | 28 |
|
29 |
-void *__xz_wrap_alloc(void *unused, size_t size) { |
|
29 |
+void *__xz_wrap_alloc(void *unused, size_t size); |
|
30 |
+void __xz_wrap_free(void *unused, void *freeme); |
|
31 |
+ |
|
32 |
+void *__xz_wrap_alloc(void *unused, size_t size) { |
|
33 |
+ UNUSEDPARAM(unused); |
|
30 | 34 |
if(!size || size > CLI_MAX_ALLOCATION) |
31 | 35 |
return NULL; |
32 |
- unused = unused; |
|
33 | 36 |
if(!size || size > CLI_MAX_ALLOCATION) { |
34 | 37 |
cli_dbgmsg("xz_iface: Attempt to allocate %lu bytes exceeds CLI_MAX_ALLOCATION.\n", |
35 | 38 |
(unsigned long int) size); |
... | ... |
@@ -38,7 +41,7 @@ void *__xz_wrap_alloc(void *unused, size_t size) { |
38 | 38 |
return cli_malloc(size); |
39 | 39 |
} |
40 | 40 |
void __xz_wrap_free(void *unused, void *freeme) { |
41 |
- unused = unused; |
|
41 |
+ UNUSEDPARAM(unused); |
|
42 | 42 |
free(freeme); |
43 | 43 |
} |
44 | 44 |
|
... | ... |
@@ -31,6 +31,7 @@ |
31 | 31 |
#include <stdlib.h> |
32 | 32 |
#include <string.h> |
33 | 33 |
|
34 |
+#include "libclamav/clamav.h" |
|
34 | 35 |
#include "libclamunrar/unrar.h" |
35 | 36 |
#include "libclamunrar/unrarppm.h" |
36 | 37 |
#include "libclamunrar/unrarvm.h" |
... | ... |
@@ -43,7 +44,7 @@ |
43 | 43 |
#ifdef RAR_HIGH_DEBUG |
44 | 44 |
#define rar_dbgmsg printf |
45 | 45 |
#else |
46 |
-static void rar_dbgmsg(const char* fmt,...){} |
|
46 |
+static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); } |
|
47 | 47 |
#endif |
48 | 48 |
|
49 | 49 |
static void insert_old_dist(unpack_data_t *unpack_data, unsigned int distance) |
... | ... |
@@ -123,7 +124,7 @@ int rar_unp_read_buf(int fd, unpack_data_t *unpack_data) |
123 | 123 |
data_size = unpack_data->read_top; |
124 | 124 |
} |
125 | 125 |
/* RAR2 depends on us only reading upto the end of the current compressed file */ |
126 |
- if (unpack_data->pack_size < ((MAX_BUF_SIZE-data_size)&~0xf)) { |
|
126 |
+ if (unpack_data->pack_size < (unsigned int)(((MAX_BUF_SIZE-data_size)&~0xf))) { |
|
127 | 127 |
read_size = unpack_data->pack_size; |
128 | 128 |
} else { |
129 | 129 |
read_size = (MAX_BUF_SIZE-data_size)&~0xf; |
... | ... |
@@ -218,7 +219,7 @@ static void unp_write_buf(unpack_data_t *unpack_data) |
218 | 218 |
struct UnpackFilter *flt, *next_filter; |
219 | 219 |
struct rarvm_prepared_program *prg, *next_prg; |
220 | 220 |
uint8_t *filtered_data; |
221 |
- int i, j; |
|
221 |
+ size_t i, j; |
|
222 | 222 |
|
223 | 223 |
rar_dbgmsg("in unp_write_buf\n"); |
224 | 224 |
written_border = unpack_data->wr_ptr; |
... | ... |
@@ -395,8 +396,9 @@ static int read_tables(int fd, unpack_data_t *unpack_data) |
395 | 395 |
uint8_t bit_length[BC]; |
396 | 396 |
unsigned char table[HUFF_TABLE_SIZE]; |
397 | 397 |
unsigned int bit_field; |
398 |
- int i, length, zero_count, number, n; |
|
398 |
+ int length, zero_count, number, n; |
|
399 | 399 |
const int table_size=HUFF_TABLE_SIZE; |
400 |
+ unsigned int i; |
|
400 | 401 |
|
401 | 402 |
rar_dbgmsg("in read_tables Offset=%ld in_addr=%d read_top=%d\n", lseek(fd, 0, SEEK_CUR), |
402 | 403 |
unpack_data->in_addr, unpack_data->read_top); |
... | ... |
@@ -469,7 +471,8 @@ static int read_tables(int fd, unpack_data_t *unpack_data) |
469 | 469 |
rar_addbits(unpack_data, 7); |
470 | 470 |
} |
471 | 471 |
while (n-- > 0 && i < table_size) { |
472 |
- table[i] = table[i-1]; |
|
472 |
+ if (i>0) |
|
473 |
+ table[i] = table[i-1]; |
|
473 | 474 |
i++; |
474 | 475 |
} |
475 | 476 |
} else { |
... | ... |
@@ -539,10 +542,11 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte, |
539 | 539 |
unsigned char *vmcode, int code_size) |
540 | 540 |
{ |
541 | 541 |
rarvm_input_t rarvm_input; |
542 |
- unsigned int filter_pos, new_filter, block_start, init_mask, cur_size; |
|
542 |
+ unsigned int filter_pos, new_filter, block_start, init_mask, cur_size, data_size; |
|
543 | 543 |
struct UnpackFilter *filter, *stack_filter; |
544 |
- int i, empty_count, stack_pos, vm_codesize, static_size, data_size; |
|
544 |
+ int empty_count, stack_pos, vm_codesize, static_size; |
|
545 | 545 |
unsigned char *vm_code, *global_data; |
546 |
+ size_t i; |
|
546 | 547 |
|
547 | 548 |
rar_dbgmsg("in add_vm_code first_byte=0x%x code_size=%d\n", first_byte, code_size); |
548 | 549 |
rarvm_input.in_buf = vmcode; |
... | ... |
@@ -562,7 +566,7 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte, |
562 | 562 |
} |
563 | 563 |
rar_dbgmsg("filter_pos = %u\n", filter_pos); |
564 | 564 |
if (filter_pos > unpack_data->Filters.num_items || |
565 |
- filter_pos > unpack_data->old_filter_lengths_size) { |
|
565 |
+ filter_pos > (unsigned int)(unpack_data->old_filter_lengths_size)) { |
|
566 | 566 |
rar_dbgmsg("filter_pos check failed\n"); |
567 | 567 |
return FALSE; |
568 | 568 |
} |
... | ... |
@@ -625,7 +629,7 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte, |
625 | 625 |
if (first_byte & 0x20) { |
626 | 626 |
stack_filter->block_length = rarvm_read_data(&rarvm_input); |
627 | 627 |
} else { |
628 |
- stack_filter->block_length = filter_pos < unpack_data->old_filter_lengths_size ? |
|
628 |
+ stack_filter->block_length = filter_pos < (unsigned int)(unpack_data->old_filter_lengths_size) ? |
|
629 | 629 |
unpack_data->old_filter_lengths[filter_pos] : 0; |
630 | 630 |
} |
631 | 631 |
rar_dbgmsg("block_length=%u\n", stack_filter->block_length); |
... | ... |
@@ -660,7 +664,7 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte, |
660 | 660 |
rar_dbgmsg("unrar: add_vm_code: rar_malloc failed for vm_code\n"); |
661 | 661 |
return FALSE; |
662 | 662 |
} |
663 |
- for (i=0 ; i < vm_codesize ; i++) { |
|
663 |
+ for (i=0 ; i < (size_t)vm_codesize ; i++) { |
|
664 | 664 |
vm_code[i] = rarvm_getbits(&rarvm_input) >> 8; |
665 | 665 |
rarvm_addbits(&rarvm_input, 8); |
666 | 666 |
} |
... | ... |
@@ -122,9 +122,9 @@ static void copy_string15(unpack_data_t *unpack_data, unsigned int distance, |
122 | 122 |
static unsigned int decode_num(unpack_data_t *unpack_data, int num, unsigned int start_pos, |
123 | 123 |
unsigned int *dec_tab, unsigned int *pos_tab) |
124 | 124 |
{ |
125 |
- int i; |
|
125 |
+ unsigned int i; |
|
126 | 126 |
|
127 |
- for (num&=0xfff0, i=0 ; dec_tab[i] <= num ; i++) { |
|
127 |
+ for (num&=0xfff0, i=0 ; dec_tab[i] <= (unsigned int)num ; i++) { |
|
128 | 128 |
start_pos++; |
129 | 129 |
} |
130 | 130 |
rar_addbits(unpack_data, start_pos); |
... | ... |
@@ -19,13 +19,14 @@ |
19 | 19 |
#include <stdio.h> |
20 | 20 |
#include <string.h> |
21 | 21 |
|
22 |
+#include "libclamav/clamav.h" |
|
22 | 23 |
#include "libclamunrar/unrar.h" |
23 | 24 |
#include "libclamunrar/unrar20.h" |
24 | 25 |
|
25 | 26 |
#ifdef RAR_HIGH_DEBUG |
26 | 27 |
#define rar_dbgmsg printf |
27 | 28 |
#else |
28 |
-static void rar_dbgmsg(const char* fmt,...){} |
|
29 |
+static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); } |
|
29 | 30 |
#endif |
30 | 31 |
|
31 | 32 |
void unpack_init_data20(int solid, unpack_data_t *unpack_data) |
... | ... |
@@ -13,12 +13,13 @@ |
13 | 13 |
#include <stdio.h> |
14 | 14 |
#include <stdlib.h> |
15 | 15 |
|
16 |
+#include "libclamav/clamav.h" |
|
16 | 17 |
#include "libclamunrar/unrarhlp.h" |
17 | 18 |
|
18 | 19 |
#ifdef RAR_HIGH_DEBUG |
19 | 20 |
#define rar_dbgmsg printf |
20 | 21 |
#else |
21 |
-static void rar_dbgmsg(const char* fmt,...){} |
|
22 |
+static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); } |
|
22 | 23 |
#endif |
23 | 24 |
|
24 | 25 |
#define RAR_MAX_ALLOCATION 184549376 |
... | ... |
@@ -21,13 +21,14 @@ |
21 | 21 |
#include <stdio.h> |
22 | 22 |
#include <string.h> |
23 | 23 |
|
24 |
+#include "libclamav/clamav.h" |
|
24 | 25 |
#include "libclamunrar/unrar.h" |
25 | 26 |
#include "libclamunrar/unrarppm.h" |
26 | 27 |
|
27 | 28 |
#ifdef RAR_HIGH_DEBUG |
28 | 29 |
#define rar_dbgmsg printf |
29 | 30 |
#else |
30 |
-static void rar_dbgmsg(const char* fmt,...){} |
|
31 |
+static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); } |
|
31 | 32 |
#endif |
32 | 33 |
|
33 | 34 |
#define MAX_O 64 |
... | ... |
@@ -754,7 +755,7 @@ static void update1(ppm_data_t *ppm_data, struct state_tag *p, struct ppm_contex |
754 | 754 |
static int ppm_decode_symbol1(ppm_data_t *ppm_data, struct ppm_context *context) |
755 | 755 |
{ |
756 | 756 |
struct state_tag *p; |
757 |
- int i, hi_cnt, count; |
|
757 |
+ unsigned int i, hi_cnt, count; |
|
758 | 758 |
|
759 | 759 |
rar_dbgmsg("in ppm_decode_symbol1\n"); |
760 | 760 |
ppm_data->coder.scale = context->con_ut.u.summ_freq; |
... | ... |
@@ -867,7 +868,7 @@ static struct see2_context_tag *make_esc_freq(ppm_data_t *ppm_data, |
867 | 867 |
|
868 | 868 |
static int ppm_decode_symbol2(ppm_data_t *ppm_data, struct ppm_context *context) |
869 | 869 |
{ |
870 |
- int count, hi_cnt, i; |
|
870 |
+ unsigned int count, hi_cnt, i; |
|
871 | 871 |
struct see2_context_tag *psee2c; |
872 | 872 |
struct state_tag *ps[256], **pps, *p; |
873 | 873 |
|
... | ... |
@@ -22,6 +22,7 @@ |
22 | 22 |
#include <stdio.h> |
23 | 23 |
#include <string.h> |
24 | 24 |
|
25 |
+#include "libclamav/clamav.h" |
|
25 | 26 |
#include "libclamunrar/unrar.h" |
26 | 27 |
#include "libclamunrar/unrarvm.h" |
27 | 28 |
#include "libclamunrar/unrarcmd.h" |
... | ... |
@@ -29,7 +30,7 @@ |
29 | 29 |
#ifdef RAR_HIGH_DEBUG |
30 | 30 |
#define rar_dbgmsg printf |
31 | 31 |
#else |
32 |
-static void rar_dbgmsg(const char* fmt,...){} |
|
32 |
+static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); } |
|
33 | 33 |
#endif |
34 | 34 |
|
35 | 35 |
#define VMCF_OP0 0 |
... | ... |
@@ -155,7 +156,7 @@ const uint32_t crc_tab[256]={ |
155 | 155 |
uint32_t rar_crc(uint32_t start_crc, void *addr, uint32_t size) |
156 | 156 |
{ |
157 | 157 |
unsigned char *data; |
158 |
- int i; |
|
158 |
+ uint32_t i; |
|
159 | 159 |
|
160 | 160 |
data = addr; |
161 | 161 |
#if WORDS_BIGENDIAN == 0 |
... | ... |
@@ -264,7 +265,7 @@ unsigned int rarvm_read_data(rarvm_input_t *rarvm_input) |
264 | 264 |
static rarvm_standard_filters_t is_standard_filter(unsigned char *code, int code_size) |
265 | 265 |
{ |
266 | 266 |
uint32_t code_crc; |
267 |
- int i; |
|
267 |
+ uint32_t i; |
|
268 | 268 |
|
269 | 269 |
struct standard_filter_signature |
270 | 270 |
{ |
... | ... |
@@ -340,11 +341,12 @@ static void filter_itanium_setbits(unsigned char *data, unsigned int bit_field, |
340 | 340 |
static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_filters_t filter_type) |
341 | 341 |
{ |
342 | 342 |
unsigned char *data, cmp_byte2, cur_byte, *src_data, *dest_data; |
343 |
- int i, j, data_size, channels, src_pos, dest_pos, border, width, PosR; |
|
343 |
+ int channels, border, width, PosR; |
|
344 | 344 |
int op_type, cur_channel, byte_count, start_pos, pa, pb, pc; |
345 |
- unsigned int file_offset, cur_pos, predicted; |
|
345 |
+ unsigned int file_offset, cur_pos, predicted, data_size, src_pos, dest_pos; |
|
346 | 346 |
int32_t offset, addr; |
347 | 347 |
const int file_size=0x1000000; |
348 |
+ unsigned int i, j; |
|
348 | 349 |
|
349 | 350 |
switch(filter_type) { |
350 | 351 |
case VMSF_E8: |
... | ... |
@@ -431,7 +433,7 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil |
431 | 431 |
} |
432 | 432 |
for (cur_channel=0 ; cur_channel < channels ; cur_channel++) { |
433 | 433 |
unsigned char prev_byte = 0; |
434 |
- for (dest_pos=data_size+cur_channel ; dest_pos<border ; dest_pos+=channels) { |
|
434 |
+ for (dest_pos=data_size+cur_channel ; dest_pos<(unsigned int)border ; dest_pos+=channels) { |
|
435 | 435 |
rarvm_data->mem[dest_pos] = (prev_byte -= rarvm_data->mem[src_pos++]); |
436 | 436 |
} |
437 | 437 |
} |
... | ... |
@@ -475,7 +477,7 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil |
475 | 475 |
dest_data[i] = prev_byte = (unsigned char)(predicted-*(src_data++)); |
476 | 476 |
} |
477 | 477 |
} |
478 |
- for (i=PosR,border=data_size-2 ; i < border ; i+=3) { |
|
478 |
+ for (i=PosR,border=data_size-2 ; i < (unsigned int)border ; i+=3) { |
|
479 | 479 |
unsigned char g=dest_data[i+1]; |
480 | 480 |
dest_data[i] += g; |
481 | 481 |
dest_data[i+2] += g; |
... | ... |
@@ -649,13 +651,13 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data, |
649 | 649 |
break; |
650 | 650 |
case VM_JZ: |
651 | 651 |
if ((rarvm_data->Flags & VM_FZ) != 0) { |
652 |
- SET_IP(GET_VALUE(FALSE, op1)); |
|
652 |
+ SET_IP((int)GET_VALUE(FALSE, op1)); |
|
653 | 653 |
continue; |
654 | 654 |
} |
655 | 655 |
break; |
656 | 656 |
case VM_JNZ: |
657 | 657 |
if ((rarvm_data->Flags & VM_FZ) == 0) { |
658 |
- SET_IP(GET_VALUE(FALSE, op1)); |
|
658 |
+ SET_IP((int)GET_VALUE(FALSE, op1)); |
|
659 | 659 |
continue; |
660 | 660 |
} |
661 | 661 |
break; |
... | ... |
@@ -682,7 +684,7 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data, |
682 | 682 |
SET_VALUE(FALSE, op1, GET_VALUE(FALSE, op1)-1); |
683 | 683 |
break; |
684 | 684 |
case VM_JMP: |
685 |
- SET_IP(GET_VALUE(FALSE, op1)); |
|
685 |
+ SET_IP((int)GET_VALUE(FALSE, op1)); |
|
686 | 686 |
continue; |
687 | 687 |
case VM_XOR: |
688 | 688 |
result = UINT32(GET_VALUE(cmd->byte_mode, op1)^GET_VALUE(cmd->byte_mode, op2)); |
... | ... |
@@ -705,37 +707,37 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data, |
705 | 705 |
break; |
706 | 706 |
case VM_JS: |
707 | 707 |
if ((rarvm_data->Flags & VM_FS) != 0) { |
708 |
- SET_IP(GET_VALUE(FALSE, op1)); |
|
708 |
+ SET_IP((int)GET_VALUE(FALSE, op1)); |
|
709 | 709 |
continue; |
710 | 710 |
} |
711 | 711 |
break; |
712 | 712 |
case VM_JNS: |
713 | 713 |
if ((rarvm_data->Flags & VM_FS) == 0) { |
714 |
- SET_IP(GET_VALUE(FALSE, op1)); |
|
714 |
+ SET_IP((int)GET_VALUE(FALSE, op1)); |
|
715 | 715 |
continue; |
716 | 716 |
} |
717 | 717 |
break; |
718 | 718 |
case VM_JB: |
719 | 719 |
if ((rarvm_data->Flags & VM_FC) != 0) { |
720 |
- SET_IP(GET_VALUE(FALSE, op1)); |
|
720 |
+ SET_IP((int)GET_VALUE(FALSE, op1)); |
|
721 | 721 |
continue; |
722 | 722 |
} |
723 | 723 |
break; |
724 | 724 |
case VM_JBE: |
725 | 725 |
if ((rarvm_data->Flags & (VM_FC|VM_FZ)) != 0) { |
726 |
- SET_IP(GET_VALUE(FALSE, op1)); |
|
726 |
+ SET_IP((int)GET_VALUE(FALSE, op1)); |
|
727 | 727 |
continue; |
728 | 728 |
} |
729 | 729 |
break; |
730 | 730 |
case VM_JA: |
731 | 731 |
if ((rarvm_data->Flags & (VM_FC|VM_FZ)) == 0) { |
732 |
- SET_IP(GET_VALUE(FALSE, op1)); |
|
732 |
+ SET_IP((int)GET_VALUE(FALSE, op1)); |
|
733 | 733 |
continue; |
734 | 734 |
} |
735 | 735 |
break; |
736 | 736 |
case VM_JAE: |
737 | 737 |
if ((rarvm_data->Flags & VM_FC) == 0) { |
738 |
- SET_IP(GET_VALUE(FALSE, op1)); |
|
738 |
+ SET_IP((int)GET_VALUE(FALSE, op1)); |
|
739 | 739 |
continue; |
740 | 740 |
} |
741 | 741 |
break; |
... | ... |
@@ -753,7 +755,7 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data, |
753 | 753 |
rarvm_data->R[7] -= 4; |
754 | 754 |
SET_VALUE(FALSE, (unsigned int *)&rarvm_data->mem[rarvm_data->R[7] & |
755 | 755 |
RARVM_MEMMASK], cmd-prepared_code+1); |
756 |
- SET_IP(GET_VALUE(FALSE, op1)); |
|
756 |
+ SET_IP((int)GET_VALUE(FALSE, op1)); |
|
757 | 757 |
continue; |
758 | 758 |
case VM_NOT: |
759 | 759 |
SET_VALUE(cmd->byte_mode, op1, ~GET_VALUE(cmd->byte_mode, op1)); |
... | ... |
@@ -860,7 +862,7 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data, |
860 | 860 |
if (rarvm_data->R[7] >= RARVM_MEMSIZE) { |
861 | 861 |
return TRUE; |
862 | 862 |
} |
863 |
- SET_IP(GET_VALUE(FALSE, (unsigned int *)&rarvm_data->mem[rarvm_data->R[7] & |
|
863 |
+ SET_IP((int)GET_VALUE(FALSE, (unsigned int *)&rarvm_data->mem[rarvm_data->R[7] & |
|
864 | 864 |
RARVM_MEMMASK])); |
865 | 865 |
rarvm_data->R[7] += 4; |
866 | 866 |
continue; |
... | ... |
@@ -30,6 +30,7 @@ |
30 | 30 |
#include <unistd.h> |
31 | 31 |
#endif |
32 | 32 |
|
33 |
+#include "libclamav/clamav.h" |
|
33 | 34 |
#include "libclamunrar/unrar.h" |
34 | 35 |
|
35 | 36 |
#include "unrar_iface.h" |
... | ... |
@@ -52,7 +53,7 @@ static uint32_t unrar_endian_convert_32(uint32_t v) |
52 | 52 |
#ifdef RAR_DEBUG_MODE |
53 | 53 |
#define unrar_dbgmsg printf |
54 | 54 |
#else |
55 |
-static void unrar_dbgmsg(const char* fmt,...){} |
|
55 |
+static void unrar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); } |
|
56 | 56 |
#endif |
57 | 57 |
|
58 | 58 |
static void *read_header(int fd, header_type hdr_type) |
... | ... |
@@ -395,6 +396,7 @@ int unrar_extract_next_prepare(unrar_state_t *state, const char *dirname) |
395 | 395 |
int ofd; |
396 | 396 |
unrar_metadata_t *new_metadata; |
397 | 397 |
|
398 |
+ UNUSEDPARAM(dirname); |
|
398 | 399 |
|
399 | 400 |
state->file_header = read_block(state->fd, FILE_HEAD); |
400 | 401 |
if(!state->file_header) |
... | ... |
@@ -178,6 +178,8 @@ static int cdiff_cmd_open(const char *cmdstr, struct cdiff_ctx *ctx, char *lbuf, |
178 | 178 |
char *db; |
179 | 179 |
unsigned int i; |
180 | 180 |
|
181 |
+ UNUSEDPARAM(lbuf); |
|
182 |
+ UNUSEDPARAM(lbuflen); |
|
181 | 183 |
|
182 | 184 |
if(!(db = cdiff_token(cmdstr, 1, 1))) { |
183 | 185 |
logg("!cdiff_cmd_open: Can't get first argument\n"); |
... | ... |
@@ -207,6 +209,8 @@ static int cdiff_cmd_add(const char *cmdstr, struct cdiff_ctx *ctx, char *lbuf, |
207 | 207 |
char *sig; |
208 | 208 |
struct cdiff_node *new; |
209 | 209 |
|
210 |
+ UNUSEDPARAM(lbuf); |
|
211 |
+ UNUSEDPARAM(lbuflen); |
|
210 | 212 |
|
211 | 213 |
if(!(sig = cdiff_token(cmdstr, 1, 1))) { |
212 | 214 |
logg("!cdiff_cmd_add: Can't get first argument\n"); |
... | ... |
@@ -237,6 +241,9 @@ static int cdiff_cmd_del(const char *cmdstr, struct cdiff_ctx *ctx, char *lbuf, |
237 | 237 |
struct cdiff_node *pt, *last, *new; |
238 | 238 |
unsigned int lineno; |
239 | 239 |
|
240 |
+ UNUSEDPARAM(lbuf); |
|
241 |
+ UNUSEDPARAM(lbuflen); |
|
242 |
+ |
|
240 | 243 |
|
241 | 244 |
if(!(arg = cdiff_token(cmdstr, 1, 0))) { |
242 | 245 |
logg("!cdiff_cmd_del: Can't get first argument\n"); |
... | ... |
@@ -294,6 +301,9 @@ static int cdiff_cmd_xchg(const char *cmdstr, struct cdiff_ctx *ctx, char *lbuf, |
294 | 294 |
struct cdiff_node *new; |
295 | 295 |
unsigned int lineno; |
296 | 296 |
|
297 |
+ UNUSEDPARAM(lbuf); |
|
298 |
+ UNUSEDPARAM(lbuflen); |
|
299 |
+ |
|
297 | 300 |
|
298 | 301 |
if(!(arg = cdiff_token(cmdstr, 1, 0))) { |
299 | 302 |
logg("!cdiff_cmd_xchg: Can't get first argument\n"); |
... | ... |
@@ -340,6 +350,8 @@ static int cdiff_cmd_close(const char *cmdstr, struct cdiff_ctx *ctx, char *lbuf |
340 | 340 |
char *tmp; |
341 | 341 |
FILE *fh, *tmpfh; |
342 | 342 |
|
343 |
+ UNUSEDPARAM(cmdstr); |
|
344 |
+ |
|
343 | 345 |
|
344 | 346 |
if(!ctx->open_db) { |
345 | 347 |
logg("!cdiff_cmd_close: No database to close\n"); |
... | ... |
@@ -681,6 +693,8 @@ static int cdiff_cmd_unlink(const char *cmdstr, struct cdiff_ctx *ctx, char *lbu |
681 | 681 |
char *db; |
682 | 682 |
unsigned int i; |
683 | 683 |
|
684 |
+ UNUSEDPARAM(lbuf); |
|
685 |
+ UNUSEDPARAM(lbuflen); |
|
684 | 686 |
|
685 | 687 |
if(ctx->open_db) { |
686 | 688 |
logg("!cdiff_cmd_unlink: Database %s is still open\n", ctx->open_db); |
... | ... |
@@ -141,6 +141,7 @@ const struct clam_option __clam_options[] = { |
141 | 141 |
{ NULL, "trust-bytecode", 't', CLOPT_TYPE_BOOL, MATCH_BOOL, 1, NULL, 0, OPT_CLAMBC, "Trust loaded bytecode (default yes)", ""}, |
142 | 142 |
{ NULL, "info", 'i', CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Load and print bytecode information without executing", ""}, |
143 | 143 |
{ NULL, "printsrc", 'p', CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Print source code of bytecode", ""}, |
144 |
+ { NULL, "printbcir", 'c', CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Print bytecode representation of bytecode signature", ""}, |
|
144 | 145 |
{ NULL, "input", 'r', CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMBC, "Input file to run the bytecode n", ""}, |
145 | 146 |
{ NULL, "trace", 't', CLOPT_TYPE_NUMBER, MATCH_NUMBER, 7, NULL, 0, OPT_CLAMBC, "bytecode trace level",""}, |
146 | 147 |
{ NULL, "no-trace-showsource", 's', CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Don't show source line during tracing",""}, |
... | ... |
@@ -303,16 +303,13 @@ static char *getdsig(const char *host, const char *user, const unsigned char *da |
303 | 303 |
return NULL; |
304 | 304 |
} |
305 | 305 |
#endif |
306 |
- if(scanf("%as", &pt) == EOF || !pt) { |
|
306 |
+ if(scanf("%30s", pass) == EOF || !pt) { |
|
307 | 307 |
mprintf("!getdsig: Can't get password\n"); |
308 | 308 |
#ifdef HAVE_TERMIOS_H |
309 | 309 |
tcsetattr(0, TCSAFLUSH, &old); |
310 | 310 |
#endif |
311 | 311 |
return NULL; |
312 | 312 |
} |
313 |
- strncpy(pass, pt, sizeof(pass)); |
|
314 |
- pass[sizeof(pass)-1]='\0'; |
|
315 |
- free(pt); |
|
316 | 313 |
|
317 | 314 |
#ifdef HAVE_TERMIOS_H |
318 | 315 |
if(tcsetattr(0, TCSAFLUSH, &old)) { |
... | ... |
@@ -848,13 +845,10 @@ static int build(const struct optstruct *opts) |
848 | 848 |
builder[sizeof(builder)-1]='\0'; |
849 | 849 |
} else { |
850 | 850 |
mprintf("Builder name: "); |
851 |
- if(scanf("%as", &pt) == EOF || !pt) { |
|
851 |
+ if(scanf("%32s", builder) == EOF || !pt) { |
|
852 | 852 |
mprintf("!build: Can't get builder name\n"); |
853 | 853 |
return -1; |
854 | 854 |
} |
855 |
- strncpy(builder, pt, sizeof(builder)); |
|
856 |
- builder[sizeof(builder)-1]='\0'; |
|
857 |
- free(pt); |
|
858 | 855 |
} |
859 | 856 |
|
860 | 857 |
/* add builder */ |
... | ... |
@@ -1108,7 +1108,7 @@ static int sigtool_scandir (const char *dirname, int hex_output) |
1108 | 1108 |
|
1109 | 1109 |
int sigtool_vba_scandir (const char *dirname, int hex_output, struct uniq *U) |
1110 | 1110 |
{ |
1111 |
- int ret = CL_CLEAN, i, j, fd, data_len; |
|
1111 |
+ int ret = CL_CLEAN, i, fd, data_len; |
|
1112 | 1112 |
vba_project_t *vba_project; |
1113 | 1113 |
DIR *dd; |
1114 | 1114 |
struct dirent *dent; |
... | ... |
@@ -1116,6 +1116,7 @@ int sigtool_vba_scandir (const char *dirname, int hex_output, struct uniq *U) |
1116 | 1116 |
char *fullname, vbaname[1024], *hash; |
1117 | 1117 |
unsigned char *data; |
1118 | 1118 |
uint32_t hashcnt; |
1119 |
+ unsigned int j; |
|
1119 | 1120 |
|
1120 | 1121 |
hashcnt = uniq_get(U, "_vba_project", 12, NULL); |
1121 | 1122 |
while(hashcnt--) { |
... | ... |
@@ -1,6 +1,10 @@ |
1 | 1 |
#include <stdio.h> |
2 |
+#include "../libclamav/clamav.h" |
|
3 |
+ |
|
2 | 4 |
int main(int argc, char **argv) |
3 | 5 |
{ |
6 |
+ UNUSEDPARAM(argc); |
|
7 |
+ UNUSEDPARAM(argv); |
|
4 | 8 |
puts("\n*** Unit tests disabled in this build\n*** Use ./configure --enable-check to enable them\n"); |
5 | 9 |
/* tell automake the test was skipped */ |
6 | 10 |
return 77; |
... | ... |
@@ -18,6 +18,7 @@ |
18 | 18 |
* MA 02110-1301, USA. |
19 | 19 |
*/ |
20 | 20 |
|
21 |
+#include "../libclamav/clamav.h" |
|
21 | 22 |
#include "../libclamav/fpu.h" |
22 | 23 |
|
23 | 24 |
/* Helper command line interface to determinine fpu endianess in unit test scripts. |
... | ... |
@@ -30,5 +31,7 @@ |
30 | 30 |
|
31 | 31 |
int main (int argc, char **argv) |
32 | 32 |
{ |
33 |
+ UNUSEDPARAM(argc); |
|
34 |
+ UNUSEDPARAM(argv); |
|
33 | 35 |
return get_fpu_endian(); |
34 | 36 |
} |
... | ... |
@@ -162,7 +162,10 @@ EXPORTS cli_fmap_scandesc @44265 NONAME |
162 | 162 |
EXPORTS cli_hashset_destroy @44266 NONAME |
163 | 163 |
EXPORTS cli_detect_environment @44267 NONAME |
164 | 164 |
EXPORTS cli_filecopy @44268 NONAME |
165 |
-EXPORTS cli_checkfp_pe @44353 NONAME |
|
165 |
+EXPORTS cli_checkfp_pe @44369 NONAME |
|
166 |
+EXPORTS cli_bytefunc_describe @44370 NONAME |
|
167 |
+EXPORTS cli_bytetype_describe @44371 NONAME |
|
168 |
+EXPORTS cli_bytevalue_describe @44372 NONAME |
|
166 | 169 |
|
167 | 170 |
; compatibility layer, tommath, zlib |
168 | 171 |
EXPORTS w32_srand @44269 NONAME |
... | ... |
@@ -410,6 +410,7 @@ |
410 | 410 |
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">/D "LIBXML_STATIC" %(AdditionalOptions)</AdditionalOptions> |
411 | 411 |
</ClCompile> |
412 | 412 |
<ClCompile Include="..\libclamav\www.c" /> |
413 |
+ <ClCompile Include="..\libclamav\xdp.c" /> |
|
413 | 414 |
<ClCompile Include="..\libclamav\xz_iface.c" /> |
414 | 415 |
<ClCompile Include="..\libclamav\yc.c" /> |
415 | 416 |
<ClCompile Include="..\shared\getopt.c" /> |
... | ... |
@@ -510,6 +511,7 @@ |
510 | 510 |
<ClInclude Include="..\libclamav\stats_json.h" /> |
511 | 511 |
<ClInclude Include="..\libclamav\stats.h" /> |
512 | 512 |
<ClInclude Include="..\libclamav\www.h" /> |
513 |
+ <ClInclude Include="..\libclamav\xdp.h" /> |
|
513 | 514 |
</ItemGroup> |
514 | 515 |
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
515 | 516 |
<ImportGroup Label="ExtensionTargets"> |
... | ... |
@@ -518,4 +520,4 @@ |
518 | 518 |
<Library Include="libeay32.lib" /> |
519 | 519 |
<Library Include="ssleay32.lib" /> |
520 | 520 |
</ItemGroup> |
521 |
-</Project> |
|
521 |
+</Project> |
|
522 | 522 |
\ No newline at end of file |
... | ... |
@@ -909,6 +909,9 @@ |
909 | 909 |
<ClCompile Include="..\libclamav\pdfng.c"> |
910 | 910 |
<Filter>Source Files</Filter> |
911 | 911 |
</ClCompile> |
912 |
+ <ClCompile Include="..\libclamav\xdp.c"> |
|
913 |
+ <Filter>Source Files</Filter> |
|
914 |
+ </ClCompile> |
|
912 | 915 |
</ItemGroup> |
913 | 916 |
<ItemGroup> |
914 | 917 |
<ClInclude Include="..\libclamav\hostid.h"> |
... | ... |
@@ -926,9 +929,12 @@ |
926 | 926 |
<ClInclude Include="..\libclamav\conv.h"> |
927 | 927 |
<Filter>Source Files</Filter> |
928 | 928 |
</ClInclude> |
929 |
+ <ClInclude Include="..\libclamav\xdp.h"> |
|
930 |
+ <Filter>Source Files</Filter> |
|
931 |
+ </ClInclude> |
|
929 | 932 |
</ItemGroup> |
930 | 933 |
<ItemGroup> |
931 | 934 |
<Library Include="libeay32.lib" /> |
932 | 935 |
<Library Include="ssleay32.lib" /> |
933 | 936 |
</ItemGroup> |
934 |
-</Project> |
|
937 |
+</Project> |
|
935 | 938 |
\ No newline at end of file |
... | ... |
@@ -1,5 +1,4 @@ |
1 |
-<?xml version="1.0" encoding="utf-8"?> |
|
2 |
- |
|
1 |
+<?xml version="1.0" encoding="utf-8"?> |
|
3 | 2 |
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
4 | 3 |
<ItemGroup Label="ProjectConfigurations"> |
5 | 4 |
<ProjectConfiguration Include="Debug|Win32"> |
... | ... |
@@ -24,7 +23,7 @@ |
24 | 24 |
<Keyword>Win32Proj</Keyword> |
25 | 25 |
<RootNamespace>libclamunrar</RootNamespace> |
26 | 26 |
</PropertyGroup> |
27 |
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/> |
|
27 |
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
|
28 | 28 |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> |
29 | 29 |
<ConfigurationType>DynamicLibrary</ConfigurationType> |
30 | 30 |
<UseDebugLibraries>true</UseDebugLibraries> |
... | ... |
@@ -47,22 +46,22 @@ |
47 | 47 |
<WholeProgramOptimization>true</WholeProgramOptimization> |
48 | 48 |
<CharacterSet>MultiByte</CharacterSet> |
49 | 49 |
</PropertyGroup> |
50 |
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/> |
|
50 |
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
|
51 | 51 |
<ImportGroup Label="ExtensionSettings"> |
52 | 52 |
</ImportGroup> |
53 | 53 |
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> |
54 |
- <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> |
|
54 |
+ <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> |
|
55 | 55 |
</ImportGroup> |
56 | 56 |
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> |
57 |
- <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> |
|
57 |
+ <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> |
|
58 | 58 |
</ImportGroup> |
59 | 59 |
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> |
60 |
- <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> |
|
60 |
+ <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> |
|
61 | 61 |
</ImportGroup> |
62 | 62 |
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> |
63 |
- <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> |
|
63 |
+ <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> |
|
64 | 64 |
</ImportGroup> |
65 |
- <PropertyGroup Label="UserMacros"/> |
|
65 |
+ <PropertyGroup Label="UserMacros" /> |
|
66 | 66 |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
67 | 67 |
<LinkIncremental>true</LinkIncremental> |
68 | 68 |
<IntDir>$(SolutionDir)build\$(PlatformName)\$(ProjectName)\$(Configuration)\</IntDir> |
... | ... |
@@ -89,7 +88,7 @@ |
89 | 89 |
<WarningLevel>Level3</WarningLevel> |
90 | 90 |
<Optimization>Disabled</Optimization> |
91 | 91 |
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBCLAMUNRAR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
92 |
- <AdditionalIncludeDirectories>"$(SolutionDir)";"$(SolutionDir)compat";"$(SolutionDir)..";"$(SolutionDir)3rdparty\pthreads"</AdditionalIncludeDirectories> |
|
92 |
+ <AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)compat;$(SolutionDir)..;$(SolutionDir)3rdparty\pthreads;C:\clamdeps\win32\openssl\include</AdditionalIncludeDirectories> |
|
93 | 93 |
<DisableSpecificWarnings>4996;4018;4146;4244</DisableSpecificWarnings> |
94 | 94 |
<CompileAs>CompileAsC</CompileAs> |
95 | 95 |
</ClCompile> |
... | ... |
@@ -97,6 +96,7 @@ |
97 | 97 |
<SubSystem>Windows</SubSystem> |
98 | 98 |
<GenerateDebugInformation>true</GenerateDebugInformation> |
99 | 99 |
<ModuleDefinitionFile>$(SolutionDir)libclamunrar.def</ModuleDefinitionFile> |
100 |
+ <AdditionalLibraryDirectories>C:\clamdeps\win32\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
|
100 | 101 |
</Link> |
101 | 102 |
</ItemDefinitionGroup> |
102 | 103 |
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
... | ... |
@@ -105,7 +105,7 @@ |
105 | 105 |
<WarningLevel>Level3</WarningLevel> |
106 | 106 |
<Optimization>Disabled</Optimization> |
107 | 107 |
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBCLAMUNRAR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
108 |
- <AdditionalIncludeDirectories>"$(SolutionDir)";"$(SolutionDir)compat";"$(SolutionDir)..";"$(SolutionDir)3rdparty\pthreads"</AdditionalIncludeDirectories> |
|
108 |
+ <AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)compat;$(SolutionDir)..;$(SolutionDir)3rdparty\pthreads;C:\clamdeps\win64\openssl\include</AdditionalIncludeDirectories> |
|
109 | 109 |
<DisableSpecificWarnings>4996;4018;4146;4244;4267</DisableSpecificWarnings> |
110 | 110 |
<CompileAs>CompileAsC</CompileAs> |
111 | 111 |
</ClCompile> |
... | ... |
@@ -113,6 +113,7 @@ |
113 | 113 |
<SubSystem>Windows</SubSystem> |
114 | 114 |
<GenerateDebugInformation>true</GenerateDebugInformation> |
115 | 115 |
<ModuleDefinitionFile>$(SolutionDir)libclamunrar.def</ModuleDefinitionFile> |
116 |
+ <AdditionalLibraryDirectories>C:\clamdeps\win64\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
|
116 | 117 |
</Link> |
117 | 118 |
</ItemDefinitionGroup> |
118 | 119 |
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
... | ... |
@@ -123,7 +124,7 @@ |
123 | 123 |
<FunctionLevelLinking>true</FunctionLevelLinking> |
124 | 124 |
<IntrinsicFunctions>true</IntrinsicFunctions> |
125 | 125 |
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBCLAMUNRAR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
126 |
- <AdditionalIncludeDirectories>"$(SolutionDir)";"$(SolutionDir)compat";"$(SolutionDir)..";"$(SolutionDir)3rdparty\pthreads"</AdditionalIncludeDirectories> |
|
126 |
+ <AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)compat;$(SolutionDir)..;$(SolutionDir)3rdparty\pthreads;C:\clamdeps\win32\openssl\include</AdditionalIncludeDirectories> |
|
127 | 127 |
<DisableSpecificWarnings>4996;4018;4146;4244</DisableSpecificWarnings> |
128 | 128 |
<CompileAs>CompileAsC</CompileAs> |
129 | 129 |
</ClCompile> |
... | ... |
@@ -133,6 +134,7 @@ |
133 | 133 |
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
134 | 134 |
<OptimizeReferences>true</OptimizeReferences> |
135 | 135 |
<ModuleDefinitionFile>$(SolutionDir)libclamunrar.def</ModuleDefinitionFile> |
136 |
+ <AdditionalLibraryDirectories>C:\clamdeps\win32\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
|
136 | 137 |
</Link> |
137 | 138 |
</ItemDefinitionGroup> |
138 | 139 |
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
... | ... |
@@ -143,7 +145,7 @@ |
143 | 143 |
<FunctionLevelLinking>true</FunctionLevelLinking> |
144 | 144 |
<IntrinsicFunctions>true</IntrinsicFunctions> |
145 | 145 |
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBCLAMUNRAR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
146 |
- <AdditionalIncludeDirectories>"$(SolutionDir)";"$(SolutionDir)compat";"$(SolutionDir)..";"$(SolutionDir)3rdparty\pthreads"</AdditionalIncludeDirectories> |
|
146 |
+ <AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)compat;$(SolutionDir)..;$(SolutionDir)3rdparty\pthreads;C:\clamdeps\win64\openssl\include</AdditionalIncludeDirectories> |
|
147 | 147 |
<DisableSpecificWarnings>4996;4018;4146;4244;4267</DisableSpecificWarnings> |
148 | 148 |
<CompileAs>CompileAsC</CompileAs> |
149 | 149 |
</ClCompile> |
... | ... |
@@ -153,25 +155,26 @@ |
153 | 153 |
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
154 | 154 |
<OptimizeReferences>true</OptimizeReferences> |
155 | 155 |
<ModuleDefinitionFile>$(SolutionDir)libclamunrar.def</ModuleDefinitionFile> |
156 |
+ <AdditionalLibraryDirectories>C:\clamdeps\win64\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
|
156 | 157 |
</Link> |
157 | 158 |
</ItemDefinitionGroup> |
158 | 159 |
<ItemGroup> |
159 |
- <None Include="libclamunrar.def"/> |
|
160 |
+ <None Include="libclamunrar.def" /> |
|
160 | 161 |
</ItemGroup> |
161 | 162 |
<ItemGroup> |
162 |
- <ResourceCompile Include="res\libclamunrar.rc"/> |
|
163 |
+ <ResourceCompile Include="res\libclamunrar.rc" /> |
|
163 | 164 |
</ItemGroup> |
164 | 165 |
<ItemGroup> |
165 |
- <ClCompile Include="..\libclamunrar\unrar.c"/> |
|
166 |
- <ClCompile Include="..\libclamunrar\unrar15.c"/> |
|
167 |
- <ClCompile Include="..\libclamunrar\unrar20.c"/> |
|
168 |
- <ClCompile Include="..\libclamunrar\unrarcmd.c"/> |
|
169 |
- <ClCompile Include="..\libclamunrar\unrarfilter.c"/> |
|
170 |
- <ClCompile Include="..\libclamunrar\unrarhlp.c"/> |
|
171 |
- <ClCompile Include="..\libclamunrar\unrarppm.c"/> |
|
172 |
- <ClCompile Include="..\libclamunrar\unrarvm.c"/> |
|
166 |
+ <ClCompile Include="..\libclamunrar\unrar.c" /> |
|
167 |
+ <ClCompile Include="..\libclamunrar\unrar15.c" /> |
|
168 |
+ <ClCompile Include="..\libclamunrar\unrar20.c" /> |
|
169 |
+ <ClCompile Include="..\libclamunrar\unrarcmd.c" /> |
|
170 |
+ <ClCompile Include="..\libclamunrar\unrarfilter.c" /> |
|
171 |
+ <ClCompile Include="..\libclamunrar\unrarhlp.c" /> |
|
172 |
+ <ClCompile Include="..\libclamunrar\unrarppm.c" /> |
|
173 |
+ <ClCompile Include="..\libclamunrar\unrarvm.c" /> |
|
173 | 174 |
</ItemGroup> |
174 |
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> |
|
175 |
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
|
175 | 176 |
<ImportGroup Label="ExtensionTargets"> |
176 | 177 |
</ImportGroup> |
177 |
-</Project> |
|
178 |
+</Project> |
|
178 | 179 |
\ No newline at end of file |
... | ... |
@@ -1,5 +1,4 @@ |
1 |
-<?xml version="1.0" encoding="utf-8"?> |
|
2 |
- |
|
1 |
+<?xml version="1.0" encoding="utf-8"?> |
|
3 | 2 |
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
4 | 3 |
<ItemGroup Label="ProjectConfigurations"> |
5 | 4 |
<ProjectConfiguration Include="Debug|Win32"> |
... | ... |
@@ -24,7 +23,7 @@ |
24 | 24 |
<Keyword>Win32Proj</Keyword> |
25 | 25 |
<RootNamespace>libclamunrar_iface</RootNamespace> |
26 | 26 |
</PropertyGroup> |
27 |
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/> |
|
27 |
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
|
28 | 28 |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> |
29 | 29 |
<ConfigurationType>DynamicLibrary</ConfigurationType> |
30 | 30 |
<UseDebugLibraries>true</UseDebugLibraries> |
... | ... |
@@ -47,22 +46,22 @@ |
47 | 47 |
<WholeProgramOptimization>true</WholeProgramOptimization> |
48 | 48 |
<CharacterSet>MultiByte</CharacterSet> |
49 | 49 |
</PropertyGroup> |
50 |
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/> |
|
50 |
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
|
51 | 51 |
<ImportGroup Label="ExtensionSettings"> |
52 | 52 |
</ImportGroup> |
53 | 53 |
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> |
54 |
- <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> |
|
54 |
+ <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> |
|
55 | 55 |
</ImportGroup> |
56 | 56 |
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> |
57 |
- <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> |
|
57 |
+ <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> |
|
58 | 58 |
</ImportGroup> |
59 | 59 |
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> |
60 |
- <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> |
|
60 |
+ <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> |
|
61 | 61 |
</ImportGroup> |
62 | 62 |
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> |
63 |
- <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> |
|
63 |
+ <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> |
|
64 | 64 |
</ImportGroup> |
65 |
- <PropertyGroup Label="UserMacros"/> |
|
65 |
+ <PropertyGroup Label="UserMacros" /> |
|
66 | 66 |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
67 | 67 |
<LinkIncremental>true</LinkIncremental> |
68 | 68 |
<IntDir>$(SolutionDir)build\$(PlatformName)\$(ProjectName)\$(Configuration)\</IntDir> |
... | ... |
@@ -89,7 +88,7 @@ |
89 | 89 |
<WarningLevel>Level3</WarningLevel> |
90 | 90 |
<Optimization>Disabled</Optimization> |
91 | 91 |
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBCLAMUNRAR_IFACE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
92 |
- <AdditionalIncludeDirectories>"$(SolutionDir)";"$(SolutionDir)compat";"$(SolutionDir)..";"$(SolutionDir)3rdparty\pthreads"</AdditionalIncludeDirectories> |
|
92 |
+ <AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)compat;$(SolutionDir)..;$(SolutionDir)3rdparty\pthreads;C:\clamdeps\win32\openssl\include</AdditionalIncludeDirectories> |
|
93 | 93 |
<DisableSpecificWarnings>4996</DisableSpecificWarnings> |
94 | 94 |
<CompileAs>CompileAsC</CompileAs> |
95 | 95 |
</ClCompile> |
... | ... |
@@ -97,9 +96,10 @@ |
97 | 97 |
<SubSystem>Windows</SubSystem> |
98 | 98 |
<GenerateDebugInformation>true</GenerateDebugInformation> |
99 | 99 |
<ModuleDefinitionFile>$(SolutionDir)libclamunrar_iface.def</ModuleDefinitionFile> |
100 |
+ <AdditionalLibraryDirectories>C:\clamdeps\win32\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
|
100 | 101 |
</Link> |
101 |
- <ProjectReference/> |
|
102 |
- <ProjectReference/> |
|
102 |
+ <ProjectReference /> |
|
103 |
+ <ProjectReference /> |
|
103 | 104 |
</ItemDefinitionGroup> |
104 | 105 |
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
105 | 106 |
<ClCompile> |
... | ... |
@@ -107,7 +107,7 @@ |
107 | 107 |
<WarningLevel>Level3</WarningLevel> |
108 | 108 |
<Optimization>Disabled</Optimization> |
109 | 109 |
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBCLAMUNRAR_IFACE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
110 |
- <AdditionalIncludeDirectories>"$(SolutionDir)";"$(SolutionDir)compat";"$(SolutionDir)..";"$(SolutionDir)3rdparty\pthreads"</AdditionalIncludeDirectories> |
|
110 |
+ <AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)compat;$(SolutionDir)..;$(SolutionDir)3rdparty\pthreads;C:\clamdeps\win64\openssl\include</AdditionalIncludeDirectories> |
|
111 | 111 |
<DisableSpecificWarnings>4996;4267</DisableSpecificWarnings> |
112 | 112 |
<CompileAs>CompileAsC</CompileAs> |
113 | 113 |
</ClCompile> |
... | ... |
@@ -115,9 +115,10 @@ |
115 | 115 |
<SubSystem>Windows</SubSystem> |
116 | 116 |
<GenerateDebugInformation>true</GenerateDebugInformation> |
117 | 117 |
<ModuleDefinitionFile>$(SolutionDir)libclamunrar_iface.def</ModuleDefinitionFile> |
118 |
+ <AdditionalLibraryDirectories>C:\clamdeps\win64\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
|
118 | 119 |
</Link> |
119 |
- <ProjectReference/> |
|
120 |
- <ProjectReference/> |
|
120 |
+ <ProjectReference /> |
|
121 |
+ <ProjectReference /> |
|
121 | 122 |
</ItemDefinitionGroup> |
122 | 123 |
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
123 | 124 |
<ClCompile> |
... | ... |
@@ -127,7 +128,7 @@ |
127 | 127 |
<FunctionLevelLinking>true</FunctionLevelLinking> |
128 | 128 |
<IntrinsicFunctions>true</IntrinsicFunctions> |
129 | 129 |
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBCLAMUNRAR_IFACE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
130 |
- <AdditionalIncludeDirectories>"$(SolutionDir)";"$(SolutionDir)compat";"$(SolutionDir)..";"$(SolutionDir)3rdparty\pthreads"</AdditionalIncludeDirectories> |
|
130 |
+ <AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)compat;$(SolutionDir)..;$(SolutionDir)3rdparty\pthreads;C:\clamdeps\win32\openssl\include</AdditionalIncludeDirectories> |
|
131 | 131 |
<DisableSpecificWarnings>4996</DisableSpecificWarnings> |
132 | 132 |
<CompileAs>CompileAsC</CompileAs> |
133 | 133 |
</ClCompile> |
... | ... |
@@ -137,9 +138,10 @@ |
137 | 137 |
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
138 | 138 |
<OptimizeReferences>true</OptimizeReferences> |
139 | 139 |
<ModuleDefinitionFile>$(SolutionDir)libclamunrar_iface.def</ModuleDefinitionFile> |
140 |
+ <AdditionalLibraryDirectories>C:\clamdeps\win32\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
|
140 | 141 |
</Link> |
141 |
- <ProjectReference/> |
|
142 |
- <ProjectReference/> |
|
142 |
+ <ProjectReference /> |
|
143 |
+ <ProjectReference /> |
|
143 | 144 |
</ItemDefinitionGroup> |
144 | 145 |
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
145 | 146 |
<ClCompile> |
... | ... |
@@ -149,7 +151,7 @@ |
149 | 149 |
<FunctionLevelLinking>true</FunctionLevelLinking> |
150 | 150 |
<IntrinsicFunctions>true</IntrinsicFunctions> |
151 | 151 |
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBCLAMUNRAR_IFACE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
152 |
- <AdditionalIncludeDirectories>"$(SolutionDir)";"$(SolutionDir)compat";"$(SolutionDir)..";"$(SolutionDir)3rdparty\pthreads"</AdditionalIncludeDirectories> |
|
152 |
+ <AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)compat;$(SolutionDir)..;$(SolutionDir)3rdparty\pthreads;C:\clamdeps\win64\openssl\include</AdditionalIncludeDirectories> |
|
153 | 153 |
<DisableSpecificWarnings>4996;4267</DisableSpecificWarnings> |
154 | 154 |
<CompileAs>CompileAsC</CompileAs> |
155 | 155 |
</ClCompile> |
... | ... |
@@ -159,26 +161,27 @@ |
159 | 159 |
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
160 | 160 |
<OptimizeReferences>true</OptimizeReferences> |
161 | 161 |
<ModuleDefinitionFile>$(SolutionDir)libclamunrar_iface.def</ModuleDefinitionFile> |
162 |
+ <AdditionalLibraryDirectories>C:\clamdeps\win64\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
|
162 | 163 |
</Link> |
163 |
- <ProjectReference/> |
|
164 |
- <ProjectReference/> |
|
164 |
+ <ProjectReference /> |
|
165 |
+ <ProjectReference /> |
|
165 | 166 |
</ItemDefinitionGroup> |
166 | 167 |
<ItemGroup> |
167 |
- <None Include="libclamunrar_iface.def"/> |
|
168 |
+ <None Include="libclamunrar_iface.def" /> |
|
168 | 169 |
</ItemGroup> |
169 | 170 |
<ItemGroup> |
170 |
- <ResourceCompile Include="res\libclamunrar_iface.rc"/> |
|
171 |
+ <ResourceCompile Include="res\libclamunrar_iface.rc" /> |
|
171 | 172 |
</ItemGroup> |
172 | 173 |
<ItemGroup> |
173 |
- <ClCompile Include="..\libclamunrar_iface\unrar_iface.c"/> |
|
174 |
- <ClCompile Include="compat\snprintf.c"/> |
|
174 |
+ <ClCompile Include="..\libclamunrar_iface\unrar_iface.c" /> |
|
175 |
+ <ClCompile Include="compat\snprintf.c" /> |
|
175 | 176 |
</ItemGroup> |
176 | 177 |
<ItemGroup> |
177 | 178 |
<ProjectReference Include="libclamunrar.vcxproj"> |
178 | 179 |
<Project>{b1406d09-59ce-4eea-9f08-feccf3a7a4a7}</Project> |
179 | 180 |
</ProjectReference> |
180 | 181 |
</ItemGroup> |
181 |
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> |
|
182 |
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
|
182 | 183 |
<ImportGroup Label="ExtensionTargets"> |
183 | 184 |
</ImportGroup> |
184 |
-</Project> |
|
185 |
+</Project> |
|
185 | 186 |
\ No newline at end of file |