Browse code

Merge branch 'master' into klin/pcre_support

Conflicts:
clamconf/clamconf.c
clamscan/manager.c
docs/signatures.tex
sigtool/sigtool.c

Kevin Lin authored on 2014/11/01 00:10:41
Showing 172 changed files
... ...
@@ -1,43 +1,70 @@
1
-The ClamAV Team - http://www.clamav.net/team
1
+The ClamAV Team - http://www.clamav.net/about.html#credits 
2 2
 ============================================
3
-Joel Esler <jesler at*sourcefire.com>
4
-Nigel Houghton <nhoughton at*sourcefire.com>
5
-Tom Judge <tjudge at*sourcefire.com>
6
-Kevin Lin <klin at*sourcefire.com>
7
-Steve Morgan <smorgan at*sourcefire.com>
8
-Matt Olney <molney at*sourcefire.com>
9
-Ryan Pentney <rpentney at*sourcefire.com>
10
-Dave Raynor <draynor at*sourcefire.com>
11
-Shawn Webb <swebb at*sourcefire.com>
12
-Alain Zidouemba <azidouemba at*sourcefire.com>
3
+Joel Esler
4
+Douglas Goddard
5
+Nigel Houghton
6
+Tom Judge
7
+Kevin Lin
8
+Steve Morgan
9
+Matt Olney
10
+Dave Raynor
11
+Samir Sapra
12
+Ryan Steinmetz
13
+Dave Suffling
14
+Matt Watchinkski
15
+Shawn Webb
16
+Alain Zidouemba
13 17
 
14
-Sourcefire VRT
18
+Talos Group
15 19
 ==============
20
+Andrea Allievi
21
+Jonathan Arneson
22
+Aaron Benson
16 23
 Nathan Benson
17
-Christoph Cordes
18
-William Freeman
19
-Ethan Gulla
24
+Andrew Blunk
25
+Kevin Brooks
26
+Marjeta Cedilnik
27
+Paul Frank
28
+Douglas Goddard
29
+Nicholas Herbert
30
+Pawel Janic
20 31
 Richard Johnson
21 32
 Alex Kambis
22
-Alex Kirk
23 33
 Christopher Marshall
24 34
 Christopher McBee
25
-Alex McDonnell
35
+David McDaniel
36
+Alex McDonnel
26 37
 Kevin Miklavcic
27 38
 Patrick Mullen
39
+Marcin Noga
40
+Katie Nolan
41
+Carlos Pacho
42
+Ryan Pentney
28 43
 Nick Randolph
44
+Marcos Rodriguez
45
+Brandon Stultz
46
+Michael Verbeck
47
+Angel Villegas
29 48
 Andy Walker
49
+Yves Younan
50
+
51
+ClamAV QA
52
+===========
53
+Erin Germ
54
+Dragos Malene
55
+Vijay Mistry
56
+Matt Donnan
30 57
 
31 58
 Contributors
32 59
 ============
33
-Aeriana <aeriana at*clamav*net>
34
-Mike Cathey <mike at*clamav*net>
35
-Diego d’Ambra <diego at*clamav*net>
36
-Andreas Faust <afaust at*clamav*net>
37
-Arnaud Jacques <arnaud at*clamav*net>
38
-Tomasz Papszun <tomek at*clamav*net>
39
-Sven Strickroth <sven at*clamav*net>
40
-Trog <trog at*clamav*net>
60
+Aeriana 
61
+Mike Cathey 
62
+Diego d’Ambra 
63
+Andreas Faust 
64
+Arnaud Jacques 
65
+Tomasz Papszun 
66
+Sven Strickroth 
67
+Trog 
41 68
 
42 69
 ClamAV Emeritus
43 70
 ===============
... ...
@@ -1,12 +1,68 @@
1
+Thu, 31 Jul 2014 19:11:22 EDT (swebb)
2
+-------------------------------------
3
+* Add support for XDP PDF file format
4
+
1 5
 Thu, Jul 31 11:50:23 EDT 2014 (swebb)
2 6
 ------------------------------------
3
-* bb#10731 - Allow to specificy a group for the socket of which the user is
4
-not a member
7
+* bb#10731 - Allow specification of a group for the milter socket of which
8
+the user is not a member - patch submitted by Sebastian Andrzej Siewior
9
+
10
+Fri, 25 Jul 2014 12:26:04 EDT (klin)
11
+------------------------------------
12
+* bb#10981 - applied LLVM 3.1-3.4 - patch submitted by Andreas Cadhalpun
13
+
14
+Fri, 25 Jul 2014 12:06:13 (klin)
15
+--------------------------------
16
+* clambc: added diagnostic tools for bytecode IR
17
+
18
+Tue, 8 Jul 2014 19:53:41 EDT (swebb)
19
+------------------------------------
20
+* mass cleanup of compiler warnings
5 21
 
6 22
 Tue, 08 Jul 11:30:00 EDT 2014 (morgan)
7 23
 ------------------------------------
8 24
 * 0.98.5 beta release
9 25
 
26
+Fri, 13 Jun 2014 16:11:15 EDT (smorgan)
27
+---------------------------------------
28
+* add timeout facility for file property scanning
29
+
30
+Tue, 3 Jun 2014 13:31:50 EDT (smorgan)
31
+--------------------------------------
32
+* add callback for user processing of json string and json scan result
33
+
34
+Wed, 7 May 2014 10:56:35 EDT (swebb)
35
+------------------------------------
36
+* PE file properties collection
37
+
38
+Tue, 6 May 2014 15:26:30 EDT (klin)
39
+-----------------------------------
40
+* add api to read json to the bytecode api
41
+
42
+Thu, 1 May 2014 16:59:01 EDT (klin)
43
+-----------------------------------
44
+* docx/pptx/xlsx file properties collection
45
+
46
+Wed, 30 Apr 2014 16:38:55 EDT (swebb)
47
+-------------------------------------
48
+* pdf file properties collection
49
+
50
+Tue, 22 Apr 2014 14:22:39 EDT (klin)
51
+------------------------------------
52
+* json api wrapper
53
+
54
+Mon, 21 Apr 2014 18:30:28 EDT (klin)
55
+------------------------------------
56
+* doc/ppt/xls file properties collection
57
+
58
+Wed, 16 Apr 18:14:45 2014 EDT (smorgan)
59
+--------------------------------------
60
+* Initial libjson-c configure/build support and json file properties work
61
+
62
+---------------------------------
63
+Beginning of 0.98.5 Development |
64
+---------------------------------
65
+
10 66
 Mon, 12 May 17:30:00 EDT 2014 (morgan)
11 67
 ------------------------------------
12 68
 * 0.98.4 release
... ...
@@ -12926,7 +12982,6 @@ Mon May  1 19:54:57 CEST 2006 (tk)
12926 12926
 ----------------------------------
12927 12927
   * freshclam/manager.c: fix possible buffer overflow
12928 12928
     Reported by Ulf Harnhammar <metaur*telia.com> and Peter <remllov_*gmx.de>
12929
-    See http://www.clamav.net/security/0.88.2.html for details.
12930 12929
 
12931 12930
 Sun Apr 30 19:23:35 BST 2006 (njh)
12932 12931
 ----------------------------------
... ...
@@ -18553,8 +18608,7 @@ Tue Feb 10 17:05:31 GMT 2004 (njh)
18553 18553
 
18554 18554
 Tue Feb 10 14:38:35 GMT 2004 (njh)
18555 18555
 ----------------------------------
18556
-  * contrib:	Removed mfc30d.dll. It can now be downloaded (if needed)
18557
-	from http://www.clamav.net/w32/mfc30d.zip
18556
+  * contrib:	Removed mfc30d.dll. 
18558 18557
 
18559 18558
 Tue Feb 10 14:35:07 CET 2004 (tk)
18560 18559
 ---------------------------------
... ...
@@ -1 +1 @@
1
-See clamdoc.pdf or http://www.clamav.net/support/faq
1
+See clamdoc.pdf or http://www.clamav.net/documentation.html 
... ...
@@ -409,6 +409,9 @@ JSON_LIBS = @JSON_LIBS@
409 409
 LCOV = @LCOV@
410 410
 LD = @LD@
411 411
 LDFLAGS = @LDFLAGS@
412
+LEX = @LEX@
413
+LEXLIB = @LEXLIB@
414
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
412 415
 LIBADD_DL = @LIBADD_DL@
413 416
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
414 417
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -471,6 +474,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
471 471
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
472 472
 XML_CPPFLAGS = @XML_CPPFLAGS@
473 473
 XML_LIBS = @XML_LIBS@
474
+YACC = @YACC@
475
+YFLAGS = @YFLAGS@
474 476
 abs_builddir = @abs_builddir@
475 477
 abs_srcdir = @abs_srcdir@
476 478
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -11,6 +11,27 @@ optional.
11 11
 Look for our upcoming series of blog posts to learn more about using the
12 12
 ClamAV API and bytecode facilities for collecting and analyzing file
13 13
 properties.
14
- 
14
+
15
+ClamAV 0.98.5 also includes these new features:
16
+
17
+    - Support for the XDP file format and extracting, decoding, and
18
+      scanning PDF files within XDP files.
19
+    - Addition of shared library support for LLVM verions 3.1 - 3.4
20
+      for the purpose of just-in-time(JIT) compilation of ClamAV
21
+      bytecode signatures. Andreas Cadhalpun submitted the patch
22
+      implementing this support.
23
+    - Enhancements to the clambc command line utility to assist
24
+      ClamAV bytecode signature authors by providing introspection
25
+      into compiled bytecode programs.
26
+    - Resolution of many of the warning messages from ClamAV compilation.
27
+    - Bug fixes and other feature enhancements. See Changelog or
28
+      git log for details.
29
+
30
+Thanks to the following ClamAV community members for code submissions
31
+and bug reporting included in ClamAV 0.98.5:
32
+
33
+Andreas Cadhalpun
34
+Sebastian Andrzej Siewior
35
+
15 36
 --
16
-The ClamAV team (http://www.clamav.net/team)
37
+The ClamAV team (http://www.clamav.net/about.html#credits)
... ...
@@ -16,6 +16,27 @@ Look for our upcoming series of blog posts to learn more about using the
16 16
 ClamAV API and bytecode facilities for collecting and analyzing file
17 17
 properties.
18 18
 
19
+ClamAV 0.98.5 also includes these new features:
20
+
21
+    - Support for the XDP file format and extracting, decoding, and
22
+      scanning PDF files within XDP files.
23
+    - Addition of shared library support for LLVM verions 3.1 - 3.4
24
+      for the purpose of just-in-time(JIT) compilation of ClamAV
25
+      bytecode signatures. Andreas Cadhalpun submitted the patch
26
+      implementing this support.
27
+    - Enhancements to the clambc command line utility to assist
28
+      ClamAV bytecode signature authors by providing introspection
29
+      into compiled bytecode programs.
30
+    - Resolution of many of the warning messages from ClamAV compilation.
31
+    - Bug fixes and other feature enhancements. See Changelog or
32
+      git log for details.
33
+
34
+Thanks to the following ClamAV community members for code submissions
35
+and bug reporting included in ClamAV 0.98.5:
36
+
37
+Andreas Cadhalpun
38
+Sebastian Andrzej Siewior
39
+
19 40
 0.98.4
20 41
 ------
21 42
 
... ...
@@ -215,7 +236,7 @@ There are also fixes for other minor issues and code quality changes. Please
215 215
 see the ChangeLog file for details.
216 216
 
217 217
 --
218
-The ClamAV team (http://www.clamav.net/team)
218
+The ClamAV team (http://www.clamav.net/about.html#credits)
219 219
 
220 220
 0.97.8
221 221
 ----
... ...
@@ -266,46 +287,6 @@ ClamAV 0.97.2 fixes problems with the bytecode engine, Safebrowsing detection,
266 266
 hash matcher, and other minor issues. Please see the ChangeLog file for
267 267
 details.
268 268
 
269
-*** Announcement ***
270
-
271
-The ClamAV project is launching a new service called "Third Party web
272
-interface". It will allow selected individuals/organizations to publish
273
-ClamAV Virus Databases (CVD) through the ClamAV mirror network.
274
-
275
-If you choose to publish your signatures through our Third Party
276
-web interface you will benefit from the following:
277
-
278
-- before publishing the signatures, we will test them for
279
-  false positives against our false positive file collection.
280
-- before publishing the signatures, we'll verify that the latest two major
281
-  versions of ClamAV can load them correctly.
282
-- the signatures will be digitally signed and packaged into a single
283
-  .cvd compressed file.
284
-- there will be no ".UNOFFICIAL" suffix in the detection names.
285
-- a custom prefix will be added to the detection names, identifying the
286
-  organization which published the signature.
287
-- updates will be distributed both as full CVD files and cdiff
288
-  incremental updates. Users will benefit from lower network traffic.
289
-- the .cvd and .cdiff files will be distributed through the
290
-  ClamAV mirror network.
291
-- the service should result in faster remediation of false positives.
292
-- ClamAV users will be able to download the third party databases
293
-  using freshclam, by adding a single line to freshclam.conf, what
294
-  should make signature maintenance significantly easier.
295
-
296
-The service is still in beta, you are welcome to contact Luca Gibelli
297
-<luca*clamav.net> if you intend to join the beta program.
298
-
299
-We especially welcome those who already distribute their own unofficial
300
-signatures to join. A list of databases distributed by the new service
301
-will be available at http://www.clamav.net/download/cvd/3rdparty
302
-
303
-We will be happy to answer any questions you might have.
304
-
305
-The ClamAV team (http://www.clamav.net/team)
306
-
307
-
308 269
 0.97.1
309 270
 ------
310 271
 
... ...
@@ -313,7 +294,7 @@ This is a bugfix release recommended for all users. Please refer to the
313 313
 ChangeLog file for details.
314 314
 
315 315
 --
316
-The ClamAV team (http://www.clamav.net/team)
316
+The ClamAV team (http://www.clamav.net/about.html#credits)
317 317
 
318 318
 
319 319
 0.97
... ...
@@ -334,11 +315,11 @@ the full power of the LibClamAV engine, all the ClamAV signatures,
334 334
 and creation of custom signatures on any platform running Immunet 3.0,
335 335
 powered by ClamAV. If you run Windows systems in your environment and
336 336
 need an AV solution to protect them, give Immunet 3.0, powered by ClamAV
337
-a try; you can download it from http://www.clamav.net/about/win32
337
+a try; you can download it from http://www.clamav.net/download.html#otherversions 
338 338
 
339 339
 
340 340
 --
341
-The ClamAV team (http://www.clamav.net/team)
341
+The ClamAV team (http://www.clamav.net/about.html#credits)
342 342
 
343 343
 
344 344
 0.96.5
... ...
@@ -350,7 +331,7 @@ and support for custom database URLs in freshclam. Please refer to the
350 350
 ChangeLog for details.
351 351
 
352 352
 --
353
-The ClamAV team (http://www.clamav.net/team)
353
+The ClamAV team (http://www.clamav.net/about.html#credits)
354 354
 
355 355
 
356 356
 0.96.4
... ...
@@ -359,7 +340,7 @@ The ClamAV team (http://www.clamav.net/team)
359 359
 ClamAV 0.96.4 is a bugfix release recommended for all users.
360 360
 
361 361
 --
362
-The ClamAV team (http://www.clamav.net/team)
362
+The ClamAV team (http://www.clamav.net/about.html#credits)
363 363
 
364 364
 0.96.3
365 365
 ------
... ...
@@ -368,7 +349,7 @@ This release fixes problems with the PDF parser and the internal bzip2
368 368
 library. A complete list of changes is available in the Changelog file.
369 369
 
370 370
 --
371
-The ClamAV team (http://www.clamav.net/team)
371
+The ClamAV team (http://www.clamav.net/about.html#credits)
372 372
 
373 373
 0.96.2
374 374
 ------
... ...
@@ -384,7 +365,7 @@ This is a bugfix release, please refer to the ChangeLog for the complete
384 384
 list of changes.
385 385
 
386 386
 --
387
-The ClamAV team (http://www.clamav.net/team)
387
+The ClamAV team (http://www.clamav.net/about.html#credits)
388 388
 
389 389
 0.96
390 390
 ----
... ...
@@ -425,7 +406,7 @@ The complete list of changes is available in the ChangeLog file. For upgrade
425 425
 notes and tips please see: https://wiki.clamav.net/Main/UpgradeNotes096
426 426
 
427 427
 --
428
-The ClamAV team (http://www.clamav.net/team)
428
+The ClamAV team (http://www.clamav.net/about.html#credits)
429 429
 
430 430
 0.95.3
431 431
 ------
... ...
@@ -435,7 +416,7 @@ Please refer to the ChangeLog included in the source distribution
435 435
 for the list of changes.
436 436
 
437 437
 --
438
-The ClamAV team (http://www.clamav.net/team)
438
+The ClamAV team (http://www.clamav.net/about.html#credits)
439 439
 
440 440
 0.95.2
441 441
 ------
... ...
@@ -445,7 +426,7 @@ in clamscan and clamdscan, and fixes various issues found in previous
445 445
 releases.
446 446
 
447 447
 --
448
-The ClamAV team (http://www.clamav.net/team)
448
+The ClamAV team (http://www.clamav.net/about.html#credits)
449 449
 
450 450
 0.95.1
451 451
 ------
... ...
@@ -453,7 +434,7 @@ The ClamAV team (http://www.clamav.net/team)
453 453
 This is a bugfix release only, please see the ChangeLog for details.
454 454
 
455 455
 --
456
-The ClamAV team (http://www.clamav.net/team)
456
+The ClamAV team (http://www.clamav.net/about.html#credits)
457 457
 
458 458
 0.95
459 459
 ----
... ...
@@ -511,7 +492,7 @@ The following are the key features of this release:
511 511
       the details.
512 512
 
513 513
 --
514
-The ClamAV team (http://www.clamav.net/team)
514
+The ClamAV team (http://www.clamav.net/about.html#credits)
515 515
 
516 516
 
517 517
 0.94.2
... ...
@@ -521,7 +502,7 @@ This is a bugfix release, please refer to the ChangeLog for a complete
521 521
 list of changes.
522 522
 
523 523
 --
524
-The ClamAV team (http://www.clamav.net/team)
524
+The ClamAV team (http://www.clamav.net/about.html#credits)
525 525
 
526 526
 
527 527
 0.94.1
... ...
@@ -536,11 +517,11 @@ area they are. It will also allow us to publish summary data on www.clamav.net
536 536
 where our users will be able to monitor the latest threats. You can help us
537 537
 by enabling SubmitDetectionStats in freshclam.conf.
538 538
 
539
-For more details, please refer to the ChangeLog and
540
-http://www.clamav.net/press/0.94.1-WhatsNew.pdf
539
+For more details, please refer to the ChangeLog
540
+
541 541
 
542 542
 --
543
-The ClamAV team (http://www.clamav.net/team)
543
+The ClamAV team (http://www.clamav.net/about.html#credits)
544 544
 
545 545
 
546 546
 0.94
... ...
@@ -583,9 +564,6 @@ version:
583 583
     tested on a wide variety of systems (try running 'make check' in the source
584 584
     directory)
585 585
 
586
-For more details, please refer to http://www.clamav.net/press/0.94-WhatsNew.pdf
587
-and to the ChangeLog.
588
-
589 586
 You may need to run 'ldconfig' after installing this version.
590 587
 
591 588
 ** This version drops the special support for Cygwin. Our QA process showed
... ...
@@ -594,7 +572,7 @@ You may need to run 'ldconfig' after installing this version.
594 594
 ** ClamAV behaviour.
595 595
 
596 596
 --
597
-The ClamAV team (http://www.clamav.net/team)
597
+The ClamAV team (http://www.clamav.net/about.html#credits)
598 598
 
599 599
 
600 600
 0.93.3
... ...
@@ -603,7 +581,7 @@ The ClamAV team (http://www.clamav.net/team)
603 603
 This release fixes a problem in handling of .cld files introduced in 0.93.2.
604 604
 
605 605
 --
606
-The ClamAV team (http://www.clamav.net/team)
606
+The ClamAV team (http://www.clamav.net/about.html#credits)
607 607
 
608 608
 0.93.2
609 609
 ------
... ...
@@ -619,7 +597,7 @@ This version improves handling of PDF, CAB, RTF, OLE2 and HTML files
619 619
 and includes various bugfixes for 0.93 issues.
620 620
 
621 621
 --
622
-The ClamAV team (http://www.clamav.net/team)
622
+The ClamAV team (http://www.clamav.net/about.html#credits)
623 623
 
624 624
 
625 625
 0.93
... ...
@@ -662,7 +640,7 @@ Most important changes include:
662 662
       remove them manually from your database directory
663 663
 
664 664
 --
665
-The ClamAV team (http://www.clamav.net/team)
665
+The ClamAV team (http://www.clamav.net/about.html#credits)
666 666
 
667 667
 
668 668
 0.92.1
... ...
@@ -672,7 +650,7 @@ This is a bugfix release, please refer to the ChangeLog for a complete
672 672
 list of changes.
673 673
 
674 674
 --
675
-The ClamAV team (http://www.clamav.net/team)
675
+The ClamAV team (http://www.clamav.net/about.html#credits)
676 676
 
677 677
 
678 678
 0.92
... ...
@@ -686,7 +664,7 @@ To get a consistent behaviour of the anti-phishing module on all platforms,
686 686
 libclamav now includes the regex library from OpenBSD.
687 687
 
688 688
 --
689
-The ClamAV team (http://www.clamav.net/team)
689
+The ClamAV team (http://www.clamav.net/about.html#credits)
690 690
 
691 691
 
692 692
 0.91.2
... ...
@@ -725,12 +703,8 @@ interact with the open source community. The core team will continue to lead
725 725
 the advancement of ClamAV and the CVD as employees of Sourcefire. Both the
726 726
 ClamAV engine and the signature database will remain under GPL.
727 727
 
728
-For more information please visit our website and the following FAQ page:
729
-
730
-http://www.clamav.net/support/sf-faq
731
-
732 728
 --
733
-The ClamAV team (http://www.clamav.net/team)
729
+The ClamAV team (http://www.clamav.net/about.html#credits)
734 730
 
735 731
 
736 732
 0.91.1
... ...
@@ -739,7 +713,7 @@ The ClamAV team (http://www.clamav.net/team)
739 739
 This release fixes stability and other issues of 0.91.
740 740
 
741 741
 --
742
-The ClamAV team (http://www.clamav.net/team)
742
+The ClamAV team (http://www.clamav.net/about.html#credits)
743 743
 
744 744
 
745 745
 0.91
... ...
@@ -765,7 +739,7 @@ Other important changes and add-ons in this version include:
765 765
     - many other improvements and bugfixes
766 766
 
767 767
 --
768
-The ClamAV team (http://www.clamav.net/team)
768
+The ClamAV team (http://www.clamav.net/about.html#credits)
769 769
 
770 770
 
771 771
 0.90.3
... ...
@@ -779,7 +753,7 @@ consider installing 0.91rc1 which is due to be released shortly
779 779
 after 0.90.3.
780 780
 
781 781
 --
782
-The ClamAV team (http://www.clamav.net/team)
782
+The ClamAV team (http://www.clamav.net/about.html#credits)
783 783
 
784 784
 
785 785
 0.90.2
... ...
@@ -788,7 +762,7 @@ The ClamAV team (http://www.clamav.net/team)
788 788
 This release fixes many problems in libclamav and freshclam.
789 789
 
790 790
 --
791
-The ClamAV team (http://www.clamav.net/team)
791
+The ClamAV team (http://www.clamav.net/about.html#credits)
792 792
 
793 793
 0.90.1
794 794
 ------
... ...
@@ -799,7 +773,7 @@ see ChangeLog for complete list of changes.
799 799
 ** Important note **: please run 'ldconfig' after installing this version.
800 800
 
801 801
 --
802
-The ClamAV team (http://www.clamav.net/team)
802
+The ClamAV team (http://www.clamav.net/about.html#credits)
803 803
 
804 804
 
805 805
 0.90
... ...
@@ -944,10 +918,10 @@ We are happy to announce new interesting software with support for ClamAV:
944 944
   + mod_streamav - a ClamAV based antivirus filter for Apache 2
945 945
   + pyClamd - a python interface to Clamd
946 946
 
947
-More information at http://www.clamav.net/download/third-party-tools/
947
+More information at http://www.clamav.net/download.html#tools 
948 948
 
949 949
 --
950
-The ClamAV team (http://www.clamav.net/team)
950
+The ClamAV team (http://www.clamav.net/about.html#credits)
951 951
 
952 952
 
953 953
 0.88.7
... ...
@@ -956,7 +930,7 @@ The ClamAV team (http://www.clamav.net/team)
956 956
 This version improves scanning of mail and tar files.
957 957
 
958 958
 --
959
-The ClamAV team (http://www.clamav.net/team)
959
+The ClamAV team (http://www.clamav.net/about.html#credits)
960 960
 
961 961
 
962 962
 0.88.6
... ...
@@ -969,7 +943,7 @@ The ClamAV developers encourage all users to give a try to the latest
969 969
 beta version of 0.90!
970 970
 
971 971
 --
972
-The ClamAV team (http://www.clamav.net/team)
972
+The ClamAV team (http://www.clamav.net/about.html#credits)
973 973
 
974 974
 
975 975
 0.88.5
... ...
@@ -979,7 +953,7 @@ This version fixes a crash in the CHM unpacker and a heap overflow in the
979 979
 function rebuilding PE files after unpacking.
980 980
 
981 981
 --
982
-The ClamAV team (http://www.clamav.net/team)
982
+The ClamAV team (http://www.clamav.net/about.html#credits)
983 983
 
984 984
 
985 985
 0.88.4
... ...
@@ -987,10 +961,8 @@ The ClamAV team (http://www.clamav.net/team)
987 987
 
988 988
 This release fixes a possible heap overflow in the UPX code.
989 989
 
990
-See security information at: http://www.clamav.net/2006/08/07/security-fixes-in-0884
991
-
992 990
 --
993
-The ClamAV team (http://www.clamav.net/team)
991
+The ClamAV team (http://www.clamav.net/about.html#credits)
994 992
 
995 993
 0.88.3
996 994
 ------
... ...
@@ -999,7 +971,7 @@ This version fixes handling of large binhex files and multiple alternatives in
999 999
 virus signatures.
1000 1000
 
1001 1001
 --
1002
-The ClamAV team (http://www.clamav.net/team)
1002
+The ClamAV team (http://www.clamav.net/about.html#credits)
1003 1003
 
1004 1004
 
1005 1005
 0.88.2
... ...
@@ -1011,13 +983,11 @@ architectures and possible security problem in freshclam.
1011 1011
 Following the 0.88.1 release some portals and security related websites
1012 1012
 published incorrect information on security problems of 0.88. To avoid
1013 1013
 such incidents in the future, every new ClamAV package will be released
1014
-together with detailed information about security bugs it fixes. Details
1015
-for this version can be found here:
1014
+together with detailed information about security bugs it fixes. 
1016 1015
 
1017
-    http://www.clamav.net/2006/08/07/security-fixes-in-0884
1018 1016
 
1019 1017
 --
1020
-The ClamAV team (http://www.clamav.net/team)
1018
+The ClamAV team (http://www.clamav.net/about.html#credits)
1021 1019
 
1022 1020
 
1023 1021
 0.88.1
... ...
@@ -1027,7 +997,7 @@ This version fixes a number of minor bugs and provides code updates
1027 1027
 to improve virus detection.
1028 1028
 
1029 1029
 --
1030
-The ClamAV team (http://www.clamav.net/team)
1030
+The ClamAV team (http://www.clamav.net/about.html#credits)
1031 1031
 
1032 1032
 
1033 1033
 0.88
... ...
@@ -1038,7 +1008,7 @@ include better zip and mail processing, and support for a self-protection mode.
1038 1038
 The security of the UPX, FSG and Petite modules has been improved, too.
1039 1039
 
1040 1040
 --
1041
-The ClamAV team (http://www.clamav.net/team)
1041
+The ClamAV team (http://www.clamav.net/about.html#credits)
1042 1042
 
1043 1043
 0.87.1
1044 1044
 ------
... ...
@@ -1047,7 +1017,7 @@ This release includes major bugfixes for problems with handling TNEF
1047 1047
 attachments, cabinet files and FSG compressed executables.
1048 1048
 
1049 1049
 --
1050
-The ClamAV team (http://www.clamav.net/team)
1050
+The ClamAV team (http://www.clamav.net/about.html#credits)
1051 1051
 
1052 1052
 0.87
1053 1053
 ----
... ...
@@ -1058,7 +1028,7 @@ and other small bugfixes have been made. The new option "--on-outdated-execute"
1058 1058
 allows freshclam to run a command when system reports a new engine version.
1059 1059
 
1060 1060
 --
1061
-The ClamAV team (http://www.clamav.net/team)
1061
+The ClamAV team (http://www.clamav.net/about.html#credits)
1062 1062
 
1063 1063
 
1064 1064
 0.86.2
... ...
@@ -1069,7 +1039,7 @@ in libclamav, improved scanning of Cabinet and FSG compressed files, better
1069 1069
 database handling in clamav-milter, and others.
1070 1070
 
1071 1071
 --
1072
-The ClamAV team (http://www.clamav.net/team)
1072
+The ClamAV team (http://www.clamav.net/about.html#credits)
1073 1073
 
1074 1074
 0.86.1
1075 1075
 ------
... ...
@@ -1077,7 +1047,7 @@ The ClamAV team (http://www.clamav.net/team)
1077 1077
 A possible crash in the libmspack's Quantum decompressor has been fixed.
1078 1078
 
1079 1079
 --
1080
-The ClamAV team (http://www.clamav.net/team)
1080
+The ClamAV team (http://www.clamav.net/about.html#credits)
1081 1081
 
1082 1082
 0.86
1083 1083
 ----
... ...
@@ -1087,7 +1057,7 @@ leaks in archive unpackers and mishandling of fast track uuencoded files have
1087 1087
 been fixed in libclamav. Database reloading in clamav-milter has been improved.
1088 1088
 
1089 1089
 --
1090
-The ClamAV team (http://www.clamav.net/team)
1090
+The ClamAV team (http://www.clamav.net/about.html#credits)
1091 1091
 
1092 1092
 0.85.1
1093 1093
 ------
... ...
@@ -1097,7 +1067,7 @@ one or more of which was empty, could crash libclamav has been fixed. Other
1097 1097
 minor bugfixes have been made.
1098 1098
 
1099 1099
 --
1100
-The ClamAV team (http://www.clamav.net/team)
1100
+The ClamAV team (http://www.clamav.net/about.html#credits)
1101 1101
 
1102 1102
 0.85
1103 1103
 ----
... ...
@@ -1106,7 +1076,7 @@ Bugfixes in this release include correct signature offset calculation in large
1106 1106
 files, proper handling of encrypted zip archives, and others.
1107 1107
 
1108 1108
 --
1109
-The ClamAV team (http://www.clamav.net/team)
1109
+The ClamAV team (http://www.clamav.net/about.html#credits)
1110 1110
 
1111 1111
 0.84
1112 1112
 ----
... ...
@@ -1117,11 +1087,6 @@ support for TNEF files and new detection mechanisms. Various bugfixes
1117 1117
 have been made.
1118 1118
 
1119 1119
 
1120
-** We encourage users to help testing the development versions, now with **
1121
-** rewritten RAR code and support for 3.0 archives!			 **
1122
-**		    http://www.clamav.net/snapshot/			 **
1123
-
1124
-
1125 1120
 -) libclamav:
1126 1121
     + JPEG exploit detector now also checks embedded Photoshop thumbnail images
1127 1122
     + archive meta-data scanner (improves malware detection within encrypted
... ...
@@ -1171,7 +1136,6 @@ to provide hardware acceleration support for the Clam AntiVirus suite.
1171 1171
 Support for Sensory Networks' NodalCore acceleration in ClamAV will be
1172 1172
 available in version 0.90 of the software suite in Q3 2005. For more
1173 1173
 information please visit:
1174
-http://www.clamav.net/partners/sensorynetworks
1175 1174
 http://www.sensorynetworks.com/
1176 1175
 
1177 1176
 
... ...
@@ -1193,7 +1157,7 @@ volunteered to design the whole line of products, including:
1193 1193
 By purchasing our merchandise, you contribute to the development of ClamAV.
1194 1194
 
1195 1195
 --
1196
-The ClamAV team (http://www.clamav.net/team)
1196
+The ClamAV team (http://www.clamav.net/about.html#credits)
1197 1197
 
1198 1198
 
1199 1199
 0.83
... ...
@@ -1204,7 +1168,7 @@ exploit detector now only checks specific RIFF files. This version also fixes
1204 1204
 a stability problem of clamav-milter/clamd and improves e-mail scanning.
1205 1205
 
1206 1206
 --
1207
-The ClamAV team (http://www.clamav.net/team)
1207
+The ClamAV team (http://www.clamav.net/about.html#credits)
1208 1208
 
1209 1209
 0.82
1210 1210
 ----
... ...
@@ -1217,7 +1181,7 @@ warning on non-standard zip archives created by ICEOWS, better proxy support
1217 1217
 in freshclam, and speed improvements.
1218 1218
 
1219 1219
 --
1220
-The ClamAV team (http://www.clamav.net/team)
1220
+The ClamAV team (http://www.clamav.net/about.html#credits)
1221 1221
 
1222 1222
 
1223 1223
 0.81
... ...
@@ -1314,7 +1278,7 @@ Important note to clamdwatch users: please upgrade to the latest version
1314 1314
     + WRAVLib - a library for a-v integration with Mono/.NET applications
1315 1315
 
1316 1316
 --
1317
-The ClamAV team (http://www.clamav.net/team)
1317
+The ClamAV team (http://www.clamav.net/about.html#credits)
1318 1318
 
1319 1319
 
1320 1320
 0.80
... ...
@@ -1323,7 +1287,7 @@ The ClamAV team (http://www.clamav.net/team)
1323 1323
 Stable version. Please read the release notes for the candidate versions below.
1324 1324
 
1325 1325
 --
1326
-The ClamAV team (http://www.clamav.net/team)
1326
+The ClamAV team (http://www.clamav.net/about.html#credits)
1327 1327
 
1328 1328
 
1329 1329
 0.80rc4
... ...
@@ -1334,7 +1298,7 @@ faster base64 decoding, support for GNU tar files, updated on-access scanner,
1334 1334
 and others.
1335 1335
 
1336 1336
 --
1337
-The ClamAV team (http://www.clamav.net/team)
1337
+The ClamAV team (http://www.clamav.net/about.html#credits)
1338 1338
 
1339 1339
 0.80rc3
1340 1340
 -------
... ...
@@ -1481,7 +1445,7 @@ project. Visit http://www.sourcewear.com and click on ClamAV logo!
1481 1481
 
1482 1482
 
1483 1483
 --
1484
-The ClamAV team (http://www.clamav.net/team)
1484
+The ClamAV team (http://www.clamav.net/about.html#credits)
1485 1485
 
1486 1486
 0.75
1487 1487
 ----
... ...
@@ -1510,7 +1474,7 @@ CAB, CHM, UPX, HTML (normalisation), PowerPoint macros and can detect
1510 1510
 annoying e-mails with empty attachments generated by new Bagle variants.
1511 1511
 
1512 1512
 --
1513
-The ClamAV team (http://www.clamav.net/team)
1513
+The ClamAV team (http://www.clamav.net/about.html#credits)
1514 1514
 
1515 1515
 0.74
1516 1516
 ----
... ...
@@ -1537,22 +1501,19 @@ and join the clamav-jp-users mailing list.
1537 1537
 
1538 1538
 
1539 1539
 --
1540
-The ClamAV team (http://www.clamav.net/team)
1540
+The ClamAV team (http://www.clamav.net/about.html#credits)
1541 1541
 
1542 1542
 
1543 1543
 0.73
1544 1544
 ----
1545 1545
 
1546 1546
 This version fixes memory management problems in the OLE2 decoder and
1547
-improves mail scanning. Because of the rapid ClamAV development the team
1548
-encourages users to help in testing new features:
1549
-
1550
-	    http://www.clamav.net/snapshot
1547
+improves mail scanning. 
1551 1548
 
1552 1549
 Thank you for using ClamAV !
1553 1550
 
1554 1551
 --
1555
-The ClamAV team (http://www.clamav.net/team)
1552
+The ClamAV team (http://www.clamav.net/about.html#credits)
1556 1553
 
1557 1554
 0.72
1558 1555
 ----
... ...
@@ -1563,7 +1524,7 @@ functional since 0.70) was improved and a number of other improvements were
1563 1563
 made.
1564 1564
 
1565 1565
 --
1566
-The ClamAV team (http://www.clamav.net/team)
1566
+The ClamAV team (http://www.clamav.net/about.html#credits)
1567 1567
 
1568 1568
 0.71
1569 1569
 ----
... ...
@@ -1611,7 +1572,7 @@ the noteworthy changes include:
1611 1611
 
1612 1612
 
1613 1613
 --
1614
-The ClamAV team (http://www.clamav.net/team)
1614
+The ClamAV team (http://www.clamav.net/about.html#credits)
1615 1615
 
1616 1616
 
1617 1617
 
... ...
@@ -1664,8 +1625,7 @@ Special thanks to Dirk Mueller <mueller*kde.org> for his code review,
1664 1664
 many bugfixes and cleanups.
1665 1665
 
1666 1666
 
1667
-Thanks to the help of many companies (clamdoc.pdf: Section 2.10,
1668
-http://www.clamav.net/mirrors.html) we have 49 very fast and reliable
1667
+Thanks to the help of many companies we have 49 very fast and reliable
1669 1668
 virus database mirrors in 22 regions and the number is still growing.
1670 1669
 As of March 2004 we attempt to redirect our users to the closest pool
1671 1670
 of mirrors by looking at their ip source address when they try to resolve
... ...
@@ -1683,7 +1643,7 @@ please help us and test CVS snapshots from time to time.
1683 1683
 
1684 1684
 We are happy to announce new programs with support for ClamAV (all of them
1685 1685
 have been reviewed by our team - more info in the documentation and
1686
-on our website: http://www.clamav.net/download/third-party-tools):
1686
+on our website: http://www.clamav.net/download.html#tools):
1687 1687
 
1688 1688
     + ClamWin - a GUI for Windows (!)
1689 1689
     + KlamAV - a collection of GUI tools for using ClamAV on KDE
... ...
@@ -1706,7 +1666,7 @@ on our website: http://www.clamav.net/download/third-party-tools):
1706 1706
     + Local Area Security - a Live CD Linux distribution
1707 1707
 
1708 1708
 --
1709
-The ClamAV team (http://www.clamav.net/team)
1709
+The ClamAV team (http://www.clamav.net/about.html#credits)
1710 1710
 April 17, 2004
1711 1711
 
1712 1712
 
... ...
@@ -1819,18 +1779,10 @@ the highest possible level.
1819 1819
 
1820 1820
 
1821 1821
 New mirroring mechanisms. Luca Gibelli (ClamAV) and mirror administrators
1822
-(22 sites, http://www.clamav.net/mirrors.html, please see clamdoc.pdf for
1822
+(22 sites, http://www.clamav.net/documentation.html for
1823 1823
 a complete mirror information) are converting mirrors to new "push mirroring"
1824 1824
 method. It uses advanced techniques to ensure all the mirrors are up to date.
1825
-More info: http://www.clamav.net/docs/mirrors
1826
-
1827
-
1828
-"Newsworthy Hack of Kindness" - Affero.net is featuring ClamAV in its latest
1829
-newsletter (Volume #9, January 2004: http://www.affero.net/nl/dec03.html).
1830
-Affero is a great rate-donate system and its mission is to bring a culture
1831
-of patronage to the Internet. Currently we only accept donations via Affero.
1832
-You can also help us and promote our project by adding the ClamAV logo to
1833
-your home page. Look at http://www.clamav.net/donate for more information.
1825
+More info: http://www.clamav.net/documentation.html 
1834 1826
 
1835 1827
 
1836 1828
 We would like to thank our donors:
... ...
@@ -642,6 +642,24 @@ fi
642 642
 rmdir .tst 2>/dev/null
643 643
 AC_SUBST([am__leading_dot])])
644 644
 
645
+# Copyright (C) 1998-2013 Free Software Foundation, Inc.
646
+#
647
+# This file is free software; the Free Software Foundation
648
+# gives unlimited permission to copy and/or distribute it,
649
+# with or without modifications, as long as this notice is preserved.
650
+
651
+# AM_PROG_LEX
652
+# -----------
653
+# Autoconf leaves LEX=: if lex or flex can't be found.  Change that to a
654
+# "missing" invocation, for better error output.
655
+AC_DEFUN([AM_PROG_LEX],
656
+[AC_PREREQ([2.50])dnl
657
+AC_REQUIRE([AM_MISSING_HAS_RUN])dnl
658
+AC_REQUIRE([AC_PROG_LEX])dnl
659
+if test "$LEX" = :; then
660
+  LEX=${am_missing_run}flex
661
+fi])
662
+
645 663
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
646 664
 
647 665
 # Copyright (C) 2001-2013 Free Software Foundation, Inc.
... ...
@@ -579,6 +579,10 @@
579 579
 # endif
580 580
 #endif
581 581
 
582
+/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
583
+   `char[]'. */
584
+#undef YYTEXT_POINTER
585
+
582 586
 /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
583 587
 #undef _LARGEFILE_SOURCE
584 588
 
... ...
@@ -364,6 +364,9 @@ JSON_LIBS = @JSON_LIBS@
364 364
 LCOV = @LCOV@
365 365
 LD = @LD@
366 366
 LDFLAGS = @LDFLAGS@
367
+LEX = @LEX@
368
+LEXLIB = @LEXLIB@
369
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
367 370
 LIBADD_DL = @LIBADD_DL@
368 371
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
369 372
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -426,6 +429,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
426 426
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
427 427
 XML_CPPFLAGS = @XML_CPPFLAGS@
428 428
 XML_LIBS = @XML_LIBS@
429
+YACC = @YACC@
430
+YFLAGS = @YFLAGS@
429 431
 abs_builddir = @abs_builddir@
430 432
 abs_srcdir = @abs_srcdir@
431 433
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -56,6 +56,8 @@ int main(int argc, char **argv) {
56 56
     mode_t umsk;
57 57
     int ret;
58 58
 
59
+    cl_initialize_crypto();
60
+
59 61
     memset(&descr, 0, sizeof(struct smfiDesc));
60 62
     descr.xxfi_name = "ClamAV";			/* filter name */
61 63
     descr.xxfi_version = SMFI_VERSION;		/* milter version */
... ...
@@ -114,104 +116,6 @@ 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
-
215 117
     if(geteuid() == 0 && (opt = optget(opts, "User"))->enabled) {
216 118
         struct passwd *user = NULL;
217 119
 	if((user = getpwnam(opt->strarg)) == NULL) {
... ...
@@ -344,6 +248,15 @@ int main(int argc, char **argv) {
344 344
 
345 345
     multircpt = optget(opts, "SupportMultipleRecipients")->enabled;
346 346
     
347
+    if(!(my_socket = optget(opts, "MilterSocket")->strarg)) {
348
+	logg("!Please configure the MilterSocket directive\n");
349
+	localnets_free();
350
+	whitelist_free();
351
+	logg_close();
352
+	optfree(opts);
353
+	return 1;
354
+    }
355
+
347 356
     if(!optget(opts, "Foreground")->enabled) {
348 357
 	if(daemonize() == -1) {
349 358
 	    logg("!daemonize() failed\n");
... ...
@@ -358,6 +271,92 @@ int main(int argc, char **argv) {
358 358
 	    logg("^Can't change current working directory to root\n");
359 359
     }
360 360
 
361
+    if(smfi_setconn(my_socket) == MI_FAILURE) {
362
+	logg("!smfi_setconn failed\n");
363
+	localnets_free();
364
+	whitelist_free();
365
+	logg_close();
366
+	optfree(opts);
367
+	return 1;
368
+    }
369
+    if(smfi_register(descr) == MI_FAILURE) {
370
+	logg("!smfi_register failed\n");
371
+	localnets_free();
372
+	whitelist_free();
373
+	logg_close();
374
+	optfree(opts);
375
+	return 1;
376
+    }
377
+    opt = optget(opts, "FixStaleSocket");
378
+    umsk = umask(0777); /* socket is created with 000 to avoid races */ 
379
+    if(smfi_opensocket(opt->enabled) == MI_FAILURE) {
380
+	logg("!Failed to create socket %s\n", my_socket);
381
+	localnets_free();
382
+	whitelist_free();
383
+	logg_close();
384
+	optfree(opts);
385
+	return 1;
386
+    }
387
+    umask(umsk); /* restore umask */
388
+    if(strncmp(my_socket, "inet:", 5) && strncmp(my_socket, "inet6:", 6)) {
389
+	/* set group ownership and perms on the local socket */
390
+	char *sock_name = my_socket;
391
+	mode_t sock_mode;
392
+	if(!strncmp(my_socket, "unix:", 5))
393
+	    sock_name += 5;
394
+	if(!strncmp(my_socket, "local:", 6))
395
+	    sock_name += 6;
396
+	if(*my_socket == ':')
397
+	    sock_name ++;
398
+
399
+	if(optget(opts, "MilterSocketGroup")->enabled) {
400
+	    char *gname = optget(opts, "MilterSocketGroup")->strarg, *end;
401
+	    gid_t sock_gid = strtol(gname, &end, 10);
402
+	    if(*end) {
403
+		struct group *pgrp = getgrnam(gname);
404
+		if(!pgrp) {
405
+		    logg("!Unknown group %s\n", gname);
406
+		    localnets_free();
407
+		    whitelist_free();
408
+		    logg_close();
409
+		    optfree(opts);
410
+		    return 1;
411
+		}
412
+		sock_gid = pgrp->gr_gid;
413
+	    }
414
+	    if(chown(sock_name, -1, sock_gid)) {
415
+		logg("!Failed to change socket ownership to group %s\n", gname);
416
+		localnets_free();
417
+		whitelist_free();
418
+		logg_close();
419
+		optfree(opts);
420
+		return 1;
421
+	    }
422
+	}
423
+	if(optget(opts, "MilterSocketMode")->enabled) {
424
+	    char *end;
425
+	    sock_mode = strtol(optget(opts, "MilterSocketMode")->strarg, &end, 8);
426
+	    if(*end) {
427
+		logg("!Invalid MilterSocketMode %s\n", optget(opts, "MilterSocketMode")->strarg);
428
+		localnets_free();
429
+		whitelist_free();
430
+		logg_close();
431
+		optfree(opts);
432
+		return 1;
433
+	    }
434
+	} else
435
+	    sock_mode = 0777 & ~umsk;
436
+
437
+	if(chmod(sock_name, sock_mode & 0666)) {
438
+	    logg("!Cannot set milter socket permission to %s\n", optget(opts, "MilterSocketMode")->strarg);
439
+	    localnets_free();
440
+	    whitelist_free();
441
+	    logg_close();
442
+	    optfree(opts);
443
+	    return 1;
444
+	}
445
+    }
446
+
361 447
     maxfilesize = optget(opts, "MaxFileSize")->numarg;
362 448
     if(!maxfilesize) {
363 449
 	logg("^Invalid MaxFileSize, using default (%d)\n", CLI_DEFAULT_MAXFILESIZE);
... ...
@@ -300,6 +300,9 @@ JSON_LIBS = @JSON_LIBS@
300 300
 LCOV = @LCOV@
301 301
 LD = @LD@
302 302
 LDFLAGS = @LDFLAGS@
303
+LEX = @LEX@
304
+LEXLIB = @LEXLIB@
305
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
303 306
 LIBADD_DL = @LIBADD_DL@
304 307
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
305 308
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -362,6 +365,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
362 362
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
363 363
 XML_CPPFLAGS = @XML_CPPFLAGS@
364 364
 XML_LIBS = @XML_LIBS@
365
+YACC = @YACC@
366
+YFLAGS = @YFLAGS@
365 367
 abs_builddir = @abs_builddir@
366 368
 abs_srcdir = @abs_srcdir@
367 369
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -49,16 +49,20 @@ static void help(void)
49 49
     printf("\n");
50 50
     printf("           Clam AntiVirus: Bytecode Testing Tool %s\n",
51 51
 	   get_version());
52
-    printf("           By The ClamAV Team: http://www.clamav.net/team\n");
52
+    printf("           By The ClamAV Team: http://www.clamav.net/about.html#credits\n");
53 53
     printf("           (C) 2009 Sourcefire, Inc.\n\n");
54 54
     printf("clambc <file> [function] [param1 ...]\n\n");
55 55
     printf("    --help                 -h         Show help\n");
56 56
     printf("    --version              -V         Show version\n");
57
+    printf("    --debug                           Show debug\n");
58
+    printf("    --force-interpreter    -f         Force using the interpreter instead of the JIT\n");
59
+    printf("    --trust-bytecode       -t         Trust loaded bytecode (default yes)\n");
57 60
     printf("    --info                 -i         Print information about bytecode\n");
58 61
     printf("    --printsrc             -p         Print bytecode source\n");
59
-    printf("    --printbcir            -c         Print bytecode IR\n");
60
-    printf("    --trace <level>                   Set bytecode trace level 0..7 (default 7)\n");
61
-    printf("    --no-trace-showsource             Don't show source line during tracing\n");
62
+    printf("    --printbcir            -c         Print IR of bytecode signature\n");
63
+    printf("    --trace <level>        -T         Set bytecode trace level 0..7 (default 7)\n");
64
+    printf("    --no-trace-showsource  -s         Don't show source line during tracing\n");
65
+    printf("    --bytecode-statistics             Collect and print bytecode execution statistics\n");
62 66
     printf("    file                              file to test\n");
63 67
     printf("\n");
64 68
     return;
... ...
@@ -133,7 +137,7 @@ static uint8_t debug_flag = 0;
133 133
 static void print_src(const char *file)
134 134
 {
135 135
   char buf[4096];
136
-  int nread, i, found = 0;
136
+  int nread, i, found = 0, lcnt = 0;
137 137
   FILE *f = fopen(file, "r");
138 138
   if (!f) {
139 139
     fprintf(stderr,"Unable to reopen %s\n", file);
... ...
@@ -142,7 +146,11 @@ static void print_src(const char *file)
142 142
   do {
143 143
     nread = fread(buf, 1, sizeof(buf), f);
144 144
     for (i=0;i<nread-1;i++) {
145
-      if (buf[i] == '\n' && buf[i+1] == 'S') {
145
+      if (buf[i] == '\n') {
146
+        lcnt++;
147
+      }
148
+      /* skip over the logical trigger */
149
+      if (lcnt >= 2 && buf[i] == '\n' && buf[i+1] == 'S') {
146 150
         found = 1;
147 151
         i+=2;
148 152
         break;
... ...
@@ -318,6 +318,9 @@ JSON_LIBS = @JSON_LIBS@
318 318
 LCOV = @LCOV@
319 319
 LD = @LD@
320 320
 LDFLAGS = @LDFLAGS@
321
+LEX = @LEX@
322
+LEXLIB = @LEXLIB@
323
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
321 324
 LIBADD_DL = @LIBADD_DL@
322 325
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
323 326
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -380,6 +383,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
380 380
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
381 381
 XML_CPPFLAGS = @XML_CPPFLAGS@
382 382
 XML_LIBS = @XML_LIBS@
383
+YACC = @YACC@
384
+YFLAGS = @YFLAGS@
383 385
 abs_builddir = @abs_builddir@
384 386
 abs_srcdir = @abs_srcdir@
385 387
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -200,7 +200,7 @@ static void help(void)
200 200
 {
201 201
     printf("\n");
202 202
     printf("           Clam AntiVirus: Configuration Tool %s\n", get_version());
203
-    printf("           By The ClamAV Team: http://www.clamav.net/team\n");
203
+    printf("           By The ClamAV Team: http://www.clamav.net/about.html#credits\n");
204 204
     printf("           (C) 2009 Sourcefire, Inc.\n\n");
205 205
 
206 206
     printf("    --help                 -h         Show help\n");
... ...
@@ -252,6 +252,7 @@ static void print_platform(struct cli_environment *env)
252 252
     printf("zlib version: %s (%s)\n",
253 253
 	   ZLIB_VERSION, zlibVersion());
254 254
 #endif
255
+
255 256
     if (env->triple[0])
256 257
     printf("Triple: %s\n", env->triple);
257 258
     if (env->cpu[0])
... ...
@@ -456,9 +457,16 @@ int main(int argc, char **argv)
456 456
 #ifdef HAVE_BZLIB_H
457 457
 	printf("BZIP2 ");
458 458
 #endif
459
+
460
+#ifdef HAVE_LIBXML2
461
+	printf("LIBXML2 ");
462
+#endif
459 463
 #ifdef HAVE_PCRE
460 464
 	printf("PCRE ");
461 465
 #endif
466
+#ifdef HAVE_JSON
467
+	printf("JSON ");
468
+#endif
462 469
     if(have_rar)
463 470
 	printf("RAR ");
464 471
     if (have_clamjit)
... ...
@@ -331,6 +331,9 @@ JSON_LIBS = @JSON_LIBS@
331 331
 LCOV = @LCOV@
332 332
 LD = @LD@
333 333
 LDFLAGS = @LDFLAGS@
334
+LEX = @LEX@
335
+LEXLIB = @LEXLIB@
336
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
334 337
 LIBADD_DL = @LIBADD_DL@
335 338
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
336 339
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -393,6 +396,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
393 393
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
394 394
 XML_CPPFLAGS = @XML_CPPFLAGS@
395 395
 XML_LIBS = @XML_LIBS@
396
+YACC = @YACC@
397
+YFLAGS = @YFLAGS@
396 398
 abs_builddir = @abs_builddir@
397 399
 abs_srcdir = @abs_srcdir@
398 400
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -82,7 +82,7 @@ static void help(void)
82 82
 {
83 83
     printf("\n");
84 84
     printf("                      Clam AntiVirus Daemon %s\n", get_version());
85
-    printf("           By The ClamAV Team: http://www.clamav.net/team\n");
85
+    printf("           By The ClamAV Team: http://www.clamav.net/about.html#credits\n");
86 86
     printf("           (C) 2007-2009 Sourcefire, Inc.\n\n");
87 87
 
88 88
     printf("    --help                   -h             Show this help.\n");
... ...
@@ -329,6 +329,9 @@ JSON_LIBS = @JSON_LIBS@
329 329
 LCOV = @LCOV@
330 330
 LD = @LD@
331 331
 LDFLAGS = @LDFLAGS@
332
+LEX = @LEX@
333
+LEXLIB = @LEXLIB@
334
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
332 335
 LIBADD_DL = @LIBADD_DL@
333 336
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
334 337
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -391,6 +394,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
391 391
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
392 392
 XML_CPPFLAGS = @XML_CPPFLAGS@
393 393
 XML_LIBS = @XML_LIBS@
394
+YACC = @YACC@
395
+YFLAGS = @YFLAGS@
394 396
 abs_builddir = @abs_builddir@
395 397
 abs_srcdir = @abs_srcdir@
396 398
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -183,7 +183,7 @@ void help(void)
183 183
 
184 184
     mprintf("\n");
185 185
     mprintf("                       ClamAV Daemon Client %s\n", get_version());
186
-    printf("           By The ClamAV Team: http://www.clamav.net/team\n");
186
+    printf("           By The ClamAV Team: http://www.clamav.net/about.html#credits\n");
187 187
     printf("           (C) 2007-2009 Sourcefire, Inc.\n\n");
188 188
 
189 189
     mprintf("    --help              -h             Show help\n");
... ...
@@ -335,6 +335,9 @@ JSON_LIBS = @JSON_LIBS@
335 335
 LCOV = @LCOV@
336 336
 LD = @LD@
337 337
 LDFLAGS = @LDFLAGS@
338
+LEX = @LEX@
339
+LEXLIB = @LEXLIB@
340
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
338 341
 LIBADD_DL = @LIBADD_DL@
339 342
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
340 343
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -397,6 +400,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
397 397
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
398 398
 XML_CPPFLAGS = @XML_CPPFLAGS@
399 399
 XML_LIBS = @XML_LIBS@
400
+YACC = @YACC@
401
+YFLAGS = @YFLAGS@
400 402
 abs_builddir = @abs_builddir@
401 403
 abs_srcdir = @abs_srcdir@
402 404
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -1229,7 +1229,7 @@ static void help(void)
1229 1229
 {
1230 1230
     printf("\n");
1231 1231
     printf("           Clam AntiVirus: Monitoring Tool %s\n", get_version());
1232
-    printf("           By The ClamAV Team: http://www.clamav.net/team\n");
1232
+    printf("           By The ClamAV Team: http://www.clamav.net/about.html#credits\n");
1233 1233
     printf("           (C) 2008-2009 Sourcefire, Inc.\n\n");
1234 1234
     printf("clamdtop [-hVc] [host[:port] /path/to/clamd.socket ...]\n\n");
1235 1235
     printf("    --help                 -h         Show help\n");
... ...
@@ -320,6 +320,9 @@ JSON_LIBS = @JSON_LIBS@
320 320
 LCOV = @LCOV@
321 321
 LD = @LD@
322 322
 LDFLAGS = @LDFLAGS@
323
+LEX = @LEX@
324
+LEXLIB = @LEXLIB@
325
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
323 326
 LIBADD_DL = @LIBADD_DL@
324 327
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
325 328
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -382,6 +385,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
382 382
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
383 383
 XML_CPPFLAGS = @XML_CPPFLAGS@
384 384
 XML_LIBS = @XML_LIBS@
385
+YACC = @YACC@
386
+YFLAGS = @YFLAGS@
385 387
 abs_builddir = @abs_builddir@
386 388
 abs_srcdir = @abs_srcdir@
387 389
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -201,7 +201,7 @@ void help(void)
201 201
 
202 202
     mprintf("\n");
203 203
     mprintf("                       Clam AntiVirus Scanner %s\n", get_version());
204
-    printf("           By The ClamAV Team: http://www.clamav.net/team\n");
204
+    printf("           By The ClamAV Team: http://www.clamav.net/about.html#credits\n");
205 205
     printf("           (C) 2007-2009 Sourcefire, Inc.\n\n");
206 206
 
207 207
     mprintf("    --help                -h             Print this help screen\n");
... ...
@@ -82,44 +82,40 @@ static int checkaccess(const char *path, const char *username, int mode)
82 82
 #else
83 83
 static int checkaccess(const char *path, const char *username, int mode)
84 84
 {
85
-	struct passwd *user;
86
-	int ret = 0, status;
85
+    struct passwd *user;
86
+    int ret = 0, status;
87 87
 
88 88
     if(!geteuid()) {
89
+        if((user = getpwnam(username)) == NULL) {
90
+            return -1;
91
+        }
89 92
 
90
-	if((user = getpwnam(username)) == NULL) {
91
-	    return -1;
92
-	}
93
-
94
-	switch(fork()) {
95
-	    case -1:
96
-		return -2;
97
-
98
-	    case 0:
99
-		if(setgid(user->pw_gid)) {
100
-		    fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid);
101
-		    exit(0);
102
-		}
103
-
104
-		if(setuid(user->pw_uid)) {
105
-		    fprintf(stderr, "ERROR: setuid(%d) failed.\n", (int) user->pw_uid);
106
-		    exit(0);
107
-		}
108
-
109
-		if(access(path, mode))
110
-		    exit(0);
111
-		else
112
-		    exit(1);
93
+        switch(fork()) {
94
+        case -1:
95
+            return -2;
96
+        case 0:
97
+            if(setgid(user->pw_gid)) {
98
+                fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid);
99
+                exit(0);
100
+            }
113 101
 
114
-	    default:
115
-		wait(&status);
116
-		if(WIFEXITED(status) && WEXITSTATUS(status) == 1)
117
-		    ret = 1;
118
-	}
102
+            if(setuid(user->pw_uid)) {
103
+                fprintf(stderr, "ERROR: setuid(%d) failed.\n", (int) user->pw_uid);
104
+                exit(0);
105
+            }
119 106
 
107
+            if(access(path, mode))
108
+                exit(0);
109
+            else
110
+                exit(1);
111
+        default:
112
+            wait(&status);
113
+            if(WIFEXITED(status) && WEXITSTATUS(status) == 1)
114
+                ret = 1;
115
+        }
120 116
     } else {
121
-	if(!access(path, mode))
122
-	    ret = 1;
117
+        if(!access(path, mode))
118
+            ret = 1;
123 119
     }
124 120
 
125 121
     return ret;
... ...
@@ -141,7 +137,7 @@ static cl_error_t pre(int fd, const char *type, void *context)
141 141
     UNUSEDPARAM(type);
142 142
 
143 143
     if (c) {
144
-	c->level++;
144
+        c->level++;
145 145
     }
146 146
     return CL_CLEAN;
147 147
 }
... ...
@@ -151,34 +147,43 @@ static int print_chain(struct metachain *c, char *str, unsigned len)
151 151
     unsigned i;
152 152
     unsigned na = 0;
153 153
     for (i=0;i<c->n-1;i++) {
154
-	unsigned int n = strlen(c->chains[i]);
155
-	if (na)
156
-	    str[na++] = '!';
157
-	if (n + na + 2 > len)
158
-	    break;
159
-	memcpy(str + na, c->chains[i], n);
160
-	na += n;
154
+        unsigned int n = strlen(c->chains[i]);
155
+
156
+        if (na)
157
+            str[na++] = '!';
158
+
159
+        if (n + na + 2 > len)
160
+            break;
161
+
162
+        memcpy(str + na, c->chains[i], n);
163
+        na += n;
161 164
     }
165
+
162 166
     str[na] = '\0';
163 167
     str[len-1] = '\0';
168
+
164 169
     return i == c->n-1 ? 0 : 1;
165 170
 }
166 171
 
167 172
 static cl_error_t post(int fd, int result, const char *virname, void *context)
168 173
 {
169 174
     struct metachain *c = context;
175
+
170 176
     UNUSEDPARAM(fd);
171 177
     UNUSEDPARAM(result);
178
+
172 179
     if (c && c->n) {
173
-	char str[128];
174
-	print_chain(c, str, sizeof(str));
175
-	if (c->level == c->lastadd && !virname)
176
-	    free(c->chains[--c->n]);
177
-	if (virname && !c->lastvir)
178
-	    c->lastvir = c->level;
180
+        char str[128];
181
+        print_chain(c, str, sizeof(str));
182
+        if (c->level == c->lastadd && !virname)
183
+            free(c->chains[--c->n]);
184
+        if (virname && !c->lastvir)
185
+            c->lastvir = c->level;
179 186
     }
187
+
180 188
     if (c)
181
-	c->level--;
189
+        c->level--;
190
+
182 191
     return CL_CLEAN;
183 192
 }
184 193
 
... ...
@@ -199,335 +204,376 @@ static cl_error_t meta(const char* container_type, unsigned long fsize_container
199 199
     UNUSEDPARAM(filepos_container);
200 200
 
201 201
     if (!c)
202
-	return CL_CLEAN;
202
+        return CL_CLEAN;
203
+
203 204
     chain = malloc(n);
205
+
204 206
     if (!chain)
205
-	return CL_CLEAN;
207
+        return CL_CLEAN;
206 208
     if (!strcmp(type, "ANY"))
207
-	snprintf(chain, n,"%s", filename);
209
+        snprintf(chain, n,"%s", filename);
208 210
     else
209
-	snprintf(chain, n,"%s:%s", type, filename);
211
+        snprintf(chain, n,"%s:%s", type, filename);
212
+
210 213
     if (c->lastadd != c->level) {
211
-	n = c->n + 1;
212
-	chains = realloc(c->chains, n * sizeof(*chains));
213
-	if (!chains) {
214
-	    free(chain);
215
-	    return CL_CLEAN;
216
-	}
217
-	c->chains = chains;
218
-	c->n = n;
219
-	c->lastadd = c->level;
214
+        n = c->n + 1;
215
+
216
+        chains = realloc(c->chains, n * sizeof(*chains));
217
+        if (!chains) {
218
+            free(chain);
219
+            return CL_CLEAN;
220
+        }
221
+
222
+        c->chains = chains;
223
+        c->n = n;
224
+        c->lastadd = c->level;
220 225
     } else {
221
-	free(c->chains[c->n-1]);
226
+        free(c->chains[c->n-1]);
222 227
     }
228
+
223 229
     c->chains[c->n-1] = chain;
224 230
     toolong = print_chain(c, prev, sizeof(prev));
225 231
     logg("*Scanning %s%s!%s\n", prev,toolong ? "..." : "", chain);
232
+
226 233
     return CL_CLEAN;
227 234
 }
228 235
 
229 236
 static void scanfile(const char *filename, struct cl_engine *engine, const struct optstruct *opts, unsigned int options)
230 237
 {
231
-	int ret = 0, fd, included;
232
-	unsigned i;
233
-	const struct optstruct *opt;
234
-	const char *virname;
235
-	const char **virpp = &virname;
236
-	STATBUF sb;
237
-	struct metachain chain;
238
+    int ret = 0, fd, included;
239
+    unsigned i;
240
+    const struct optstruct *opt;
241
+    const char *virname;
242
+    const char **virpp = &virname;
243
+    STATBUF sb;
244
+    struct metachain chain;
238 245
 
239 246
     if((opt = optget(opts, "exclude"))->enabled) {
240
-	while(opt) {
241
-	    if(match_regex(filename, opt->strarg) == 1) {
242
-		if(!printinfected)
243
-		    logg("~%s: Excluded\n", filename);
244
-		return;
245
-	    }
246
-	    opt = opt->nextarg;
247
-	}
247
+        while(opt) {
248
+            if(match_regex(filename, opt->strarg) == 1) {
249
+                if(!printinfected)
250
+                    logg("~%s: Excluded\n", filename);
251
+
252
+                return;
253
+            }
254
+
255
+            opt = opt->nextarg;
256
+        }
248 257
     }
249 258
 
250 259
     if((opt = optget(opts, "include"))->enabled) {
251
-	included = 0;
252
-	while(opt) {
253
-	    if(match_regex(filename, opt->strarg) == 1) {
254
-		included = 1;
255
-		break;
256
-	    }
257
-	    opt = opt->nextarg;
258
-	}
259
-	if(!included) {
260
-	    if(!printinfected)
261
-		logg("~%s: Excluded\n", filename);
262
-	    return;
263
-	}
260
+        included = 0;
261
+
262
+        while(opt) {
263
+            if(match_regex(filename, opt->strarg) == 1) {
264
+                included = 1;
265
+                break;
266
+            }
267
+
268
+            opt = opt->nextarg;
269
+        }
270
+
271
+        if(!included) {
272
+            if(!printinfected)
273
+                logg("~%s: Excluded\n", filename);
274
+
275
+            return;
276
+        }
264 277
     }
265 278
 
266 279
     /* argh, don't scan /proc files */
267 280
     if(CLAMSTAT(filename, &sb) != -1) {
268 281
 #ifdef C_LINUX
269
-	if(procdev && sb.st_dev == procdev) {
270
-	    if(!printinfected)
271
-		logg("~%s: Excluded (/proc)\n", filename);
272
-		return;
273
-	}
282
+        if(procdev && sb.st_dev == procdev) {
283
+            if(!printinfected)
284
+                logg("~%s: Excluded (/proc)\n", filename);
285
+
286
+            return;
287
+        }
274 288
 #endif    
275
-	if(!sb.st_size) {
276
-	    if(!printinfected)
277
-		logg("~%s: Empty file\n", filename);
278
-	    return;
279
-	}
280
-	info.rblocks += sb.st_size / CL_COUNT_PRECISION;
289
+        if(!sb.st_size) {
290
+            if(!printinfected)
291
+                logg("~%s: Empty file\n", filename);
292
+
293
+            return;
294
+        }
295
+
296
+        info.rblocks += sb.st_size / CL_COUNT_PRECISION;
281 297
     }
282 298
 
283 299
 #ifndef _WIN32
284
-    if(geteuid())
285
-	if(checkaccess(filename, NULL, R_OK) != 1) {
286
-	    if(!printinfected)
287
-		logg("~%s: Access denied\n", filename);
288
-	    info.errors++;
289
-	    return;
290
-	}
300
+    if(geteuid()) {
301
+        if(checkaccess(filename, NULL, R_OK) != 1) {
302
+            if(!printinfected)
303
+                logg("~%s: Access denied\n", filename);
304
+
305
+            info.errors++;
306
+            return;
307
+        }
308
+    }
291 309
 #endif
292 310
 
293 311
     memset(&chain, 0, sizeof(chain));
294 312
     if(optget(opts, "archive-verbose")->enabled) {
295
-	chain.chains = malloc(sizeof(*chain.chains));
296
-	if (chain.chains) {
297
-	    chain.chains[0] = strdup(filename);
298
-	    chain.n = 1;
299
-	}
313
+        chain.chains = malloc(sizeof(*chain.chains));
314
+        if (chain.chains) {
315
+            chain.chains[0] = strdup(filename);
316
+            chain.n = 1;
317
+        }
300 318
     }
319
+
301 320
     logg("*Scanning %s\n", filename);
302 321
 
303 322
     if((fd = safe_open(filename, O_RDONLY|O_BINARY)) == -1) {
304
-	logg("^Can't open file %s: %s\n", filename, strerror(errno));
305
-	info.errors++;
306
-	return;
323
+        logg("^Can't open file %s: %s\n", filename, strerror(errno));
324
+        info.errors++;
325
+        return;
307 326
     }
308 327
 
309 328
 
310 329
     if((ret = cl_scandesc_callback(fd, virpp, &info.blocks, engine, options, &chain)) == CL_VIRUS) {
311
-	if(optget(opts, "archive-verbose")->enabled) {
312
-	    if (chain.n > 1) {
313
-		char str[128];
314
-		int toolong = print_chain(&chain, str, sizeof(str));
315
-		logg("~%s%s!(%d)%s: %s FOUND\n", str, toolong ? "..." : "", chain.lastvir-1, chain.chains[chain.n-1], virname);
316
-	    } else if (chain.lastvir)
317
-		logg("~%s!(%d): %s FOUND\n", filename, chain.lastvir-1, virname);
318
-	}
319
-	if (options & CL_SCAN_ALLMATCHES) {
320
-	    int i = 0;
321
-	    virpp = (const char **)*virpp; /* horrible */
322
-	    virname = virpp[0];
323
-	    while (virpp[i])
324
-		logg("~%s: %s FOUND\n", filename, virpp[i++]);
325
-	    free((void *)virpp);
326
-	}
327
-	else
328
-	    logg("~%s: %s FOUND\n", filename, virname);
329
-	info.files++;
330
-	info.ifiles++;
331
-
332
-	if(bell)
333
-	    fprintf(stderr, "\007");
330
+        if (options & CL_SCAN_ALLMATCHES) {
331
+            virpp = (const char **)*virpp; /* allmatch needs an extra dereference */
332
+            virname = virpp[0]; /* this is the first virus */
333
+        }
334
+        if(optget(opts, "archive-verbose")->enabled) {
335
+            if (chain.n > 1) {
336
+                char str[128];
337
+                int toolong = print_chain(&chain, str, sizeof(str));
338
+
339
+                logg("~%s%s!(%d)%s: %s FOUND\n", str, toolong ? "..." : "", chain.lastvir-1, chain.chains[chain.n-1], virname);
340
+            } else if (chain.lastvir) {
341
+                logg("~%s!(%d): %s FOUND\n", filename, chain.lastvir-1, virname);
342
+            }
343
+        }
344
+
345
+        if (options & CL_SCAN_ALLMATCHES) {
346
+            int i = 0;
347
+            while (virpp[i])
348
+                logg("~%s: %s FOUND\n", filename, virpp[i++]);
349
+
350
+            free((void *)virpp);
351
+        }
352
+        else
353
+            logg("~%s: %s FOUND\n", filename, virname);
334 354
 
355
+        info.files++;
356
+        info.ifiles++;
357
+
358
+        if(bell)
359
+            fprintf(stderr, "\007");
335 360
     } else if(ret == CL_CLEAN) {
336
-	if(!printinfected && printclean)
337
-	    mprintf("~%s: OK\n", filename);
338
-	info.files++;
361
+        if(!printinfected && printclean)
362
+            mprintf("~%s: OK\n", filename);
363
+
364
+        info.files++;
339 365
     } else {
340
-	if(!printinfected)
341
-	    logg("~%s: %s ERROR\n", filename, cl_strerror(ret));
342
-	info.errors++;
366
+        if(!printinfected)
367
+            logg("~%s: %s ERROR\n", filename, cl_strerror(ret));
368
+
369
+        info.errors++;
343 370
     }
344 371
 
345 372
     for (i=0;i<chain.n;i++)
346
-	free(chain.chains[i]);
373
+        free(chain.chains[i]);
374
+
347 375
     free(chain.chains);
348 376
     close(fd);
349 377
 
350 378
     if(ret == CL_VIRUS && action)
351
-	action(filename);
379
+        action(filename);
352 380
 }
353 381
 
354 382
 static void scandirs(const char *dirname, struct cl_engine *engine, const struct optstruct *opts, unsigned int options, unsigned int depth, dev_t dev)
355 383
 {
356
-	DIR *dd;
357
-	struct dirent *dent;
358
-	STATBUF sb;
359
-	char *fname;
360
-	int included;
361
-	const struct optstruct *opt;
362
-	unsigned int dirlnk, filelnk;
384
+    DIR *dd;
385
+    struct dirent *dent;
386
+    STATBUF sb;
387
+    char *fname;
388
+    int included;
389
+    const struct optstruct *opt;
390
+    unsigned int dirlnk, filelnk;
363 391
 
364 392
 
365 393
     if((opt = optget(opts, "exclude-dir"))->enabled) {
366
-	while(opt) {
367
-	    if(match_regex(dirname, opt->strarg) == 1) {
368
-		if(!printinfected)
369
-		    logg("~%s: Excluded\n", dirname);
370
-		return;
371
-	    }
372
-	    opt = opt->nextarg;
373
-	}
394
+        while(opt) {
395
+            if(match_regex(dirname, opt->strarg) == 1) {
396
+                if(!printinfected)
397
+                    logg("~%s: Excluded\n", dirname);
398
+
399
+                return;
400
+            }
401
+
402
+            opt = opt->nextarg;
403
+        }
374 404
     }
375 405
 
376 406
     if((opt = optget(opts, "include-dir"))->enabled) {
377
-	included = 0;
378
-	while(opt) {
379
-	    if(match_regex(dirname, opt->strarg) == 1) {
380
-		included = 1;
381
-		break;
382
-	    }
383
-	    opt = opt->nextarg;
384
-	}
385
-	if(!included) {
386
-	    if(!printinfected)
387
-		logg("~%s: Excluded\n", dirname);
388
-	    return;
389
-	}
407
+        included = 0;
408
+        while(opt) {
409
+            if(match_regex(dirname, opt->strarg) == 1) {
410
+                included = 1;
411
+                break;
412
+            }
413
+
414
+            opt = opt->nextarg;
415
+        }
416
+
417
+        if(!included) {
418
+            if(!printinfected)
419
+                logg("~%s: Excluded\n", dirname);
420
+
421
+            return;
422
+        }
390 423
     }
391 424
 
392 425
     if(depth > (unsigned int) optget(opts, "max-dir-recursion")->numarg)
393
-	return;
426
+        return;
394 427
 
395 428
     dirlnk = optget(opts, "follow-dir-symlinks")->numarg;
396 429
     filelnk = optget(opts, "follow-file-symlinks")->numarg;
397 430
 
398 431
     if((dd = opendir(dirname)) != NULL) {
399
-	info.dirs++;
400
-	depth++;
401
-	while((dent = readdir(dd))) {
402
-	    if(dent->d_ino) {
403
-		if(strcmp(dent->d_name, ".") && strcmp(dent->d_name, "..")) {
404
-		    /* build the full name */
405
-		    fname = malloc(strlen(dirname) + strlen(dent->d_name) + 2);
406
-		    if (fname == NULL) { /* oops, malloc() failed, print warning and return */
407
-			logg("!scandirs: Memory allocation failed for fname\n");
408
-			break;
409
-		    }
410
-
411
-		    if(!strcmp(dirname, PATHSEP))
412
-			sprintf(fname, PATHSEP"%s", dent->d_name);
413
-		    else
414
-			sprintf(fname, "%s"PATHSEP"%s", dirname, dent->d_name);
415
-
416
-		    /* stat the file */
417
-		    if(LSTAT(fname, &sb) != -1) {
418
-			if(!optget(opts, "cross-fs")->enabled) {
419
-			    if(sb.st_dev != dev) {
420
-				if(!printinfected)
421
-				    logg("~%s: Excluded\n", fname);
422
-				free(fname);
423
-				continue;
424
-			    }
425
-			}
426
-			if(S_ISLNK(sb.st_mode)) {
427
-			    if(dirlnk != 2 && filelnk != 2) {
428
-				if(!printinfected)
429
-				    logg("%s: Symbolic link\n", fname);
430
-			    } else if(CLAMSTAT(fname, &sb) != -1) {
431
-				if(S_ISREG(sb.st_mode) && filelnk == 2) {
432
-				    scanfile(fname, engine, opts, options);
433
-				} else if(S_ISDIR(sb.st_mode) && dirlnk == 2) {
434
-				    if(recursion)
435
-					scandirs(fname, engine, opts, options, depth, dev);
436
-				} else {
437
-				    if(!printinfected)
438
-					logg("%s: Symbolic link\n", fname);
439
-				}
440
-			    }
441
-			} else if(S_ISREG(sb.st_mode)) {
442
-			    scanfile(fname, engine, opts, options);
443
-			} else if(S_ISDIR(sb.st_mode) && recursion) {
444
-			    scandirs(fname, engine, opts, options, depth, dev);
445
-			}
446
-		    }
447
-		    free(fname);
448
-		}
449
-	    }
450
-	}
451
-	closedir(dd);
432
+        info.dirs++;
433
+        depth++;
434
+        while((dent = readdir(dd))) {
435
+            if(dent->d_ino) {
436
+                if(strcmp(dent->d_name, ".") && strcmp(dent->d_name, "..")) {
437
+                    /* build the full name */
438
+                    fname = malloc(strlen(dirname) + strlen(dent->d_name) + 2);
439
+                    if (fname == NULL) { /* oops, malloc() failed, print warning and return */
440
+                        logg("!scandirs: Memory allocation failed for fname\n");
441
+                        break;
442
+                    }
443
+
444
+                    if(!strcmp(dirname, PATHSEP))
445
+                        sprintf(fname, PATHSEP"%s", dent->d_name);
446
+                    else
447
+                        sprintf(fname, "%s"PATHSEP"%s", dirname, dent->d_name);
448
+
449
+                    /* stat the file */
450
+                    if(LSTAT(fname, &sb) != -1) {
451
+                        if(!optget(opts, "cross-fs")->enabled) {
452
+                            if(sb.st_dev != dev) {
453
+                                if(!printinfected)
454
+                                    logg("~%s: Excluded\n", fname);
455
+
456
+                                free(fname);
457
+                                continue;
458
+                            }
459
+                        }
460
+                        if(S_ISLNK(sb.st_mode)) {
461
+                            if(dirlnk != 2 && filelnk != 2) {
462
+                                if(!printinfected)
463
+                                    logg("%s: Symbolic link\n", fname);
464
+                            } else if(CLAMSTAT(fname, &sb) != -1) {
465
+                                if(S_ISREG(sb.st_mode) && filelnk == 2) {
466
+                                    scanfile(fname, engine, opts, options);
467
+                                } else if(S_ISDIR(sb.st_mode) && dirlnk == 2) {
468
+                                    if(recursion)
469
+                                        scandirs(fname, engine, opts, options, depth, dev);
470
+                                } else {
471
+                                    if(!printinfected)
472
+                                        logg("%s: Symbolic link\n", fname);
473
+                                }
474
+                            }
475
+                        } else if(S_ISREG(sb.st_mode)) {
476
+                            scanfile(fname, engine, opts, options);
477
+                        } else if(S_ISDIR(sb.st_mode) && recursion) {
478
+                            scandirs(fname, engine, opts, options, depth, dev);
479
+                        }
480
+                    }
481
+
482
+                    free(fname);
483
+                }
484
+            }
485
+        }
486
+        closedir(dd);
452 487
     } else {
453
-	if(!printinfected)
454
-	    logg("~%s: Can't open directory.\n", dirname);
455
-	info.errors++;
488
+        if(!printinfected)
489
+            logg("~%s: Can't open directory.\n", dirname);
490
+
491
+        info.errors++;
456 492
     }
457 493
 }
458 494
 
459 495
 static int scanstdin(const struct cl_engine *engine, const struct optstruct *opts, int options)
460 496
 {
461
-	int ret;
462
-	unsigned int fsize = 0;
463
-	const char *virname, *tmpdir;
464
-	const char **virpp = &virname;
465
-
466
-	char *file, buff[FILEBUFF];
467
-	size_t bread;
468
-	FILE *fs;
497
+    int ret;
498
+    unsigned int fsize = 0;
499
+    const char *virname, *tmpdir;
500
+    const char **virpp = &virname;
501
+    char *file, buff[FILEBUFF];
502
+    size_t bread;
503
+    FILE *fs;
469 504
 
470 505
     if(optget(opts, "tempdir")->enabled) {
471
-	tmpdir = optget(opts, "tempdir")->strarg;
472
-    } else
473
-	/* check write access */
474
-	tmpdir = cli_gettmpdir();
506
+        tmpdir = optget(opts, "tempdir")->strarg;
507
+    } else {
508
+        /* check write access */
509
+        tmpdir = cli_gettmpdir();
510
+    }
475 511
 
476 512
     if(checkaccess(tmpdir, CLAMAVUSER, W_OK) != 1) {
477
-	logg("!Can't write to temporary directory\n");
478
-	return 2;
513
+        logg("!Can't write to temporary directory\n");
514
+        return 2;
479 515
     }
480 516
 
481 517
     if(!(file = cli_gentemp(tmpdir))) {
482
-	logg("!Can't generate tempfile name\n");
483
-	return 2;
518
+        logg("!Can't generate tempfile name\n");
519
+        return 2;
484 520
     }
485 521
 
486 522
     if(!(fs = fopen(file, "wb"))) {
487
-	logg("!Can't open %s for writing\n", file);
488
-	free(file);
489
-	return 2;
523
+        logg("!Can't open %s for writing\n", file);
524
+        free(file);
525
+        return 2;
490 526
     }
491 527
 
492 528
     while((bread = fread(buff, 1, FILEBUFF, stdin))) {
493
-	fsize += bread;
494
-	if(fwrite(buff, 1, bread, fs) < bread) {
495
-	    logg("!Can't write to %s\n", file);
496
-	    free(file);
497
-	    fclose(fs);
498
-	    return 2;
499
-	}
529
+        fsize += bread;
530
+        if(fwrite(buff, 1, bread, fs) < bread) {
531
+            logg("!Can't write to %s\n", file);
532
+            free(file);
533
+            fclose(fs);
534
+            return 2;
535
+        }
500 536
     }
537
+
501 538
     fclose(fs);
502 539
 
503 540
     logg("*Checking %s\n", file);
541
+
504 542
     info.files++;
505 543
     info.rblocks += fsize / CL_COUNT_PRECISION;
506 544
 
507 545
     if((ret = cl_scanfile(file, &virname, &info.blocks, engine, options)) == CL_VIRUS) {
508 546
         if (options & CL_SCAN_ALLMATCHES) {
509 547
             int i = 0;
548
+
510 549
             virpp = (const char **)*virpp; /* temp hack for scanall mode until api augmentation */
511 550
             virname = virpp[0];
551
+
512 552
             while (virpp[i])
513 553
                 logg("stdin: %s FOUND\n", virpp[i++]);
554
+
514 555
             free((void *)virpp);
556
+        } else {
557
+            logg("stdin: %s FOUND\n", virname);
515 558
         }
516
-	else
517
-	    logg("stdin: %s FOUND\n", virname);
518
-
519
-	info.ifiles++;
520 559
 
521
-	if(bell)
522
-	    fprintf(stderr, "\007");
560
+        info.ifiles++;
523 561
 
562
+        if(bell)
563
+            fprintf(stderr, "\007");
524 564
     } else if(ret == CL_CLEAN) {
525
-	if(!printinfected)
526
-	    mprintf("stdin: OK\n");
565
+        if(!printinfected)
566
+            mprintf("stdin: OK\n");
527 567
     } else {
528
-	if(!printinfected)
529
-	    logg("stdin: %s ERROR\n", cl_strerror(ret));
530
-	info.errors++;
568
+        if(!printinfected)
569
+            logg("stdin: %s ERROR\n", cl_strerror(ret));
570
+
571
+        info.errors++;
531 572
     }
532 573
 
533 574
     unlink(file);
... ...
@@ -537,49 +583,49 @@ static int scanstdin(const struct cl_engine *engine, const struct optstruct *opt
537 537
 
538 538
 int scanmanager(const struct optstruct *opts)
539 539
 {
540
-	int ret = 0, i;
541
-	unsigned int options = 0, dboptions = 0, dirlnk = 1, filelnk = 1;
542
-	struct cl_engine *engine;
543
-	STATBUF sb;
544
-	char *file, cwd[1024], *pua_cats = NULL;
545
-	const char *filename;
546
-	const struct optstruct *opt;
540
+    int ret = 0, i;
541
+    unsigned int options = 0, dboptions = 0, dirlnk = 1, filelnk = 1;
542
+    struct cl_engine *engine;
543
+    STATBUF sb;
544
+    char *file, cwd[1024], *pua_cats = NULL;
545
+    const char *filename;
546
+    const struct optstruct *opt;
547 547
 #ifndef _WIN32
548
-	struct rlimit rlim;
548
+    struct rlimit rlim;
549 549
 #endif
550 550
 
551 551
     dirlnk = optget(opts, "follow-dir-symlinks")->numarg;
552 552
     if(dirlnk > 2) {
553
-	logg("!--follow-dir-symlinks: Invalid argument\n");
554
-	return 2;
553
+        logg("!--follow-dir-symlinks: Invalid argument\n");
554
+        return 2;
555 555
     }
556 556
 
557 557
     filelnk = optget(opts, "follow-file-symlinks")->numarg;
558 558
     if(filelnk > 2) {
559
-	logg("!--follow-file-symlinks: Invalid argument\n");
560
-	return 2;
559
+        logg("!--follow-file-symlinks: Invalid argument\n");
560
+        return 2;
561 561
     }
562 562
 
563 563
     if(optget(opts, "phishing-sigs")->enabled)
564
-	dboptions |= CL_DB_PHISHING;
564
+        dboptions |= CL_DB_PHISHING;
565 565
 
566 566
     if(optget(opts, "official-db-only")->enabled)
567
-	dboptions |= CL_DB_OFFICIAL_ONLY;
567
+        dboptions |= CL_DB_OFFICIAL_ONLY;
568 568
 
569 569
     if(optget(opts,"phishing-scan-urls")->enabled)
570
-	dboptions |= CL_DB_PHISHING_URLS;
570
+        dboptions |= CL_DB_PHISHING_URLS;
571 571
 
572 572
     if(optget(opts,"bytecode")->enabled)
573
-	dboptions |= CL_DB_BYTECODE;
573
+        dboptions |= CL_DB_BYTECODE;
574 574
 
575 575
     if((ret = cl_init(CL_INIT_DEFAULT))) {
576
-	logg("!Can't initialize libclamav: %s\n", cl_strerror(ret));
577
-	return 2;
576
+        logg("!Can't initialize libclamav: %s\n", cl_strerror(ret));
577
+        return 2;
578 578
     }
579 579
 
580 580
     if(!(engine = cl_engine_new())) {
581
-	logg("!Can't initialize antivirus engine\n");
582
-	return 2;
581
+        logg("!Can't initialize antivirus engine\n");
582
+        return 2;
583 583
     }
584 584
 
585 585
     if (optget(opts, "disable-cache")->enabled)
... ...
@@ -608,6 +654,7 @@ int scanmanager(const struct optstruct *opts)
608 608
             } else {
609 609
                 if (strlen(p) > 36) {
610 610
                     logg("!Invalid HostID\n");
611
+
611 612
                     cl_engine_set_clcb_stats_submit(engine, NULL);
612 613
                     cl_engine_free(engine);
613 614
                     return 2;
... ...
@@ -621,88 +668,101 @@ int scanmanager(const struct optstruct *opts)
621 621
     }
622 622
 
623 623
     if(optget(opts, "detect-pua")->enabled) {
624
-	dboptions |= CL_DB_PUA;
625
-	if((opt = optget(opts, "exclude-pua"))->enabled) {
626
-	    dboptions |= CL_DB_PUA_EXCLUDE;
627
-	    i = 0;
628
-	    while(opt) {
629
-		if(!(pua_cats = realloc(pua_cats, i + strlen(opt->strarg) + 3))) {
630
-		    logg("!Can't allocate memory for pua_cats\n");
631
-		    cl_engine_free(engine);
632
-		    return 2;
633
-		}
634
-		sprintf(pua_cats + i, ".%s", opt->strarg);
635
-		i += strlen(opt->strarg) + 1;
636
-		pua_cats[i] = 0;
637
-		opt = opt->nextarg;
638
-	    }
639
-	    pua_cats[i] = '.';
640
-	    pua_cats[i + 1] = 0;
641
-	}
642
-
643
-	if((opt = optget(opts, "include-pua"))->enabled) {
644
-	    if(pua_cats) {
645
-		logg("!--exclude-pua and --include-pua cannot be used at the same time\n");
646
-		cl_engine_free(engine);
647
-		free(pua_cats);
648
-		return 2;
649
-	    }
650
-	    dboptions |= CL_DB_PUA_INCLUDE;
651
-	    i = 0;
652
-	    while(opt) {
653
-		if(!(pua_cats = realloc(pua_cats, i + strlen(opt->strarg) + 3))) {
654
-		    logg("!Can't allocate memory for pua_cats\n");
655
-		    cl_engine_free(engine);
656
-		    return 2;
657
-		}
658
-		sprintf(pua_cats + i, ".%s", opt->strarg);
659
-		i += strlen(opt->strarg) + 1;
660
-		pua_cats[i] = 0;
661
-		opt = opt->nextarg;
662
-	    }
663
-	    pua_cats[i] = '.';
664
-	    pua_cats[i + 1] = 0;
665
-	}
666
-
667
-	if(pua_cats) {
668
-	    if((ret = cl_engine_set_str(engine, CL_ENGINE_PUA_CATEGORIES, pua_cats))) {
669
-		logg("!cli_engine_set_str(CL_ENGINE_PUA_CATEGORIES) failed: %s\n", cl_strerror(ret));
670
-		free(pua_cats);
671
-		cl_engine_free(engine);
672
-		return 2;
673
-	    }
674
-	    free(pua_cats);
675
-	}
624
+        dboptions |= CL_DB_PUA;
625
+        if((opt = optget(opts, "exclude-pua"))->enabled) {
626
+            dboptions |= CL_DB_PUA_EXCLUDE;
627
+            i = 0;
628
+            while(opt) {
629
+                if(!(pua_cats = realloc(pua_cats, i + strlen(opt->strarg) + 3))) {
630
+                    logg("!Can't allocate memory for pua_cats\n");
631
+
632
+                    cl_engine_free(engine);
633
+                    return 2;
634
+                }
635
+
636
+                sprintf(pua_cats + i, ".%s", opt->strarg);
637
+                i += strlen(opt->strarg) + 1;
638
+                pua_cats[i] = 0;
639
+
640
+                opt = opt->nextarg;
641
+            }
642
+            pua_cats[i] = '.';
643
+            pua_cats[i + 1] = 0;
644
+        }
645
+
646
+        if((opt = optget(opts, "include-pua"))->enabled) {
647
+            if(pua_cats) {
648
+                logg("!--exclude-pua and --include-pua cannot be used at the same time\n");
649
+
650
+                cl_engine_free(engine);
651
+                free(pua_cats);
652
+                return 2;
653
+            }
654
+
655
+            dboptions |= CL_DB_PUA_INCLUDE;
656
+            i = 0;
657
+            while(opt) {
658
+                if(!(pua_cats = realloc(pua_cats, i + strlen(opt->strarg) + 3))) {
659
+                    logg("!Can't allocate memory for pua_cats\n");
660
+                    cl_engine_free(engine);
661
+                    return 2;
662
+                }
663
+
664
+                sprintf(pua_cats + i, ".%s", opt->strarg);
665
+                i += strlen(opt->strarg) + 1;
666
+                pua_cats[i] = 0;
667
+
668
+                opt = opt->nextarg;
669
+            }
670
+
671
+            pua_cats[i] = '.';
672
+            pua_cats[i + 1] = 0;
673
+        }
674
+
675
+        if(pua_cats) {
676
+            if((ret = cl_engine_set_str(engine, CL_ENGINE_PUA_CATEGORIES, pua_cats))) {
677
+                logg("!cli_engine_set_str(CL_ENGINE_PUA_CATEGORIES) failed: %s\n", cl_strerror(ret));
678
+
679
+                free(pua_cats);
680
+                cl_engine_free(engine);
681
+                return 2;
682
+            }
683
+
684
+            free(pua_cats);
685
+        }
676 686
     }
677 687
 
678 688
     if(optget(opts, "dev-ac-only")->enabled)
679
-	cl_engine_set_num(engine, CL_ENGINE_AC_ONLY, 1);
689
+        cl_engine_set_num(engine, CL_ENGINE_AC_ONLY, 1);
680 690
 
681 691
     if(optget(opts, "dev-ac-depth")->enabled)
682
-	cl_engine_set_num(engine, CL_ENGINE_AC_MAXDEPTH, optget(opts, "dev-ac-depth")->numarg);
692
+        cl_engine_set_num(engine, CL_ENGINE_AC_MAXDEPTH, optget(opts, "dev-ac-depth")->numarg);
683 693
 
684 694
     if(optget(opts, "leave-temps")->enabled)
685
-	cl_engine_set_num(engine, CL_ENGINE_KEEPTMP, 1);
695
+        cl_engine_set_num(engine, CL_ENGINE_KEEPTMP, 1);
686 696
 
687 697
     if(optget(opts, "force-to-disk")->enabled)
688
-	cl_engine_set_num(engine, CL_ENGINE_FORCETODISK, 1);
698
+        cl_engine_set_num(engine, CL_ENGINE_FORCETODISK, 1);
689 699
 
690 700
     if(optget(opts, "bytecode-unsigned")->enabled)
691
-	dboptions |= CL_DB_BYTECODE_UNSIGNED;
701
+        dboptions |= CL_DB_BYTECODE_UNSIGNED;
692 702
 
693 703
     if((opt = optget(opts,"bytecode-timeout"))->enabled)
694
-	cl_engine_set_num(engine, CL_ENGINE_BYTECODE_TIMEOUT, opt->numarg);
704
+        cl_engine_set_num(engine, CL_ENGINE_BYTECODE_TIMEOUT, opt->numarg);
705
+
695 706
     if((opt = optget(opts,"bytecode-mode"))->enabled) {
696
-	enum bytecode_mode mode;
697
-	if (!strcmp(opt->strarg, "ForceJIT"))
698
-	    mode = CL_BYTECODE_MODE_JIT;
699
-	else if(!strcmp(opt->strarg, "ForceInterpreter"))
700
-	    mode = CL_BYTECODE_MODE_INTERPRETER;
701
-	else if(!strcmp(opt->strarg, "Test"))
702
-	    mode = CL_BYTECODE_MODE_TEST;
703
-	else
704
-	    mode = CL_BYTECODE_MODE_AUTO;
705
-	cl_engine_set_num(engine, CL_ENGINE_BYTECODE_MODE, mode);
707
+        enum bytecode_mode mode;
708
+
709
+        if (!strcmp(opt->strarg, "ForceJIT"))
710
+            mode = CL_BYTECODE_MODE_JIT;
711
+        else if(!strcmp(opt->strarg, "ForceInterpreter"))
712
+            mode = CL_BYTECODE_MODE_INTERPRETER;
713
+        else if(!strcmp(opt->strarg, "Test"))
714
+            mode = CL_BYTECODE_MODE_TEST;
715
+        else
716
+            mode = CL_BYTECODE_MODE_AUTO;
717
+
718
+        cl_engine_set_num(engine, CL_ENGINE_BYTECODE_MODE, mode);
706 719
     }
707 720
 
708 721
     if((opt = optget(opts, "statistics"))->enabled) {
... ...
@@ -718,44 +778,50 @@ int scanmanager(const struct optstruct *opts)
718 718
     }
719 719
 
720 720
     if((opt = optget(opts, "tempdir"))->enabled) {
721
-	if((ret = cl_engine_set_str(engine, CL_ENGINE_TMPDIR, opt->strarg))) {
722
-	    logg("!cli_engine_set_str(CL_ENGINE_TMPDIR) failed: %s\n", cl_strerror(ret));
723
-	    cl_engine_free(engine);
724
-	    return 2;
725
-	}
721
+        if((ret = cl_engine_set_str(engine, CL_ENGINE_TMPDIR, opt->strarg))) {
722
+            logg("!cli_engine_set_str(CL_ENGINE_TMPDIR) failed: %s\n", cl_strerror(ret));
723
+
724
+            cl_engine_free(engine);
725
+            return 2;
726
+        }
726 727
     }
727 728
 
728 729
     if((opt = optget(opts, "database"))->active) {
729
-	while(opt) {
730
-	    if((ret = cl_load(opt->strarg, engine, &info.sigs, dboptions))) {
731
-		logg("!%s\n", cl_strerror(ret));
732
-		cl_engine_free(engine);
733
-		return 2;
734
-	    }
735
-	    opt = opt->nextarg;
736
-	}
730
+        while(opt) {
731
+            if((ret = cl_load(opt->strarg, engine, &info.sigs, dboptions))) {
732
+                logg("!%s\n", cl_strerror(ret));
733
+
734
+                cl_engine_free(engine);
735
+                return 2;
736
+            }
737
+
738
+            opt = opt->nextarg;
739
+        }
737 740
     } else {
738
-	    char *dbdir = freshdbdir();
739
-
740
-	if((ret = cl_load(dbdir, engine, &info.sigs, dboptions))) {
741
-	    logg("!%s\n", cl_strerror(ret));
742
-	    free(dbdir);
743
-	    cl_engine_free(engine);
744
-	    return 2;
745
-	}
746
-	free(dbdir);
741
+        char *dbdir = freshdbdir();
742
+
743
+        if((ret = cl_load(dbdir, engine, &info.sigs, dboptions))) {
744
+            logg("!%s\n", cl_strerror(ret));
745
+
746
+            free(dbdir);
747
+            cl_engine_free(engine);
748
+            return 2;
749
+        }
750
+
751
+        free(dbdir);
747 752
     }
748 753
 
749 754
     if((ret = cl_engine_compile(engine)) != 0) {
750
-	logg("!Database initialization error: %s\n", cl_strerror(ret));;
751
-	cl_engine_free(engine);
752
-	return 2;
755
+        logg("!Database initialization error: %s\n", cl_strerror(ret));;
756
+
757
+        cl_engine_free(engine);
758
+        return 2;
753 759
     }
754 760
 
755 761
     if(optget(opts, "archive-verbose")->enabled) {
756
-	cl_engine_set_clcb_meta(engine, meta);
757
-	cl_engine_set_clcb_pre_cache(engine, pre);
758
-	cl_engine_set_clcb_post_scan(engine, post);
762
+        cl_engine_set_clcb_meta(engine, meta);
763
+        cl_engine_set_clcb_pre_cache(engine, pre);
764
+        cl_engine_set_clcb_post_scan(engine, post);
759 765
     }
760 766
 
761 767
     if (optget(opts, "nocerts")->enabled)
... ...
@@ -767,111 +833,123 @@ int scanmanager(const struct optstruct *opts)
767 767
     /* set limits */
768 768
 
769 769
     if((opt = optget(opts, "max-scansize"))->active) {
770
-	if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_SCANSIZE, opt->numarg))) {
771
-	    logg("!cli_engine_set_num(CL_ENGINE_MAX_SCANSIZE) failed: %s\n", cl_strerror(ret));
772
-	    cl_engine_free(engine);
773
-	    return 2;
774
-	}
770
+        if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_SCANSIZE, opt->numarg))) {
771
+            logg("!cli_engine_set_num(CL_ENGINE_MAX_SCANSIZE) failed: %s\n", cl_strerror(ret));
772
+
773
+            cl_engine_free(engine);
774
+            return 2;
775
+        }
775 776
     }
776 777
 
777 778
     if((opt = optget(opts, "max-filesize"))->active) {
778
-	if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_FILESIZE, opt->numarg))) {
779
-	    logg("!cli_engine_set_num(CL_ENGINE_MAX_FILESIZE) failed: %s\n", cl_strerror(ret));
780
-	    cl_engine_free(engine);
781
-	    return 2;
782
-	}
779
+        if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_FILESIZE, opt->numarg))) {
780
+            logg("!cli_engine_set_num(CL_ENGINE_MAX_FILESIZE) failed: %s\n", cl_strerror(ret));
781
+
782
+            cl_engine_free(engine);
783
+            return 2;
784
+        }
783 785
     }
784 786
 
785 787
 #ifndef _WIN32
786 788
     if(getrlimit(RLIMIT_FSIZE, &rlim) == 0) {
787
-	if(rlim.rlim_cur < (rlim_t) cl_engine_get_num(engine, CL_ENGINE_MAX_FILESIZE, NULL))
788
-	    logg("^System limit for file size is lower than engine->maxfilesize\n");
789
-	if(rlim.rlim_cur < (rlim_t) cl_engine_get_num(engine, CL_ENGINE_MAX_SCANSIZE, NULL))
790
-	    logg("^System limit for file size is lower than engine->maxscansize\n");
789
+        if(rlim.rlim_cur < (rlim_t) cl_engine_get_num(engine, CL_ENGINE_MAX_FILESIZE, NULL))
790
+            logg("^System limit for file size is lower than engine->maxfilesize\n");
791
+        if(rlim.rlim_cur < (rlim_t) cl_engine_get_num(engine, CL_ENGINE_MAX_SCANSIZE, NULL))
792
+            logg("^System limit for file size is lower than engine->maxscansize\n");
791 793
     } else {
792
-	logg("^Cannot obtain resource limits for file size\n");
794
+        logg("^Cannot obtain resource limits for file size\n");
793 795
     }
794 796
 #endif
795 797
 
796 798
     if((opt = optget(opts, "max-files"))->active) {
797
-	if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_FILES, opt->numarg))) {
798
-	    logg("!cli_engine_set_num(CL_ENGINE_MAX_FILES) failed: %s\n", cl_strerror(ret));
799
-	    cl_engine_free(engine);
800
-	    return 2;
801
-	}
799
+        if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_FILES, opt->numarg))) {
800
+            logg("!cli_engine_set_num(CL_ENGINE_MAX_FILES) failed: %s\n", cl_strerror(ret));
801
+
802
+            cl_engine_free(engine);
803
+            return 2;
804
+        }
802 805
     }
803 806
 
804 807
     if((opt = optget(opts, "max-recursion"))->active) {
805
-	if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_RECURSION, opt->numarg))) {
806
-	    logg("!cli_engine_set_num(CL_ENGINE_MAX_RECURSION) failed: %s\n", cl_strerror(ret));
807
-	    cl_engine_free(engine);
808
-	    return 2;
809
-	}
808
+        if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_RECURSION, opt->numarg))) {
809
+            logg("!cli_engine_set_num(CL_ENGINE_MAX_RECURSION) failed: %s\n", cl_strerror(ret));
810
+
811
+            cl_engine_free(engine);
812
+            return 2;
813
+        }
810 814
     }
811 815
 
812 816
     /* Engine max sizes */
813 817
 
814 818
     if((opt = optget(opts, "max-embeddedpe"))->active) {
815
-	if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_EMBEDDEDPE, opt->numarg))) {
816
-	    logg("!cli_engine_set_num(CL_ENGINE_MAX_EMBEDDEDPE) failed: %s\n", cl_strerror(ret));
817
-	    cl_engine_free(engine);
818
-	    return 2;
819
-	}
819
+        if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_EMBEDDEDPE, opt->numarg))) {
820
+            logg("!cli_engine_set_num(CL_ENGINE_MAX_EMBEDDEDPE) failed: %s\n", cl_strerror(ret));
821
+
822
+            cl_engine_free(engine);
823
+            return 2;
824
+        }
820 825
     }
821 826
 
822 827
     if((opt = optget(opts, "max-htmlnormalize"))->active) {
823
-	if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_HTMLNORMALIZE, opt->numarg))) {
824
-	    logg("!cli_engine_set_num(CL_ENGINE_MAX_HTMLNORMALIZE) failed: %s\n", cl_strerror(ret));
825
-	    cl_engine_free(engine);
826
-	    return 2;
827
-	}
828
+        if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_HTMLNORMALIZE, opt->numarg))) {
829
+            logg("!cli_engine_set_num(CL_ENGINE_MAX_HTMLNORMALIZE) failed: %s\n", cl_strerror(ret));
830
+
831
+            cl_engine_free(engine);
832
+            return 2;
833
+        }
828 834
     }
829 835
 
830 836
     if((opt = optget(opts, "max-htmlnotags"))->active) {
831
-	if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_HTMLNOTAGS, opt->numarg))) {
832
-	    logg("!cli_engine_set_num(CL_ENGINE_MAX_HTMLNOTAGS) failed: %s\n", cl_strerror(ret));
833
-	    cl_engine_free(engine);
834
-	    return 2;
835
-	}
837
+        if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_HTMLNOTAGS, opt->numarg))) {
838
+            logg("!cli_engine_set_num(CL_ENGINE_MAX_HTMLNOTAGS) failed: %s\n", cl_strerror(ret));
839
+
840
+            cl_engine_free(engine);
841
+            return 2;
842
+        }
836 843
     }
837 844
 
838 845
     if((opt = optget(opts, "max-scriptnormalize"))->active) {
839
-	if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_SCRIPTNORMALIZE, opt->numarg))) {
840
-	    logg("!cli_engine_set_num(CL_ENGINE_MAX_SCRIPTNORMALIZE) failed: %s\n", cl_strerror(ret));
841
-	    cl_engine_free(engine);
842
-	    return 2;
843
-	}
846
+        if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_SCRIPTNORMALIZE, opt->numarg))) {
847
+            logg("!cli_engine_set_num(CL_ENGINE_MAX_SCRIPTNORMALIZE) failed: %s\n", cl_strerror(ret));
848
+
849
+            cl_engine_free(engine);
850
+            return 2;
851
+        }
844 852
     }
845 853
 
846 854
     if((opt = optget(opts, "max-ziptypercg"))->active) {
847
-	if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_ZIPTYPERCG, opt->numarg))) {
848
-	    logg("!cli_engine_set_num(CL_ENGINE_MAX_ZIPTYPERCG) failed: %s\n", cl_strerror(ret));
849
-	    cl_engine_free(engine);
850
-	    return 2;
851
-	}
855
+        if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_ZIPTYPERCG, opt->numarg))) {
856
+            logg("!cli_engine_set_num(CL_ENGINE_MAX_ZIPTYPERCG) failed: %s\n", cl_strerror(ret));
857
+
858
+            cl_engine_free(engine);
859
+            return 2;
860
+        }
852 861
     }
853 862
 
854 863
     if((opt = optget(opts, "max-partitions"))->active) {
855
-	if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_PARTITIONS, opt->numarg))) {
856
-	    logg("!cli_engine_set_num(CL_ENGINE_MAX_PARTITIONS) failed: %s\n", cl_strerror(ret));
857
-	    cl_engine_free(engine);
858
-	    return 2;
859
-	}
864
+        if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_PARTITIONS, opt->numarg))) {
865
+            logg("!cli_engine_set_num(CL_ENGINE_MAX_PARTITIONS) failed: %s\n", cl_strerror(ret));
866
+
867
+            cl_engine_free(engine);
868
+            return 2;
869
+        }
860 870
     }
861 871
 
862 872
     if((opt = optget(opts, "max-iconspe"))->active) {
863
-	if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_ICONSPE, opt->numarg))) {
864
-	    logg("!cli_engine_set_num(CL_ENGINE_MAX_ICONSPE) failed: %s\n", cl_strerror(ret));
865
-	    cl_engine_free(engine);
866
-	    return 2;
867
-	}
873
+        if((ret = cl_engine_set_num(engine, CL_ENGINE_MAX_ICONSPE, opt->numarg))) {
874
+            logg("!cli_engine_set_num(CL_ENGINE_MAX_ICONSPE) failed: %s\n", cl_strerror(ret));
875
+
876
+            cl_engine_free(engine);
877
+            return 2;
878
+        }
868 879
     }
869 880
 
870 881
     if ((opt = optget(opts, "timelimit"))->active) {
871 882
         if ((ret = cl_engine_set_num(engine, CL_ENGINE_TIME_LIMIT, opt->numarg))) {
872
-	    logg("!cli_engine_set_num(CL_ENGINE_TIME_LIMIT) failed: %s\n", cl_strerror(ret));
873
-	    cl_engine_free(engine);
874
-	    return 2;
883
+            logg("!cli_engine_set_num(CL_ENGINE_TIME_LIMIT) failed: %s\n", cl_strerror(ret));
884
+
885
+            cl_engine_free(engine);
886
+            return 2;
875 887
         }
876 888
     }
877 889
 
... ...
@@ -901,107 +979,107 @@ int scanmanager(const struct optstruct *opts)
901 901
 
902 902
     /* set scan options */
903 903
     if(optget(opts, "allmatch")->enabled)
904
-	options |= CL_SCAN_ALLMATCHES;
904
+        options |= CL_SCAN_ALLMATCHES;
905 905
 
906 906
     if(optget(opts,"phishing-ssl")->enabled)
907
-	options |= CL_SCAN_PHISHING_BLOCKSSL;
907
+        options |= CL_SCAN_PHISHING_BLOCKSSL;
908 908
 
909 909
     if(optget(opts,"phishing-cloak")->enabled)
910
-	options |= CL_SCAN_PHISHING_BLOCKCLOAK;
910
+        options |= CL_SCAN_PHISHING_BLOCKCLOAK;
911 911
 
912 912
     if(optget(opts,"partition-intersection")->enabled)
913
-	options |= CL_SCAN_PARTITION_INTXN;
913
+        options |= CL_SCAN_PARTITION_INTXN;
914 914
 
915 915
     if(optget(opts,"heuristic-scan-precedence")->enabled)
916
-	options |= CL_SCAN_HEURISTIC_PRECEDENCE;
916
+        options |= CL_SCAN_HEURISTIC_PRECEDENCE;
917 917
 
918 918
     if(optget(opts, "scan-archive")->enabled)
919
-	options |= CL_SCAN_ARCHIVE;
919
+        options |= CL_SCAN_ARCHIVE;
920 920
 
921 921
     if(optget(opts, "detect-broken")->enabled)
922
-	options |= CL_SCAN_BLOCKBROKEN;
922
+        options |= CL_SCAN_BLOCKBROKEN;
923 923
 
924 924
     if(optget(opts, "block-encrypted")->enabled)
925
-	options |= CL_SCAN_BLOCKENCRYPTED;
925
+        options |= CL_SCAN_BLOCKENCRYPTED;
926 926
 
927 927
     if(optget(opts, "scan-pe")->enabled)
928
-	options |= CL_SCAN_PE;
928
+        options |= CL_SCAN_PE;
929 929
 
930 930
     if(optget(opts, "scan-elf")->enabled)
931
-	options |= CL_SCAN_ELF;
931
+        options |= CL_SCAN_ELF;
932 932
 
933 933
     if(optget(opts, "scan-ole2")->enabled)
934
-	options |= CL_SCAN_OLE2;
934
+        options |= CL_SCAN_OLE2;
935 935
 
936 936
     if(optget(opts, "scan-pdf")->enabled)
937
-	options |= CL_SCAN_PDF;
937
+        options |= CL_SCAN_PDF;
938 938
 
939 939
     if(optget(opts, "scan-swf")->enabled)
940
-	options |= CL_SCAN_SWF;
940
+        options |= CL_SCAN_SWF;
941 941
 
942 942
     if(optget(opts, "scan-html")->enabled)
943
-	options |= CL_SCAN_HTML;
943
+        options |= CL_SCAN_HTML;
944 944
 
945 945
     if(optget(opts, "scan-mail")->enabled)
946
-	options |= CL_SCAN_MAIL;
946
+        options |= CL_SCAN_MAIL;
947 947
 
948 948
     if(optget(opts, "algorithmic-detection")->enabled)
949
-	options |= CL_SCAN_ALGORITHMIC;
949
+        options |= CL_SCAN_ALGORITHMIC;
950 950
 
951 951
 #ifdef HAVE__INTERNAL__SHA_COLLECT
952 952
     if(optget(opts, "dev-collect-hashes")->enabled)
953
-	options |= CL_SCAN_INTERNAL_COLLECT_SHA;
953
+        options |= CL_SCAN_INTERNAL_COLLECT_SHA;
954 954
 #endif
955 955
 
956 956
     if(optget(opts, "dev-performance")->enabled)
957
-	options |= CL_SCAN_PERFORMANCE_INFO;
957
+        options |= CL_SCAN_PERFORMANCE_INFO;
958 958
 
959 959
     if(optget(opts, "detect-structured")->enabled) {
960
-	options |= CL_SCAN_STRUCTURED;
961
-
962
-	if((opt = optget(opts, "structured-ssn-format"))->enabled) {
963
-	    switch(opt->numarg) {
964
-		case 0:
965
-		    options |= CL_SCAN_STRUCTURED_SSN_NORMAL;
966
-		    break;
967
-		case 1:
968
-		    options |= CL_SCAN_STRUCTURED_SSN_STRIPPED;
969
-		    break;
970
-		case 2:
971
-		    options |= (CL_SCAN_STRUCTURED_SSN_NORMAL | CL_SCAN_STRUCTURED_SSN_STRIPPED);
972
-		    break;
973
-		default:
974
-		    logg("!Invalid argument for --structured-ssn-format\n");
975
-		    return 2;
976
-	    }
977
-	} else {
978
-	    options |= CL_SCAN_STRUCTURED_SSN_NORMAL;
979
-	}
980
-
981
-	if((opt = optget(opts, "structured-ssn-count"))->active) {
982
-	    if((ret = cl_engine_set_num(engine, CL_ENGINE_MIN_SSN_COUNT, opt->numarg))) {
983
-		logg("!cli_engine_set_num(CL_ENGINE_MIN_SSN_COUNT) failed: %s\n", cl_strerror(ret));
984
-		cl_engine_free(engine);
985
-		return 2;
986
-	    }
987
-	}
960
+        options |= CL_SCAN_STRUCTURED;
961
+
962
+        if((opt = optget(opts, "structured-ssn-format"))->enabled) {
963
+            switch(opt->numarg) {
964
+            case 0:
965
+                options |= CL_SCAN_STRUCTURED_SSN_NORMAL;
966
+                break;
967
+            case 1:
968
+                options |= CL_SCAN_STRUCTURED_SSN_STRIPPED;
969
+                break;
970
+            case 2:
971
+                options |= (CL_SCAN_STRUCTURED_SSN_NORMAL | CL_SCAN_STRUCTURED_SSN_STRIPPED);
972
+                break;
973
+            default:
974
+                logg("!Invalid argument for --structured-ssn-format\n");
975
+                return 2;
976
+            }
977
+        } else {
978
+            options |= CL_SCAN_STRUCTURED_SSN_NORMAL;
979
+        }
988 980
 
989
-	if((opt = optget(opts, "structured-cc-count"))->active) {
990
-	    if((ret = cl_engine_set_num(engine, CL_ENGINE_MIN_CC_COUNT, opt->numarg))) {
991
-		logg("!cli_engine_set_num(CL_ENGINE_MIN_CC_COUNT) failed: %s\n", cl_strerror(ret));
992
-		cl_engine_free(engine);
993
-		return 2;
994
-	    }
995
-	}
981
+        if((opt = optget(opts, "structured-ssn-count"))->active) {
982
+            if((ret = cl_engine_set_num(engine, CL_ENGINE_MIN_SSN_COUNT, opt->numarg))) {
983
+                logg("!cli_engine_set_num(CL_ENGINE_MIN_SSN_COUNT) failed: %s\n", cl_strerror(ret));
996 984
 
985
+                cl_engine_free(engine);
986
+                return 2;
987
+            }
988
+        }
989
+
990
+        if((opt = optget(opts, "structured-cc-count"))->active) {
991
+            if((ret = cl_engine_set_num(engine, CL_ENGINE_MIN_CC_COUNT, opt->numarg))) {
992
+                logg("!cli_engine_set_num(CL_ENGINE_MIN_CC_COUNT) failed: %s\n", cl_strerror(ret));
993
+                cl_engine_free(engine);
994
+                return 2;
995
+            }
996
+        }
997 997
     } else {
998
-	options &= ~CL_SCAN_STRUCTURED;
998
+        options &= ~CL_SCAN_STRUCTURED;
999 999
     }
1000 1000
 
1001 1001
 #ifdef C_LINUX
1002 1002
     procdev = (dev_t) 0;
1003 1003
     if(CLAMSTAT("/proc", &sb) != -1 && !sb.st_size)
1004
-	procdev = sb.st_dev;
1004
+        procdev = sb.st_dev;
1005 1005
 #endif
1006 1006
 
1007 1007
 #if HAVE_JSON
... ...
@@ -1011,60 +1089,60 @@ int scanmanager(const struct optstruct *opts)
1011 1011
 
1012 1012
     /* check filetype */
1013 1013
     if(!opts->filename && !optget(opts, "file-list")->enabled) {
1014
-	/* we need full path for some reasons (eg. archive handling) */
1015
-	if(!getcwd(cwd, sizeof(cwd))) {
1016
-	    logg("!Can't get absolute pathname of current working directory\n");
1017
-	    ret = 2;
1018
-	} else {
1019
-	    CLAMSTAT(cwd, &sb);
1020
-	    scandirs(cwd, engine, opts, options, 1, sb.st_dev);
1021
-	}
1014
+        /* we need full path for some reasons (eg. archive handling) */
1015
+        if(!getcwd(cwd, sizeof(cwd))) {
1016
+            logg("!Can't get absolute pathname of current working directory\n");
1017
+            ret = 2;
1018
+        } else {
1019
+            CLAMSTAT(cwd, &sb);
1020
+            scandirs(cwd, engine, opts, options, 1, sb.st_dev);
1021
+        }
1022 1022
 
1023 1023
     } else if(opts->filename && !optget(opts, "file-list")->enabled && !strcmp(opts->filename[0], "-")) { /* read data from stdin */
1024
-	ret = scanstdin(engine, opts, options);
1025
-
1024
+        ret = scanstdin(engine, opts, options);
1026 1025
     } else {
1027
-	if(opts->filename && optget(opts, "file-list")->enabled)
1028
-	    logg("^Only scanning files from --file-list (files passed at cmdline are ignored)\n");
1029
-
1030
-	while((filename = filelist(opts, &ret)) && (file = strdup(filename))) {
1031
-	    if(LSTAT(file, &sb) == -1) {
1032
-		perror(file);
1033
-		logg("^%s: Can't access file\n", file);
1034
-		ret = 2;
1035
-	    } else {
1036
-		for(i = strlen(file) - 1; i > 0; i--) {
1037
-		    if(file[i] == *PATHSEP)
1038
-			file[i] = 0;
1039
-		    else
1040
-			break;
1041
-		}
1042
-
1043
-		if(S_ISLNK(sb.st_mode)) {
1044
-		    if(dirlnk == 0 && filelnk == 0) {
1045
-			if(!printinfected)
1046
-			    logg("%s: Symbolic link\n", file);
1047
-		    } else if(CLAMSTAT(file, &sb) != -1) {
1048
-			if(S_ISREG(sb.st_mode) && filelnk) {
1049
-			    scanfile(file, engine, opts, options);
1050
-			} else if(S_ISDIR(sb.st_mode) && dirlnk) {
1051
-			    scandirs(file, engine, opts, options, 1, sb.st_dev);
1052
-			} else {
1053
-			    if(!printinfected)
1054
-				logg("%s: Symbolic link\n", file);
1055
-			}
1056
-		    }
1057
-		} else if(S_ISREG(sb.st_mode)) {
1058
-		    scanfile(file, engine, opts, options);
1059
-		} else if(S_ISDIR(sb.st_mode)) {
1060
-		    scandirs(file, engine, opts, options, 1, sb.st_dev);
1061
-		} else {
1062
-		    logg("^%s: Not supported file type\n", file);
1063
-		    ret = 2;
1064
-		}
1065
-	    }
1066
-	    free(file);
1067
-	}
1026
+        if(opts->filename && optget(opts, "file-list")->enabled)
1027
+            logg("^Only scanning files from --file-list (files passed at cmdline are ignored)\n");
1028
+
1029
+        while((filename = filelist(opts, &ret)) && (file = strdup(filename))) {
1030
+            if(LSTAT(file, &sb) == -1) {
1031
+                perror(file);
1032
+                logg("^%s: Can't access file\n", file);
1033
+                ret = 2;
1034
+            } else {
1035
+                for(i = strlen(file) - 1; i > 0; i--) {
1036
+                    if(file[i] == *PATHSEP)
1037
+                        file[i] = 0;
1038
+                    else
1039
+                        break;
1040
+                }
1041
+
1042
+                if(S_ISLNK(sb.st_mode)) {
1043
+                    if(dirlnk == 0 && filelnk == 0) {
1044
+                        if(!printinfected)
1045
+                            logg("%s: Symbolic link\n", file);
1046
+                    } else if(CLAMSTAT(file, &sb) != -1) {
1047
+                        if(S_ISREG(sb.st_mode) && filelnk) {
1048
+                            scanfile(file, engine, opts, options);
1049
+                        } else if(S_ISDIR(sb.st_mode) && dirlnk) {
1050
+                            scandirs(file, engine, opts, options, 1, sb.st_dev);
1051
+                        } else {
1052
+                            if(!printinfected)
1053
+                                logg("%s: Symbolic link\n", file);
1054
+                        }
1055
+                    }
1056
+                } else if(S_ISREG(sb.st_mode)) {
1057
+                    scanfile(file, engine, opts, options);
1058
+                } else if(S_ISDIR(sb.st_mode)) {
1059
+                    scandirs(file, engine, opts, options, 1, sb.st_dev);
1060
+                } else {
1061
+                    logg("^%s: Not supported file type\n", file);
1062
+                    ret = 2;
1063
+                }
1064
+            }
1065
+
1066
+            free(file);
1067
+        }
1068 1068
     }
1069 1069
 
1070 1070
     if((opt = optget(opts, "statistics"))->enabled) {
... ...
@@ -1088,9 +1166,9 @@ int scanmanager(const struct optstruct *opts)
1088 1088
 
1089 1089
     /* overwrite return code - infection takes priority */
1090 1090
     if(info.ifiles)
1091
-	ret = 1;
1091
+        ret = 1;
1092 1092
     else if(info.errors)
1093
-	ret = 2;
1093
+        ret = 2;
1094 1094
 
1095 1095
     return ret;
1096 1096
 }
... ...
@@ -318,6 +318,9 @@ JSON_LIBS = @JSON_LIBS@
318 318
 LCOV = @LCOV@
319 319
 LD = @LD@
320 320
 LDFLAGS = @LDFLAGS@
321
+LEX = @LEX@
322
+LEXLIB = @LEXLIB@
323
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
321 324
 LIBADD_DL = @LIBADD_DL@
322 325
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
323 326
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -380,6 +383,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
380 380
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
381 381
 XML_CPPFLAGS = @XML_CPPFLAGS@
382 382
 XML_LIBS = @XML_LIBS@
383
+YACC = @YACC@
384
+YFLAGS = @YFLAGS@
383 385
 abs_builddir = @abs_builddir@
384 386
 abs_srcdir = @abs_srcdir@
385 387
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -724,6 +724,11 @@ VERSIONSCRIPT_TRUE
724 724
 VERSIONSCRIPTFLAG
725 725
 GPERF
726 726
 LIBM
727
+YFLAGS
728
+YACC
729
+LEXLIB
730
+LEX_OUTPUT_ROOT
731
+LEX
727 732
 LTDLOPEN
728 733
 LT_CONFIG_H
729 734
 CONVENIENCE_LTDL_FALSE
... ...
@@ -916,6 +921,7 @@ enable_clamdtop
916 916
 with_libncurses_prefix
917 917
 with_libpdcurses_prefix
918 918
 enable_distcheck_werror
919
+with_system_llvm
919 920
 enable_llvm
920 921
 enable_sha_collector_for_internal_use
921 922
 with_libcurl
... ...
@@ -928,7 +934,9 @@ CFLAGS
928 928
 LDFLAGS
929 929
 LIBS
930 930
 CPPFLAGS
931
-CPP'
931
+CPP
932
+YACC
933
+YFLAGS'
932 934
 ac_subdirs_all='
933 935
 libclamav/c++'
934 936
 
... ...
@@ -1629,6 +1637,9 @@ Optional Packages:
1629 1629
   --without-libncurses-prefix     don't search for libncurses in includedir and libdir
1630 1630
   --with-libpdcurses-prefix[=DIR]  search for libpdcurses in DIR/include and DIR/lib
1631 1631
   --without-libpdcurses-prefix     don't search for libpdcurses in includedir and libdir
1632
+  --with-system-llvm      Use system llvm instead of built-in, uses full path
1633
+                          to llvm-config (default= /usr/local or /usr if not
1634
+                          found in /usr/local)
1632 1635
   --with-libcurl=DIR   path to directory containing libcurl (default=
1633 1636
     /usr/local or /usr if not found in /usr/local)
1634 1637
 
... ...
@@ -1641,6 +1652,12 @@ Some influential environment variables:
1641 1641
   CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
1642 1642
               you have headers in a nonstandard directory <include dir>
1643 1643
   CPP         C preprocessor
1644
+  YACC        The `Yet Another Compiler Compiler' implementation to use.
1645
+              Defaults to the first program found out of: `bison -y', `byacc',
1646
+              `yacc'.
1647
+  YFLAGS      The list of arguments that will be passed by default to $YACC.
1648
+              This script will default YFLAGS to the empty string to avoid a
1649
+              default value of `-d' given by some make applications.
1644 1650
 
1645 1651
 Use these variables to override the choices made by `configure' or to help
1646 1652
 it to find libraries and programs with nonstandard names/locations.
... ...
@@ -14037,6 +14054,211 @@ else
14037 14037
 fi
14038 14038
 
14039 14039
 
14040
+for ac_prog in flex lex
14041
+do
14042
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
14043
+set dummy $ac_prog; ac_word=$2
14044
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
14045
+$as_echo_n "checking for $ac_word... " >&6; }
14046
+if ${ac_cv_prog_LEX+:} false; then :
14047
+  $as_echo_n "(cached) " >&6
14048
+else
14049
+  if test -n "$LEX"; then
14050
+  ac_cv_prog_LEX="$LEX" # Let the user override the test.
14051
+else
14052
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
14053
+for as_dir in $PATH
14054
+do
14055
+  IFS=$as_save_IFS
14056
+  test -z "$as_dir" && as_dir=.
14057
+    for ac_exec_ext in '' $ac_executable_extensions; do
14058
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
14059
+    ac_cv_prog_LEX="$ac_prog"
14060
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
14061
+    break 2
14062
+  fi
14063
+done
14064
+  done
14065
+IFS=$as_save_IFS
14066
+
14067
+fi
14068
+fi
14069
+LEX=$ac_cv_prog_LEX
14070
+if test -n "$LEX"; then
14071
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LEX" >&5
14072
+$as_echo "$LEX" >&6; }
14073
+else
14074
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14075
+$as_echo "no" >&6; }
14076
+fi
14077
+
14078
+
14079
+  test -n "$LEX" && break
14080
+done
14081
+test -n "$LEX" || LEX=":"
14082
+
14083
+if test "x$LEX" != "x:"; then
14084
+  cat >conftest.l <<_ACEOF
14085
+%%
14086
+a { ECHO; }
14087
+b { REJECT; }
14088
+c { yymore (); }
14089
+d { yyless (1); }
14090
+e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument.  */
14091
+    yyless ((input () != 0)); }
14092
+f { unput (yytext[0]); }
14093
+. { BEGIN INITIAL; }
14094
+%%
14095
+#ifdef YYTEXT_POINTER
14096
+extern char *yytext;
14097
+#endif
14098
+int
14099
+main (void)
14100
+{
14101
+  return ! yylex () + ! yywrap ();
14102
+}
14103
+_ACEOF
14104
+{ { ac_try="$LEX conftest.l"
14105
+case "(($ac_try" in
14106
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14107
+  *) ac_try_echo=$ac_try;;
14108
+esac
14109
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
14110
+$as_echo "$ac_try_echo"; } >&5
14111
+  (eval "$LEX conftest.l") 2>&5
14112
+  ac_status=$?
14113
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
14114
+  test $ac_status = 0; }
14115
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking lex output file root" >&5
14116
+$as_echo_n "checking lex output file root... " >&6; }
14117
+if ${ac_cv_prog_lex_root+:} false; then :
14118
+  $as_echo_n "(cached) " >&6
14119
+else
14120
+
14121
+if test -f lex.yy.c; then
14122
+  ac_cv_prog_lex_root=lex.yy
14123
+elif test -f lexyy.c; then
14124
+  ac_cv_prog_lex_root=lexyy
14125
+else
14126
+  as_fn_error $? "cannot find output from $LEX; giving up" "$LINENO" 5
14127
+fi
14128
+fi
14129
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5
14130
+$as_echo "$ac_cv_prog_lex_root" >&6; }
14131
+LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
14132
+
14133
+if test -z "${LEXLIB+set}"; then
14134
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex library" >&5
14135
+$as_echo_n "checking lex library... " >&6; }
14136
+if ${ac_cv_lib_lex+:} false; then :
14137
+  $as_echo_n "(cached) " >&6
14138
+else
14139
+
14140
+    ac_save_LIBS=$LIBS
14141
+    ac_cv_lib_lex='none needed'
14142
+    for ac_lib in '' -lfl -ll; do
14143
+      LIBS="$ac_lib $ac_save_LIBS"
14144
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14145
+/* end confdefs.h.  */
14146
+`cat $LEX_OUTPUT_ROOT.c`
14147
+_ACEOF
14148
+if ac_fn_c_try_link "$LINENO"; then :
14149
+  ac_cv_lib_lex=$ac_lib
14150
+fi
14151
+rm -f core conftest.err conftest.$ac_objext \
14152
+    conftest$ac_exeext conftest.$ac_ext
14153
+      test "$ac_cv_lib_lex" != 'none needed' && break
14154
+    done
14155
+    LIBS=$ac_save_LIBS
14156
+
14157
+fi
14158
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lex" >&5
14159
+$as_echo "$ac_cv_lib_lex" >&6; }
14160
+  test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex
14161
+fi
14162
+
14163
+
14164
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yytext is a pointer" >&5
14165
+$as_echo_n "checking whether yytext is a pointer... " >&6; }
14166
+if ${ac_cv_prog_lex_yytext_pointer+:} false; then :
14167
+  $as_echo_n "(cached) " >&6
14168
+else
14169
+  # POSIX says lex can declare yytext either as a pointer or an array; the
14170
+# default is implementation-dependent.  Figure out which it is, since
14171
+# not all implementations provide the %pointer and %array declarations.
14172
+ac_cv_prog_lex_yytext_pointer=no
14173
+ac_save_LIBS=$LIBS
14174
+LIBS="$LEXLIB $ac_save_LIBS"
14175
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14176
+/* end confdefs.h.  */
14177
+
14178
+  #define YYTEXT_POINTER 1
14179
+`cat $LEX_OUTPUT_ROOT.c`
14180
+_ACEOF
14181
+if ac_fn_c_try_link "$LINENO"; then :
14182
+  ac_cv_prog_lex_yytext_pointer=yes
14183
+fi
14184
+rm -f core conftest.err conftest.$ac_objext \
14185
+    conftest$ac_exeext conftest.$ac_ext
14186
+LIBS=$ac_save_LIBS
14187
+
14188
+fi
14189
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_yytext_pointer" >&5
14190
+$as_echo "$ac_cv_prog_lex_yytext_pointer" >&6; }
14191
+if test $ac_cv_prog_lex_yytext_pointer = yes; then
14192
+
14193
+$as_echo "#define YYTEXT_POINTER 1" >>confdefs.h
14194
+
14195
+fi
14196
+rm -f conftest.l $LEX_OUTPUT_ROOT.c
14197
+
14198
+fi
14199
+if test "$LEX" = :; then
14200
+  LEX=${am_missing_run}flex
14201
+fi
14202
+for ac_prog in 'bison -y' byacc
14203
+do
14204
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
14205
+set dummy $ac_prog; ac_word=$2
14206
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
14207
+$as_echo_n "checking for $ac_word... " >&6; }
14208
+if ${ac_cv_prog_YACC+:} false; then :
14209
+  $as_echo_n "(cached) " >&6
14210
+else
14211
+  if test -n "$YACC"; then
14212
+  ac_cv_prog_YACC="$YACC" # Let the user override the test.
14213
+else
14214
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
14215
+for as_dir in $PATH
14216
+do
14217
+  IFS=$as_save_IFS
14218
+  test -z "$as_dir" && as_dir=.
14219
+    for ac_exec_ext in '' $ac_executable_extensions; do
14220
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
14221
+    ac_cv_prog_YACC="$ac_prog"
14222
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
14223
+    break 2
14224
+  fi
14225
+done
14226
+  done
14227
+IFS=$as_save_IFS
14228
+
14229
+fi
14230
+fi
14231
+YACC=$ac_cv_prog_YACC
14232
+if test -n "$YACC"; then
14233
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5
14234
+$as_echo "$YACC" >&6; }
14235
+else
14236
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14237
+$as_echo "no" >&6; }
14238
+fi
14239
+
14240
+
14241
+  test -n "$YACC" && break
14242
+done
14243
+test -n "$YACC" || YACC="yacc"
14244
+
14040 14245
 
14041 14246
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
14042 14247
 $as_echo_n "checking whether ln -s works... " >&6; }
... ...
@@ -22473,11 +22695,36 @@ fi
22473 22473
 
22474 22474
 
22475 22475
 
22476
+
22477
+# Check whether --with-system-llvm was given.
22478
+if test "${with_system_llvm+set}" = set; then :
22479
+  withval=$with_system_llvm; case "$withval" in
22480
+  yes)
22481
+    system_llvm="default"
22482
+    ;;
22483
+  no)
22484
+    system_llvm="built-in"
22485
+    ;;
22486
+  *)
22487
+    system_llvm=$withval
22488
+ esac
22489
+
22490
+else
22491
+  system_llvm="built-in"
22492
+fi
22493
+
22494
+
22476 22495
 # Check whether --enable-llvm was given.
22477 22496
 if test "${enable_llvm+set}" = set; then :
22478 22497
   enableval=$enable_llvm; enable_llvm=$enableval
22479 22498
 else
22480
-  enable_llvm="auto"
22499
+
22500
+if test "x$system_llvm" != "xbuilt-in"; then
22501
+    enable_llvm="yes"
22502
+else
22503
+    enable_llvm="auto"
22504
+fi
22505
+
22481 22506
 fi
22482 22507
 
22483 22508
 
... ...
@@ -22493,6 +22740,8 @@ subdirs="$subdirs libclamav/c++"
22493 22493
 
22494 22494
 
22495 22495
 
22496
+else
22497
+    system_llvm="none"
22496 22498
 fi
22497 22499
 
22498 22500
 # Check whether --enable-sha-collector-for-internal-use was given.
... ...
@@ -28126,15 +28375,15 @@ if test "$subdirfailed" = "no"; then
28126 28126
 fi
28127 28127
 
28128 28128
 
28129
-   $as_echo_n "              jit         : "
28129
+   $as_echo_n "              llvm        : "
28130 28130
    if test "x$enable_llvm" = "xno"; then :
28131
-  $as_echo "$have_jit (disabled)"
28131
+  $as_echo "$have_jit, from $system_llvm (disabled)"
28132 28132
 elif test "x$enable_llvm" = "xyes"; then :
28133
-  $as_echo "$have_jit"
28133
+  $as_echo "$have_jit, from $system_llvm"
28134 28134
 elif test "x$enable_llvm" = "x"; then :
28135
-  $as_echo "$have_jit"
28135
+  $as_echo "$have_jit, from $system_llvm"
28136 28136
 else
28137
-  $as_echo "$have_jit ($enable_llvm)"
28137
+  $as_echo "$have_jit, from $system_llvm ($enable_llvm)"
28138 28138
 fi
28139 28139
 
28140 28140
 
... ...
@@ -28195,7 +28444,7 @@ fi
28195 28195
 if test "x$LIBJSON_HOME" != "x"; then
28196 28196
 
28197 28197
 
28198
-   $as_echo_n "              preclass    : "
28198
+   $as_echo_n "              libjson     : "
28199 28199
    if test "x$have_json" = "xno"; then :
28200 28200
   $as_echo "$LIBJSON_HOME (disabled)"
28201 28201
 elif test "x$have_json" = "xyes"; then :
... ...
@@ -216,7 +216,7 @@ have_jit="no"
216 216
 if test "$subdirfailed" = "no"; then
217 217
     have_jit="yes"
218 218
 fi
219
-CL_MSG_STATUS([jit         ],[$have_jit],[$enable_llvm])
219
+CL_MSG_STATUS([llvm        ],[$have_jit, from $system_llvm],[$enable_llvm])
220 220
 CL_MSG_STATUS([mempool     ],[$have_mempool],[$enable_mempool])
221 221
 
222 222
 AC_MSG_NOTICE([Summary of engine detection features])
... ...
@@ -224,7 +224,7 @@ CL_MSG_STATUS([bzip2       ],[$bzip_check],[$want_bzip2])
224 224
 CL_MSG_STATUS([zlib        ],[$ZLIB_HOME],[yes])
225 225
 CL_MSG_STATUS([unrar       ],[$want_unrar],[$want_unrar])
226 226
 if test "x$LIBJSON_HOME" != "x"; then
227
-    CL_MSG_STATUS([preclass    ],[$LIBJSON_HOME],[$have_json])
227
+    CL_MSG_STATUS([libjson     ],[$LIBJSON_HOME],[$have_json])
228 228
 fi
229 229
 if test "x$PCRE_HOME" = "x"; then
230 230
     CL_MSG_STATUS([pcre        ],[no],[$have_pcre])
... ...
@@ -266,6 +266,9 @@ JSON_LIBS = @JSON_LIBS@
266 266
 LCOV = @LCOV@
267 267
 LD = @LD@
268 268
 LDFLAGS = @LDFLAGS@
269
+LEX = @LEX@
270
+LEXLIB = @LEXLIB@
271
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
269 272
 LIBADD_DL = @LIBADD_DL@
270 273
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
271 274
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -328,6 +331,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
328 328
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
329 329
 XML_CPPFLAGS = @XML_CPPFLAGS@
330 330
 XML_LIBS = @XML_LIBS@
331
+YACC = @YACC@
332
+YFLAGS = @YFLAGS@
331 333
 abs_builddir = @abs_builddir@
332 334
 abs_srcdir = @abs_srcdir@
333 335
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -16,7 +16,7 @@
16 16
 #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 17
 #  MA 02110-1301, USA.
18 18
 
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
19
+EXTRA_DIST = html $(top_srcdir)/docs/man/*.in clamdoc.pdf clamdoc.tex phishsigs_howto.tex phishsigs_howto.pdf signatures.pdf signatures.tex clam.eps
20 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 21
 
22 22
 if ENABLE_CLAMSUBMIT
... ...
@@ -300,6 +300,9 @@ JSON_LIBS = @JSON_LIBS@
300 300
 LCOV = @LCOV@
301 301
 LD = @LD@
302 302
 LDFLAGS = @LDFLAGS@
303
+LEX = @LEX@
304
+LEXLIB = @LEXLIB@
305
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
303 306
 LIBADD_DL = @LIBADD_DL@
304 307
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
305 308
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -362,6 +365,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
362 362
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
363 363
 XML_CPPFLAGS = @XML_CPPFLAGS@
364 364
 XML_LIBS = @XML_LIBS@
365
+YACC = @YACC@
366
+YFLAGS = @YFLAGS@
365 367
 abs_builddir = @abs_builddir@
366 368
 abs_srcdir = @abs_srcdir@
367 369
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -422,7 +427,7 @@ target_vendor = @target_vendor@
422 422
 top_build_prefix = @top_build_prefix@
423 423
 top_builddir = @top_builddir@
424 424
 top_srcdir = @top_srcdir@
425
-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
425
+EXTRA_DIST = html $(top_srcdir)/docs/man/*.in clamdoc.pdf clamdoc.tex phishsigs_howto.tex phishsigs_howto.pdf signatures.pdf signatures.tex clam.eps
426 426
 man_MANS = man/clamscan.1 man/freshclam.1 man/sigtool.1 man/clamd.8 \
427 427
 	man/clamd.conf.5 man/clamdscan.1 man/clamav-milter.8 \
428 428
 	man/clamav-milter.conf.5 man/freshclam.conf.5 man/clamconf.1 \
429 429
deleted file mode 100644
430 430
Binary files a/docs/clamav-mirror-howto.pdf and /dev/null differ
431 431
deleted file mode 100644
... ...
@@ -1,438 +0,0 @@
1
-%% LyX 1.3 created this file.  For more info, see http://www.lyx.org/.
2
-%% Do not edit unless you really know what you are doing.
3
-\documentclass[english]{article}
4
-\usepackage{times}
5
-\usepackage[T1]{fontenc}
6
-\usepackage[latin1]{inputenc}
7
-\setcounter{secnumdepth}{4}
8
-\setcounter{tocdepth}{4}
9
-\usepackage{setspace}
10
-\onehalfspacing
11
-
12
-\makeatletter
13
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
14
-\usepackage[official]{eurosym}
15
-\usepackage{listings}
16
-\usepackage{color}
17
-\lstset{ 
18
- commentstyle=\color{blue}, 
19
- keywordstyle=\color{red}, 
20
- frame=single, 
21
- breaklines, 
22
- showstringspaces=false,
23
- tabsize=2, 
24
- numbers=left, 
25
- numberstyle=\tiny, 
26
- stepnumber=5, 
27
- numbersep=5pt,
28
- basicstyle=\normalfont\footnotesize\tt,
29
- language={[]Perl} 
30
- } 
31
-
32
-\usepackage{babel}
33
-\makeatother
34
-\begin{document}
35
-
36
-\title{Mirroring the Virus Database}
37
-
38
-
39
-\author{Luca Gibelli}
40
-
41
-\maketitle
42
-Some guidelines for people interested in contributing to the distribution
43
-of ClamAV virus database.
44
-
45
-
46
-\section{Introduction}
47
-
48
-
49
-\subsection{This doc}
50
-
51
-The latest version of this document is always available at http://www.clamav.net/doc/mirrors/.
52
-Before going any further, please check that you are reading the latest
53
-version.
54
-
55
-Japanese sysadmins can find a translated version of this doc at http://www.orange.co.jp/\textasciitilde{}masaki/clamav/mirror-howto-jp.html
56
-(not necessarily up to date).
57
-
58
-
59
-\subsection{Who is responsible for the virus database}
60
-
61
-The virusdb team take care of reviewing virus signatures, checking
62
-for new viruses in the wild and committing changes to the virus database
63
-file.
64
-
65
-The updates are released quite often (usually no less than three times
66
-a week). If you want to be notified whenever the virus database is
67
-updated subscribe to clamav-virusdb \emph{at} lists.clamav.net . 
68
-
69
-Every time the virusdb team updates the database, the ChangeLog will
70
-be posted to the mailing-list. 
71
-
72
-Visit for the list description and archives. 
73
-
74
-If you need to contact the virusdb team please write to: virus-team
75
-\emph{at} clamav.net
76
-
77
-
78
-\subsection{Virus submission}
79
-
80
-Whenever you find a new virus which is not detected by ClamAV you
81
-should send it to the virusdb team by filling the form at http://www.clamav.net/sendvirus.html.
82
-They will review your submission and update the database so that the
83
-whole ClamAV user community can take benefit from it.
84
-
85
-\textbf{Never} send virus samples to ClamAV mailing-lists or developers
86
-addresses.
87
-
88
-
89
-\subsection{Getting a copy of the latest virus database}
90
-
91
-The most important factor for an antivirus's efficiency is to be up
92
-to date. ClamAV comes with a tool to update the virus database automatically:
93
-its name is \emph{freshclam}.
94
-
95
-freshclam looks up the TXT record associated with \textit{current.cvd.clamav.net}
96
-and extracts the latest database version available from the string
97
-returned. If the local database is outdated, freshclam tries to connect
98
-to the hostnames listed in freshclam.conf (DatabaseMirror directive).
99
-If the first server in the list fails or the latest database is not
100
-available on that mirror (e.g. in case there has been a problem sync'ing
101
-the mirror), freshclam will sleep for 10 secs and then try again with
102
-the next one, and so on. 
103
-
104
-After freshclam downloads the new database, it sends a notify to clamd
105
-(if active) to reload the database.
106
-
107
-It is important for the machine running ClamAV to be able to make
108
-DNS lookups and to connect to port 80 of external hosts on Internet
109
-either directly or through a proxy. There are known problems with
110
-some transparent proxies caching what they shouldn't cache. If you
111
-should run into this kind of problem, please check your proxy configuration
112
-before reporting a bug.
113
-
114
-
115
-\section{Mirroring the database}
116
-
117
-
118
-\subsection{The need for mirrors}
119
-
120
-To prevent the spread of worms it is essential to check for updates
121
-frequently. ClamAV users often configure freshclam with a check interval
122
-of 30 minutes. 
123
-
124
-With an exponentially growing number of ClamAV users, the servers
125
-hosting the virus database files get easily overloaded. 
126
-
127
-Without mirrors, the traffic on our main site was 100GB/month (May
128
-2003). 
129
-
130
-On Feb 2004 the traffic on each mirror (11 in total) reached 120GB/month.
131
-\\
132
-Thanks to some improvements in freshclam and the increasing number
133
-of mirrors (currently 60), the traffic on each mirror was lowered
134
-to 40GB/month (Aug 2004). That makes about 2.5TByte/month of global
135
-traffic.
136
-
137
-Our users are encouraged to add the following directives to their
138
-freshclam.conf :
139
-
140
-DatabaseMirror db.XY.clamav.net
141
-
142
-DatabaseMirror db.local.clamav.net
143
-
144
-where XY stands for the country the server lives in %
145
-\footnote{a full list is available at http://www.iana.org/cctld/cctld-whois.htm%
146
-}
147
-
148
-Each db.XY.clamav.net record points to the mirrors available in that
149
-country%
150
-\footnote{For a complete list of the mirrors available in each country visit
151
-http://www.clamav.net/mirrors.html%
152
-} or, in case there are none, the continent.
153
-
154
-If freshclam can't connect to db.XY.clamav.net, it will fail back
155
-on db.local.clamav.net, which \textbf{attempts} to redirect the user
156
-to the closest pool of mirrors by looking up its ip source address
157
-in GeoIP database (http://www.maxmind.com/app/geoip\_country).%
158
-\footnote{See:
159
-
160
-http://www.iana.org/assignments/ipv4-address-space
161
-
162
-http://ip-to-country.webhosting.info/
163
-
164
-http://ftp.apnic.net/stats/apnic/
165
-
166
-http://www.ripe.net/db/erx/erx-ip/
167
-
168
-Some of the information were contributed by Walter Hop (from transip.nl).%
169
-} We are aware that looking up the ip source address is not an accurate
170
-method to find the user location from a network topology point of
171
-view. We accept the risk.
172
-
173
-
174
-\subsection{Requirements to become a mirror}
175
-
176
-We need fast reliable mirrors. Servers eligible for becoming mirrors
177
-have to provide:
178
-
179
-\begin{itemize}
180
-\item At least a 10Mbit/s link to the Internet%
181
-\footnote{Traffic is bursty, that's why we request such a large pipe%
182
-}
183
-\item Unlimited traffic
184
-\item At least 50MB of web space
185
-\item Support for our \emph{push-mirroring} system
186
-\item The mirror has to be available to all ClamAV users. We DO NOT support
187
-private mirrors.
188
-\item ssh 2 (read on)
189
-\end{itemize}
190
-We also appreciate (but do not require) having shell access to the
191
-server hosting the mirror. FTP access is no longer accepted. \\
192
-The virusdb team will use the account \emph{only} to update the virus
193
-database.
194
-
195
-
196
-\subsection{How to become a mirror}
197
-
198
-Before setting up a mirror contact \emph{luca -at- clamav.net}! 
199
-
200
-You have to follow these steps:
201
-
202
-\begin{enumerate}
203
-\item Set up a virtual host for \\
204
-http://database.clamav.net, http://db.{*}.clamav.net and http://clamav.your-domain.tld\\
205
-Note there is an asterisk in the second hostname. A literal asterisk.\\
206
-Do not replace it with your country code. \\
207
-If you are using name based virtual hosts%
208
-\footnote{You can check whether the mirror setup is correct or not, simply by
209
-adding a line like this:
210
-
211
-your-server-ip database.clamav.net
212
-
213
-to the /etc/hosts on your client machine. Then visit http://database.clamav.net
214
-and see if you can download files from your mirror's directory.%
215
-} see \\
216
-http://httpd.apache.org/docs/mod/core.html\#serveralias for more information.
217
-\\
218
-Here is an example for a typical setup:\\
219
-\\
220
-\emph{<VirtualHost 10.1.2.3> }\\
221
-\emph{ServerAdmin john@clamav.foo.com }\\
222
-\emph{DocumentRoot /home/users/clamavdb/public\_html }\\
223
-\emph{ServerName database.clamav.net}\\
224
-\emph{ServerAlias db.{*}.clamav.net}\\
225
-\emph{ServerAlias clamav.foo.com}\\
226
-\emph{</VirtualHost>}\\
227
-If you are not using Apache and you cannot create wildcard vhosts,
228
-you must use IP based virtual hosts!\\
229
-Please note that an http redirect (e.g. RedirectPermanent) is not
230
-enough! freshclam can't handle redirects yet. \emph{}\\
231
-If you are running Apache 2.x, please use the following directive
232
-for proper logging:\\
233
-\emph{LogFormat \char`\"{}\%h \%l \%u \%t \textbackslash{}\char`\"{}\%r\textbackslash{}\char`\"{}
234
-\%>s \%O \textbackslash{}\char`\"{}\%\{Referer\}i\textbackslash{}\char`\"{}
235
-\textbackslash{}\char`\"{}\%\{User-Agent\}i\textbackslash{}\char`\"{}\char`\"{}
236
-combinedrealsize }\\
237
-\emph{CustomLog /path/to/clamav-access.log combinedrealsize }\\
238
-See the {}``Statistics'' paragraph for more info.
239
-\item Create an account with login {}``clamavdb'' and give it write access
240
-to the virtual host's DocumentRoot. \\
241
-You may want to disable password authentication for this account and
242
-change the password to something obscure.\\
243
-The {}``clamavdb'' user's shell must be /bin/sh or /bin/bash . Otherwise
244
-the user won't be able to run the command associated with the ssh
245
-public key%
246
-\footnote{Take a look at the content of \emph{{}``authorized\_keys\_noshell''}:
247
-the only command which can be executed by the owner of the corresponding
248
-ssh private key is \textasciitilde{}/bin/clam-clientsync. We will
249
-only be able to trigger the execution of that script and nothing else!
250
-
251
-However, shell access is really appreciated. If you are willingly
252
-to give us shell access, use \emph{authorized\_key}s\emph{\_shell}
253
-instead which contains Luca Gibelli and Tomasz Papszun ssh public
254
-keys too.%
255
-}.
256
-\item Download the following files:\\
257
-clam-clientsync.conf\\
258
-clam-clientsync\\
259
-authorized\_keys\_shell\\
260
-authorized\_keys\_noshell\\
261
-authorized\_keys\_shell.sig\\
262
-authorized\_keys\_noshell.sig\\
263
-from http://www.clamav.net/doc/mirrors/
264
-\item Verify the signature using:\\
265
-\$ gpg --verify authorized\_keys\_noshell.sig authorized\_keys\_noshell\\
266
-\$ gpg --verify authorized\_keys\_shell.sig authorized\_keys\_shell\\
267
-My PGP public key is available on most keyservers and on ClamAV web
268
-site. It can eventually be verified by telephone. Contact me by email
269
-first.
270
-\item If you don't want to give us shell access, copy \emph{authorized\_keys\_noshell}
271
-to \emph{\textasciitilde{}clamavdb/.ssh/authorized\_keys}:\\
272
-\$ cp authorized\_keys\_noshell \textasciitilde{}/.ssh/authorized\_keys\\
273
-If you want to give us shell access, use \emph{authorized\_keys\_shell}
274
-instead:\\
275
-\$ cp authorized\_keys\_shell \textasciitilde{}clamavdb/.ssh/authorized\_keys\\
276
-\$ chmod go-w \textasciitilde{}clamavdb\\
277
-\$ chmod 700 \textasciitilde{}clamavdb/.ssh\\
278
-\$ chmod 600 \textasciitilde{}clamavdb/.ssh/authorized\_keys
279
-\item Copy clam-clientsync to \textasciitilde{}clamavdb/bin/\\
280
-Copy clam-clientsync.conf to \textasciitilde{}clamavdb/etc/\\
281
-chmod 600 \textasciitilde{}clamavdb/etc/clam-clientsync.conf\\
282
-chmod 755 \textasciitilde{}clamavdb/bin/clam-clientsync\\
283
-Everything must be owned by user clamavdb.\\
284
-The clam-clientsync requires the {}``lockfile'' program, which is
285
-part of the \emph{procmail} package. Before going any further, please
286
-check that {}``lockfile'' is available. 
287
-\item Send the server's details (ip address, country, virtual host aliases,
288
-available bandwidth and sysadmin's full name and email address) to
289
-\emph{luca} \emph{at} \emph{clamav.net} .
290
-\item Edit \textasciitilde{}clamavdb/etc/clam-clientsync.conf . If your
291
-DocumentRoot (see paragraph 1) is \emph{/home/users/clamavdb/public\_html}
292
-, your login is \emph{foo} and your password \emph{guessme}, then
293
-your clam-clientsync.conf will look like this: \\
294
-TO=/home/users/clamavdb/public\_html\\
295
-RSYNC\_USER=foo\\
296
-RSYNC\_PASSWORD=guessme\\
297
-EXCLUDE=\char`\"{}--exclude local\_{*}\char`\"{} 
298
-\item Reconfigure your packet filter to allow incoming connections on port
299
-22/tcp and outgoing connections to ports 873/tcp and 873/udp.\\
300
-You can furtherly restrict access to these ports by only allowing
301
-connections from/to the following IP addresses: \\
302
-194.109.142.194, 64.18.103.6, 194.242.226.43 .\\
303
-rsync.clamav.net is a round robin record which points to our master
304
-mirror servers. Any changes to this record will be announced on the
305
-clamav-mirrors mailing-list.
306
-\item You are welcome to put your company logo on the mirror home page.
307
-Just copy it to the DocumentRoot and rename it to {}``local\_logo.png''.
308
-The index.html is unique for every mirror. Please note that any file
309
-in the DocumentRoot whose name doesn't match {}``local\_{*}'' will
310
-be deleted at every mirror sync.
311
-\item Subscribe to clamav-mirrors \emph{at} lists.clamav.net: see \\
312
-http://lists.clamav.net/mailman/listinfo/clamav-mirrors for more info.
313
-\\
314
-Subscribe requests have to be approved. We will approve your subscription
315
-request only \emph{after} reviewing your server's info.
316
-\end{enumerate}
317
-When everything is done, your server's IP address will be added either
318
-to your country's dns record (db.XY.clamav.net) or one of the round
319
-robin record (db.<continent>.clamav.net) and your company will be
320
-listed on our mirrors list page.
321
-
322
-
323
-\subsection{Statistics}
324
-
325
-Although it's not required, we really appreciate if you can make access
326
-statistics of your mirror available to us. They should be available
327
-at http://your-mirror-host-name/local\_stats/ and they \textbf{must}
328
-be protected with login and password. You should use the same login
329
-and password you are using in your \textasciitilde{}clamavdb/etc/clam-clientsync.conf
330
-file.
331
-
332
-If possible, please tell your statistics generator to ignore requests
333
-made by the {}``ClamAV-MirrorCheck'' agent. 
334
-
335
-If you are using Webalizer, you can add the following directive to
336
-your conf. file:
337
-
338
-HideAgent ClamAV-MirrorCheck
339
-
340
-If you are using AWStats, you can add this one instead:
341
-
342
-SkipUserAgents=\char`\"{}ClamAV-MirrorCheck''
343
-
344
-Refer to your stats generator's manual for more info.
345
-
346
-\textbf{Important note} for Apache2 users: 
347
-
348
-As stated in the Apache documentation from http://httpd.apache.org/docs/2.0/mod/mod\_log\_config.html:
349
-
350
-\textit{Note that in httpd 2.0, unlike 1.3, the \%b and \%B format
351
-strings do not represent the number of bytes sent to the client, but
352
-simply the size in bytes of the HTTP response (which will differ,
353
-for instance, if the connection is aborted, or if SSL is used). The
354
-\%O format provided by mod\_logio will log the actual number of bytes
355
-sent over the network.}
356
-
357
-
358
-\subsection{Admin's duty}
359
-
360
-\begin{itemize}
361
-\item Scheduled downtimes should be announced on the clamav-mirrors mailing-list
362
-in advance.
363
-\item IP address changes should be notified in advance too. 
364
-\item Changes in the ssh host public key of the mirror host should be announced
365
-on the clamav-mirrors mailing-list.
366
-\item It is essential to be able to contact the sysadmin responsible for
367
-the mirror server and get a quick response. Whenever a problem with
368
-a mirror occurs we need to immediately find out its cause and act
369
-consequently.
370
-\end{itemize}
371
-
372
-\section{Notes for sigmakers}
373
-
374
-New sigmakers should send their ssh2 public key to \emph{luca at clamav.net}
375
-. Their public key will be added to rsyncX.clamav.net authorized\_keys
376
-(after being verified).
377
-
378
-Sigmakers can upload a new database to either rsync1.clamav.net or
379
-rsync2.clamav.net using a (scp|sftp|rsync)-only account. 
380
-
381
-The new database won't be available to other people immediately. First,
382
-sigmakers have to notify the rsyncX.clamav.net server that a new database
383
-is available. 
384
-
385
-Here is the step-by-step procedure to release a new database version
386
-and propagate it around the world:
387
-
388
-\begin{enumerate}
389
-\item Assume your ssh private key is \textasciitilde{}/.ssh/id\_rsa and
390
-you've just built a new daily.cvd. Assume you want to use rsync1.clamav.net
391
-\item In order to upload the new database, you have to run:\\
392
-\$ rsync -tcz --stats --progress -e 'ssh -i \textasciitilde{}/.ssh/id\_rsa'
393
-daily.cvd clamupload@rsync1.clamav.net:public\_html/
394
-\item Next, you need to notify rsync1.clamav.net that a new database is
395
-available:\\
396
-\$ ssh rsync1.clamav.net -i \textasciitilde{}/.ssh/id\_rsa -l clamavdb
397
-sleep 1
398
-\item rsync1.clamav.net will verify the digital signature of the newly uploaded
399
-database using \emph{sigtool -i}. If it finds an error, it will refuse
400
-to distribute the database to other mirrors.
401
-\item rsync1.clamav.net will copy the previously uploaded database to its
402
-rsync shared directory.
403
-\item rsync1.clamav.net will notify every mirror that a new database is
404
-available
405
-\item Every mirror will rsync its copy of the database from \emph{rsync1.clamav.net::clamavdb}
406
-(only mirrors can access the rsync server at rsync1.clamav.net, it's
407
-password protected)
408
-\end{enumerate}
409
-As a fallback, every three hours, either rsync1.clamav.net or rsync2.clamav.net
410
-force an update on every mirror. 
411
-
412
-If rsync1 can't reach rsync2 or viceversa, the automatic update doesn't
413
-take place. This is done to avoid propagating an old database.
414
-
415
-To avoid conflicts, sigmakers should use rsync1 by default and if
416
-it fails, switch to rsync2. Whenever a sigmaker uses rsync2, he should
417
-announce it on the clamav-team mailing-list so that every other sigmaker
418
-uses rsync2 too, until the issues with rsync1 are over. 
419
-
420
-
421
-\section{Mirror status}
422
-
423
-Every mirror is continously monitored to ensure that every ClamAV
424
-user gets the latest virus database.
425
-
426
-Every three hours we upload a file called \emph{timestamp} on every
427
-mirror. Every hour we choose a random mirror and check that \emph{timestamp}
428
-is fresh. If the file is one day old or unavailable, the mirror if
429
-marked as {}``old'' and the ClamAV team receive a warning. If the
430
-situation persists for two days, the mirror is temporarily removed
431
-from the list. 
432
-
433
-You can view the current status of every ClamAV database mirror at
434
-http://www.clamav.net/mirrors.html . 
435
-
436
-Please note that this page doesn't reflect how \emph{often} the database
437
-is propagated to mirrors. It just shows the trend of mirrors availability.
438
-\end{document}
439 1
Binary files a/docs/clamdoc.pdf and b/docs/clamdoc.pdf differ
... ...
@@ -204,7 +204,7 @@
204 204
     \item \textbf{clamav-virusdb*lists.clamav.net} - database update announcements, moderated
205 205
     \end{itemize}
206 206
     \noindent You can subscribe and search the mailing list archives at: 
207
-    \url{http://www.clamav.net/support/ml/}\\
207
+    \url{http://www.clamav.net/contact.html#ml}\\
208 208
     Alternatively you can try asking on the \verb+#clamav+ IRC channel - launch
209 209
     your favourite irc client and type:
210 210
     \begin{verbatim}
... ...
@@ -216,7 +216,7 @@
216 216
     If you have got a virus which is not detected by your ClamAV with the latest
217 217
     databases, please submit the sample at our website:
218 218
     \begin{center}
219
-	\url{http://www.clamav.net/sendvirus}
219
+	\url{http://www.clamav.net/malware-sample}
220 220
     \end{center}
221 221
 
222 222
     \section{Base package}
... ...
@@ -238,7 +238,7 @@
238 238
 
239 239
     \subsection{Binary packages}
240 240
     You can find the up-to-date list of binary packages at our website:
241
-    \url{http://www.clamav.net/download/packages/}
241
+    \url{http://www.clamav.net/download.html#otherversions}
242 242
 
243 243
     \section{Installation}
244 244
 
... ...
@@ -272,6 +272,9 @@
272 272
 	    \footnote{Note that several versions of GCC have bugs when compiling LLVM, see
273 273
 		\url{http://llvm.org/docs/GettingStarted.html#brokengcc} for a
274 274
 		    full list.}
275
+	\item OSX Xcode versions prior to 5.0 use a g++ compiler frontend (llvm-gcc) that is not 
276
+	    compatible with ClamAV JIT. It is recommended to either compile ClamAV JIT with 
277
+	    clang++ or to compile ClamAV without JIT.
275 278
 	\item A supported CPU for the JIT, either of: X86, X86-64, PowerPC, PowerPC64
276 279
     \end{itemize}
277 280
     The following packages are optional, but needed for the JIT unit tests:
... ...
@@ -386,7 +389,7 @@ All 4 tests passed
386 386
 
387 387
     \subsection{Reporting a unit test failure bug}
388 388
 	If \verb+make check+ says that some tests failed we encourage you to report a bug on our bugzilla: \url{http://bugs.clamav.net}.
389
-	The information we need is (see also \url{http://clamav.net/bugs}):
389
+	The information we need is (see also \url{http://www.clamav.net/documentation.html#ins-bugs}):
390 390
 	\begin{itemize}
391 391
 	 \item The exact output from \verb+make check+	 
392 392
 	 \item Output of \verb+uname -mrsp+ 
... ...
@@ -238,7 +238,7 @@ original version by:  Nikos Drakos, CBLU, University of Leeds
238 238
 <!--End of Table of Child-Links-->
239 239
 <BR><HR>
240 240
 <ADDRESS>
241
-Cisco 2014-05-21
241
+Sourcefire 2013-04-16
242 242
 </ADDRESS>
243 243
 </BODY>
244 244
 </HTML>
245 245
new file mode 100644
246 246
Binary files /dev/null and b/docs/html/crossref.png differ
247 247
Binary files a/docs/html/img2.png and b/docs/html/img2.png differ
248 248
Binary files a/docs/html/img3.png and b/docs/html/img3.png differ
249 249
Binary files a/docs/html/img4.png and b/docs/html/img4.png differ
250 250
new file mode 100644
251 251
Binary files /dev/null and b/docs/html/img5.png differ
252 252
new file mode 100644
253 253
Binary files /dev/null and b/docs/html/img6.png differ
... ...
@@ -238,7 +238,7 @@ original version by:  Nikos Drakos, CBLU, University of Leeds
238 238
 <!--End of Table of Child-Links-->
239 239
 <BR><HR>
240 240
 <ADDRESS>
241
-Cisco 2014-05-21
241
+Sourcefire 2013-04-16
242 242
 </ADDRESS>
243 243
 </BODY>
244 244
 </HTML>
... ...
@@ -171,7 +171,7 @@ Contents</A>
171 171
  SRC="img3.png"
172 172
  ALT="\begin{boxedminipage}[b]{\textwidth}
173 173
 ClamAV User Manual,
174
-\copyright \ 2014 Cis...
174
+\copyright  2014 Cis...
175 175
 ... Franklin Street, Fifth Floor, Boston,
176 176
 MA 02110-1301, USA.
177 177
 \end{boxedminipage}">
... ...
@@ -195,7 +195,7 @@ ClamAV and Clam AntiVirus are trademarks of Cisco Systems, Inc.
195 195
 <P>
196 196
 <BR><HR>
197 197
 <ADDRESS>
198
-Cisco 2014-05-21
198
+Sourcefire 2013-04-16
199 199
 </ADDRESS>
200 200
 </BODY>
201 201
 </HTML>
... ...
@@ -56,11 +56,11 @@ Binary packages</A>
56 56
 </H2>
57 57
     You can find the up-to-date list of binary packages at our website:
58 58
     <TT><A NAME="tex2html5"
59
-  HREF="http://www.clamav.net/download/packages/">http://www.clamav.net/download/packages/</A></TT>
59
+  HREF="http://www.clamav.net/download.html#otherversions">http://www.clamav.net/download.html#otherversions</A></TT>
60 60
 <P>
61 61
 <BR><HR>
62 62
 <ADDRESS>
63
-Cisco 2014-05-21
63
+Sourcefire 2013-04-16
64 64
 </ADDRESS>
65 65
 </BODY>
66 66
 </HTML>
... ...
@@ -82,7 +82,7 @@ Installation</A>
82 82
 <!--End of Table of Child-Links-->
83 83
 <BR><HR>
84 84
 <ADDRESS>
85
-Cisco 2014-05-21
85
+Sourcefire 2013-04-16
86 86
 </ADDRESS>
87 87
 </BODY>
88 88
 </HTML>
... ...
@@ -98,6 +98,10 @@ the package for these compilers are usually called: gcc, g++, or gcc-c++.
98 98
 	    <A NAME="tex2html9"
99 99
   HREF="footnode.html#foot821"><SUP><SPAN CLASS="arabic">6</SPAN></SUP></A>
100 100
 </LI>
101
+<LI>OSX Xcode versions prior to 5.0 use a g++ compiler frontend (llvm-gcc) that is not 
102
+	    compatible with ClamAV JIT. It is recommended to either compile ClamAV JIT with 
103
+	    clang++ or to compile ClamAV without JIT.
104
+</LI>
101 105
 <LI>A supported CPU for the JIT, either of: X86, X86-64, PowerPC, PowerPC64
102 106
     
103 107
 </LI>
... ...
@@ -139,7 +143,7 @@ the package for these compilers are usually called: gcc, g++, or gcc-c++.
139 139
   HREF="node1.html">Contents</A></B> </DIV>
140 140
 <!--End of Navigation Panel-->
141 141
 <ADDRESS>
142
-Cisco 2014-05-21
142
+Sourcefire 2013-04-16
143 143
 </ADDRESS>
144 144
 </BODY>
145 145
 </HTML>
... ...
@@ -74,7 +74,7 @@ Installing on shell account</A>
74 74
 <P>
75 75
 <BR><HR>
76 76
 <ADDRESS>
77
-Cisco 2014-05-21
77
+Sourcefire 2013-04-16
78 78
 </ADDRESS>
79 79
 </BODY>
80 80
 </HTML>
... ...
@@ -68,7 +68,7 @@ Adding new system user and group</A>
68 68
 <P>
69 69
 <BR><HR>
70 70
 <ADDRESS>
71
-Cisco 2014-05-21
71
+Sourcefire 2013-04-16
72 72
 </ADDRESS>
73 73
 </BODY>
74 74
 </HTML>
... ...
@@ -74,7 +74,7 @@ Compilation of base package</A>
74 74
 <P>
75 75
 <BR><HR>
76 76
 <ADDRESS>
77
-Cisco 2014-05-21
77
+Sourcefire 2013-04-16
78 78
 </ADDRESS>
79 79
 </BODY>
80 80
 </HTML>
... ...
@@ -65,7 +65,7 @@ Compilation with clamav-milter enabled</A>
65 65
 <P>
66 66
 <BR><HR>
67 67
 <ADDRESS>
68
-Cisco 2014-05-21
68
+Sourcefire 2013-04-16
69 69
 </ADDRESS>
70 70
 </BODY>
71 71
 </HTML>
... ...
@@ -141,7 +141,7 @@ All 4 tests passed
141 141
   HREF="node1.html">Contents</A></B> </DIV>
142 142
 <!--End of Navigation Panel-->
143 143
 <ADDRESS>
144
-Cisco 2014-05-21
144
+Sourcefire 2013-04-16
145 145
 </ADDRESS>
146 146
 </BODY>
147 147
 </HTML>
... ...
@@ -58,7 +58,7 @@ Reporting a unit test failure bug</A>
58 58
 	If <code>make check</code> says that some tests failed we encourage you to report a bug on our bugzilla: <TT><A NAME="tex2html14"
59 59
   HREF="http://bugs.clamav.net">http://bugs.clamav.net</A></TT>.
60 60
 	The information we need is (see also <TT><A NAME="tex2html15"
61
-  HREF="http://clamav.net/bugs">http://clamav.net/bugs</A></TT>):
61
+  HREF="http://www.clamav.net/documentation.html#ins-bugs">http://www.clamav.net/documentation.html#ins-bugs</A></TT>):
62 62
 	
63 63
 <UL>
64 64
 <LI>The exact output from <code>make check</code>	 
... ...
@@ -96,7 +96,7 @@ $ CK_FORK=no ./libtool --mode=execute valgrind unit_tests/check-clamav
96 96
 <P>
97 97
 <BR><HR>
98 98
 <ADDRESS>
99
-Cisco 2014-05-21
99
+Sourcefire 2013-04-16
100 100
 </ADDRESS>
101 101
 </BODY>
102 102
 </HTML>
... ...
@@ -86,7 +86,7 @@ Here is a listing of currently available ClamAV Virus Database Files:
86 86
 <P>
87 87
 <BR><HR>
88 88
 <ADDRESS>
89
-Cisco 2014-05-21
89
+Sourcefire 2013-04-16
90 90
 </ADDRESS>
91 91
 </BODY>
92 92
 </HTML>
... ...
@@ -78,7 +78,7 @@ Introduction</A>
78 78
 <!--End of Table of Child-Links-->
79 79
 <BR><HR>
80 80
 <ADDRESS>
81
-Cisco 2014-05-21
81
+Sourcefire 2013-04-16
82 82
 </ADDRESS>
83 83
 </BODY>
84 84
 </HTML>
... ...
@@ -90,7 +90,7 @@ Configuration</A>
90 90
 <!--End of Table of Child-Links-->
91 91
 <BR><HR>
92 92
 <ADDRESS>
93
-Cisco 2014-05-21
93
+Sourcefire 2013-04-16
94 94
 </ADDRESS>
95 95
 </BODY>
96 96
 </HTML>
... ...
@@ -78,7 +78,7 @@ clamd</A>
78 78
 <!--End of Table of Child-Links-->
79 79
 <BR><HR>
80 80
 <ADDRESS>
81
-Cisco 2014-05-21
81
+Sourcefire 2013-04-16
82 82
 </ADDRESS>
83 83
 </BODY>
84 84
 </HTML>
... ...
@@ -67,7 +67,7 @@ Configure on-access scanning in <code>clamd.conf</code> and read the
67 67
 <P>
68 68
 <BR><HR>
69 69
 <ADDRESS>
70
-Cisco 2014-05-21
70
+Sourcefire 2013-04-16
71 71
 </ADDRESS>
72 72
 </BODY>
73 73
 </HTML>
... ...
@@ -91,7 +91,7 @@ Please consult your MTA's manual on how to connect ClamAV with the milter.
91 91
 <P>
92 92
 <BR><HR>
93 93
 <ADDRESS>
94
-Cisco 2014-05-21
94
+Sourcefire 2013-04-16
95 95
 </ADDRESS>
96 96
 </BODY>
97 97
 </HTML>
... ...
@@ -74,7 +74,7 @@ Testing</A>
74 74
 <P>
75 75
 <BR><HR>
76 76
 <ADDRESS>
77
-Cisco 2014-05-21
77
+Sourcefire 2013-04-16
78 78
 </ADDRESS>
79 79
 </BODY>
80 80
 </HTML>
... ...
@@ -140,7 +140,7 @@ N * * * *	/usr/local/bin/freshclam --quiet
140 140
   HREF="node1.html">Contents</A></B> </DIV>
141 141
 <!--End of Navigation Panel-->
142 142
 <ADDRESS>
143
-Cisco 2014-05-21
143
+Sourcefire 2013-04-16
144 144
 </ADDRESS>
145 145
 </BODY>
146 146
 </HTML>
... ...
@@ -76,7 +76,7 @@ Closest mirrors</A>
76 76
 <P>
77 77
 <BR><HR>
78 78
 <ADDRESS>
79
-Cisco 2014-05-21
79
+Sourcefire 2013-04-16
80 80
 </ADDRESS>
81 81
 </BODY>
82 82
 </HTML>
... ...
@@ -109,7 +109,7 @@ The only private data that is transferred is an IP address, which is used
109 109
   HREF="node1.html">Contents</A></B> </DIV>
110 110
 <!--End of Navigation Panel-->
111 111
 <ADDRESS>
112
-Cisco 2014-05-21
112
+Sourcefire 2013-04-16
113 113
 </ADDRESS>
114 114
 </BODY>
115 115
 </HTML>
... ...
@@ -89,7 +89,7 @@ Usage</A>
89 89
 <!--End of Table of Child-Links-->
90 90
 <BR><HR>
91 91
 <ADDRESS>
92
-Cisco 2014-05-21
92
+Sourcefire 2013-04-16
93 93
 </ADDRESS>
94 94
 </BODY>
95 95
 </HTML>
... ...
@@ -235,7 +235,7 @@ Scan stream: clamd will return a new port number you should
235 235
   HREF="node1.html">Contents</A></B> </DIV>
236 236
 <!--End of Navigation Panel-->
237 237
 <ADDRESS>
238
-Cisco 2014-05-21
238
+Sourcefire 2013-04-16
239 239
 </ADDRESS>
240 240
 </BODY>
241 241
 </HTML>
... ...
@@ -216,7 +216,7 @@ Features</A>
216 216
   HREF="node1.html">Contents</A></B> </DIV>
217 217
 <!--End of Navigation Panel-->
218 218
 <ADDRESS>
219
-Cisco 2014-05-21
219
+Sourcefire 2013-04-16
220 220
 </ADDRESS>
221 221
 </BODY>
222 222
 </HTML>
... ...
@@ -75,7 +75,7 @@ Clam<SPAN  CLASS="textbf">d</SPAN>scan</A>
75 75
 <P>
76 76
 <BR><HR>
77 77
 <ADDRESS>
78
-Cisco 2014-05-21
78
+Sourcefire 2013-04-16
79 79
 </ADDRESS>
80 80
 </BODY>
81 81
 </HTML>
... ...
@@ -90,7 +90,7 @@ SIGTERM signal. In other case you can lose access
90 90
 <P>
91 91
 <BR><HR>
92 92
 <ADDRESS>
93
-Cisco 2014-05-21
93
+Sourcefire 2013-04-16
94 94
 </ADDRESS>
95 95
 </BODY>
96 96
 </HTML>
... ...
@@ -69,7 +69,7 @@ For more detailed help, type 'man clamdtop' or 'clamdtop -help'.
69 69
 <P>
70 70
 <BR><HR>
71 71
 <ADDRESS>
72
-Cisco 2014-05-21
72
+Sourcefire 2013-04-16
73 73
 </ADDRESS>
74 74
 </BODY>
75 75
 </HTML>
... ...
@@ -71,7 +71,7 @@ For more detailed help, type 'man clamscan' or 'clamscan -help'.
71 71
 <P>
72 72
 <BR><HR>
73 73
 <ADDRESS>
74
-Cisco 2014-05-21
74
+Sourcefire 2013-04-16
75 75
 </ADDRESS>
76 76
 </BODY>
77 77
 </HTML>
... ...
@@ -62,7 +62,7 @@ ClamBC</A>
62 62
 <P>
63 63
 <BR><HR>
64 64
 <ADDRESS>
65
-Cisco 2014-05-21
65
+Sourcefire 2013-04-16
66 66
 </ADDRESS>
67 67
 </BODY>
68 68
 </HTML>
... ...
@@ -85,7 +85,7 @@ Database updated (2831219 signatures) from database.clamav.net (IP: 64.6.100.177
85 85
 <P>
86 86
 <BR><HR>
87 87
 <ADDRESS>
88
-Cisco 2014-05-21
88
+Sourcefire 2013-04-16
89 89
 </ADDRESS>
90 90
 </BODY>
91 91
 </HTML>
... ...
@@ -115,7 +115,7 @@ Engine flevel: 77, dconf: 77
115 115
 <P>
116 116
 <BR><HR>
117 117
 <ADDRESS>
118
-Cisco 2014-05-21
118
+Sourcefire 2013-04-16
119 119
 </ADDRESS>
120 120
 </BODY>
121 121
 </HTML>
... ...
@@ -69,7 +69,7 @@ Output format</A>
69 69
 <!--End of Table of Child-Links-->
70 70
 <BR><HR>
71 71
 <ADDRESS>
72
-Cisco 2014-05-21
72
+Sourcefire 2013-04-16
73 73
 </ADDRESS>
74 74
 </BODY>
75 75
 </HTML>
... ...
@@ -80,7 +80,7 @@ clamscan</A>
80 80
 <P>
81 81
 <BR><HR>
82 82
 <ADDRESS>
83
-Cisco 2014-05-21
83
+Sourcefire 2013-04-16
84 84
 </ADDRESS>
85 85
 </BODY>
86 86
 </HTML>
... ...
@@ -82,7 +82,7 @@ Error messages are printed in the following format:
82 82
 <P>
83 83
 <BR><HR>
84 84
 <ADDRESS>
85
-Cisco 2014-05-21
85
+Sourcefire 2013-04-16
86 86
 </ADDRESS>
87 87
 </BODY>
88 88
 </HTML>
... ...
@@ -73,7 +73,7 @@ Mailing lists and IRC channel</A>
73 73
 </UL>
74 74
     You can subscribe and search the mailing list archives at: 
75 75
     <TT><A NAME="tex2html2"
76
-  HREF="http://www.clamav.net/support/ml/">http://www.clamav.net/support/ml/</A></TT>
76
+  HREF="http://www.clamav.net/contact.html#ml">http://www.clamav.net/contact.html#ml</A></TT>
77 77
 <BR>
78 78
 Alternatively you can try asking on the <code>#clamav</code> IRC channel - launch
79 79
     your favourite irc client and type:
... ...
@@ -85,7 +85,7 @@ Alternatively you can try asking on the <code>#clamav</code> IRC channel - launc
85 85
 <P>
86 86
 <BR><HR>
87 87
 <ADDRESS>
88
-Cisco 2014-05-21
88
+Sourcefire 2013-04-16
89 89
 </ADDRESS>
90 90
 </BODY>
91 91
 </HTML>
... ...
@@ -128,7 +128,7 @@ LibClamAV</A>
128 128
 <!--End of Table of Child-Links-->
129 129
 <BR><HR>
130 130
 <ADDRESS>
131
-Cisco 2014-05-21
131
+Sourcefire 2013-04-16
132 132
 </ADDRESS>
133 133
 </BODY>
134 134
 </HTML>
... ...
@@ -62,7 +62,7 @@ Licence</A>
62 62
 <P>
63 63
 <BR><HR>
64 64
 <ADDRESS>
65
-Cisco 2014-05-21
65
+Sourcefire 2013-04-16
66 66
 </ADDRESS>
67 67
 </BODY>
68 68
 </HTML>
... ...
@@ -78,7 +78,7 @@ Supported formats and features</A>
78 78
 <!--End of Table of Child-Links-->
79 79
 <BR><HR>
80 80
 <ADDRESS>
81
-Cisco 2014-05-21
81
+Sourcefire 2013-04-16
82 82
 </ADDRESS>
83 83
 </BODY>
84 84
 </HTML>
... ...
@@ -86,7 +86,7 @@ Executables</A>
86 86
 <P>
87 87
 <BR><HR>
88 88
 <ADDRESS>
89
-Cisco 2014-05-21
89
+Sourcefire 2013-04-16
90 90
 </ADDRESS>
91 91
 </BODY>
92 92
 </HTML>
... ...
@@ -61,7 +61,7 @@ Mail files</A>
61 61
 <P>
62 62
 <BR><HR>
63 63
 <ADDRESS>
64
-Cisco 2014-05-21
64
+Sourcefire 2013-04-16
65 65
 </ADDRESS>
66 66
 </BODY>
67 67
 </HTML>
... ...
@@ -119,7 +119,7 @@ Archives and compressed files</A>
119 119
 <P>
120 120
 <BR><HR>
121 121
 <ADDRESS>
122
-Cisco 2014-05-21
122
+Sourcefire 2013-04-16
123 123
 </ADDRESS>
124 124
 </BODY>
125 125
 </HTML>
... ...
@@ -75,7 +75,7 @@ Documents</A>
75 75
 <P>
76 76
 <BR><HR>
77 77
 <ADDRESS>
78
-Cisco 2014-05-21
78
+Sourcefire 2013-04-16
79 79
 </ADDRESS>
80 80
 </BODY>
81 81
 </HTML>
... ...
@@ -69,7 +69,7 @@ Future versions of Libclamav may include additional features to
69 69
 <P>
70 70
 <BR><HR>
71 71
 <ADDRESS>
72
-Cisco 2014-05-21
72
+Sourcefire 2013-04-16
73 73
 </ADDRESS>
74 74
 </BODY>
75 75
 </HTML>
... ...
@@ -74,7 +74,7 @@ Others</A>
74 74
 <P>
75 75
 <BR><HR>
76 76
 <ADDRESS>
77
-Cisco 2014-05-21
77
+Sourcefire 2013-04-16
78 78
 </ADDRESS>
79 79
 </BODY>
80 80
 </HTML>
... ...
@@ -90,7 +90,7 @@ API</A>
90 90
 <!--End of Table of Child-Links-->
91 91
 <BR><HR>
92 92
 <ADDRESS>
93
-Cisco 2014-05-21
93
+Sourcefire 2013-04-16
94 94
 </ADDRESS>
95 95
 </BODY>
96 96
 </HTML>
... ...
@@ -58,13 +58,13 @@ Virus submitting</A>
58 58
     databases, please submit the sample at our website:
59 59
     <DIV ALIGN="CENTER">
60 60
 <TT><A NAME="tex2html3"
61
-  HREF="http://www.clamav.net/sendvirus">http://www.clamav.net/sendvirus</A></TT>
61
+  HREF="http://www.clamav.net/malware-sample">http://www.clamav.net/malware-sample</A></TT>
62 62
 </DIV>
63 63
 
64 64
 <P>
65 65
 <BR><HR>
66 66
 <ADDRESS>
67
-Cisco 2014-05-21
67
+Sourcefire 2013-04-16
68 68
 </ADDRESS>
69 69
 </BODY>
70 70
 </HTML>
... ...
@@ -63,7 +63,7 @@ Header file</A>
63 63
 <P>
64 64
 <BR><HR>
65 65
 <ADDRESS>
66
-Cisco 2014-05-21
66
+Sourcefire 2013-04-16
67 67
 </ADDRESS>
68 68
 </BODY>
69 69
 </HTML>
... ...
@@ -72,7 +72,7 @@ Initialization</A>
72 72
 <P>
73 73
 <BR><HR>
74 74
 <ADDRESS>
75
-Cisco 2014-05-21
75
+Sourcefire 2013-04-16
76 76
 </ADDRESS>
77 77
 </BODY>
78 78
 </HTML>
... ...
@@ -124,7 +124,7 @@ Load bytecode.
124 124
 <P>
125 125
 <BR><HR>
126 126
 <ADDRESS>
127
-Cisco 2014-05-21
127
+Sourcefire 2013-04-16
128 128
 </ADDRESS>
129 129
 </BODY>
130 130
 </HTML>
... ...
@@ -68,7 +68,7 @@ Error handling</A>
68 68
 <P>
69 69
 <BR><HR>
70 70
 <ADDRESS>
71
-Cisco 2014-05-21
71
+Sourcefire 2013-04-16
72 72
 </ADDRESS>
73 73
 </BODY>
74 74
 </HTML>
... ...
@@ -74,7 +74,7 @@ Engine structure</A>
74 74
 <P>
75 75
 <BR><HR>
76 76
 <ADDRESS>
77
-Cisco 2014-05-21
77
+Sourcefire 2013-04-16
78 78
 </ADDRESS>
79 79
 </BODY>
80 80
 </HTML>
... ...
@@ -78,7 +78,7 @@ const char *cl_engine_get_str(const struct cl_engine *engine,
78 78
 <P>
79 79
 <BR><HR>
80 80
 <ADDRESS>
81
-Cisco 2014-05-21
81
+Sourcefire 2013-04-16
82 82
 </ADDRESS>
83 83
 </BODY>
84 84
 </HTML>
... ...
@@ -102,7 +102,7 @@ Database checks</A>
102 102
 <P>
103 103
 <BR><HR>
104 104
 <ADDRESS>
105
-Cisco 2014-05-21
105
+Sourcefire 2013-04-16
106 106
 </ADDRESS>
107 107
 </BODY>
108 108
 </HTML>
... ...
@@ -221,7 +221,7 @@ OLE2 containers, which contain VBA macros will be marked infected
221 221
   HREF="node1.html">Contents</A></B> </DIV>
222 222
 <!--End of Navigation Panel-->
223 223
 <ADDRESS>
224
-Cisco 2014-05-21
224
+Sourcefire 2013-04-16
225 225
 </ADDRESS>
226 226
 </BODY>
227 227
 </HTML>
... ...
@@ -62,7 +62,7 @@ Memory</A>
62 62
 <P>
63 63
 <BR><HR>
64 64
 <ADDRESS>
65
-Cisco 2014-05-21
65
+Sourcefire 2013-04-16
66 66
 </ADDRESS>
67 67
 </BODY>
68 68
 </HTML>
... ...
@@ -64,7 +64,7 @@ Forking daemons</A>
64 64
 <P>
65 65
 <BR><HR>
66 66
 <ADDRESS>
67
-Cisco 2014-05-21
67
+Sourcefire 2013-04-16
68 68
 </ADDRESS>
69 69
 </BODY>
70 70
 </HTML>
... ...
@@ -77,7 +77,7 @@ Base package</A>
77 77
 <!--End of Table of Child-Links-->
78 78
 <BR><HR>
79 79
 <ADDRESS>
80
-Cisco 2014-05-21
80
+Sourcefire 2013-04-16
81 81
 </ADDRESS>
82 82
 </BODY>
83 83
 </HTML>
... ...
@@ -66,7 +66,7 @@ clamav-config</A>
66 66
 <P>
67 67
 <BR><HR>
68 68
 <ADDRESS>
69
-Cisco 2014-05-21
69
+Sourcefire 2013-04-16
70 70
 </ADDRESS>
71 71
 </BODY>
72 72
 </HTML>
... ...
@@ -64,7 +64,7 @@ Example</A>
64 64
 <P>
65 65
 <BR><HR>
66 66
 <ADDRESS>
67
-Cisco 2014-05-21
67
+Sourcefire 2013-04-16
68 68
 </ADDRESS>
69 69
 </BODY>
70 70
 </HTML>
... ...
@@ -81,7 +81,7 @@ Verification OK.
81 81
 <P>
82 82
 <BR><HR>
83 83
 <ADDRESS>
84
-Cisco 2014-05-21
84
+Sourcefire 2013-04-16
85 85
 </ADDRESS>
86 86
 </BODY>
87 87
 </HTML>
... ...
@@ -612,7 +612,7 @@ Contributors</A>
612 612
   HREF="node1.html">Contents</A></B> </DIV>
613 613
 <!--End of Navigation Panel-->
614 614
 <ADDRESS>
615
-Cisco 2014-05-21
615
+Sourcefire 2013-04-16
616 616
 </ADDRESS>
617 617
 </BODY>
618 618
 </HTML>
... ...
@@ -458,7 +458,7 @@ Donors</A>
458 458
   HREF="node1.html">Contents</A></B> </DIV>
459 459
 <!--End of Navigation Panel-->
460 460
 <ADDRESS>
461
-Cisco 2014-05-21
461
+Sourcefire 2013-04-16
462 462
 </ADDRESS>
463 463
 </BODY>
464 464
 </HTML>
... ...
@@ -62,7 +62,7 @@ Graphics</A>
62 62
 <P>
63 63
 <BR><HR>
64 64
 <ADDRESS>
65
-Cisco 2014-05-21
65
+Sourcefire 2013-04-16
66 66
 </ADDRESS>
67 67
 </BODY>
68 68
 </HTML>
... ...
@@ -61,7 +61,7 @@ OpenAntiVirus</A>
61 61
 <P>
62 62
 <BR><HR>
63 63
 <ADDRESS>
64
-Cisco 2014-05-21
64
+Sourcefire 2013-04-16
65 65
 </ADDRESS>
66 66
 </BODY>
67 67
 </HTML>
... ...
@@ -136,7 +136,7 @@ Role: manager, virus databases
136 136
 <P>
137 137
 <BR><HR>
138 138
 <ADDRESS>
139
-Cisco 2014-05-21
139
+Sourcefire 2013-04-16
140 140
 </ADDRESS>
141 141
 </BODY>
142 142
 </HTML>
... ...
@@ -127,7 +127,7 @@ Role: coder
127 127
 </UL>
128 128
 <BR><HR>
129 129
 <ADDRESS>
130
-Cisco 2014-05-21
130
+Sourcefire 2013-04-16
131 131
 </ADDRESS>
132 132
 </BODY>
133 133
 </HTML>
... ...
@@ -68,7 +68,7 @@ Supported platforms</A>
68 68
 <!--End of Table of Child-Links-->
69 69
 <BR><HR>
70 70
 <ADDRESS>
71
-Cisco 2014-05-21
71
+Sourcefire 2013-04-16
72 72
 </ADDRESS>
73 73
 </BODY>
74 74
 </HTML>
... ...
@@ -76,7 +76,7 @@ UNIX</A>
76 76
 <P>
77 77
 <BR><HR>
78 78
 <ADDRESS>
79
-Cisco 2014-05-21
79
+Sourcefire 2013-04-16
80 80
 </ADDRESS>
81 81
 </BODY>
82 82
 </HTML>
... ...
@@ -59,7 +59,7 @@ Windows</A>
59 59
 <P>
60 60
 <BR><HR>
61 61
 <ADDRESS>
62
-Cisco 2014-05-21
62
+Sourcefire 2013-04-16
63 63
 </ADDRESS>
64 64
 </BODY>
65 65
 </HTML>
... ...
@@ -1,6 +1,6 @@
1
-.TH CLAMBC "1" "April 2010" "ClamAV @VERSION@" "Clam AntiVirus"
1
+.TH CLAMBC "1" "September 2014" "ClamAV @VERSION@" "Clam AntiVirus"
2 2
 .SH NAME
3
-clambc \- Bytecode Testing Tool
3
+clambc \- Bytecode Analysis and Testing Tool
4 4
 .SH SYNOPSIS
5 5
 .PP
6 6
 clambc <file> [function] [param1 ...]
... ...
@@ -12,23 +12,44 @@ Show help
12 12
 \fB\-\-version\fR              \fB\-V\fR
13 13
 Show version
14 14
 .TP
15
+\fB\-\-debug\fR
16
+Show debug
17
+.TP
18
+\fB\-\-force\-interpreter\fR   \fB\-f\fR
19
+Force using the interpreter instead of the JIT
20
+.TP
21
+\fB\-\-trust\-bytecode\fR      \fB\-t\fR
22
+Trust loaded bytecode (default yes)
23
+.TP
15 24
 \fB\-\-info\fR                 \fB\-i\fR
16 25
 Print information about bytecode
17 26
 .TP
18 27
 \fB\-\-printsrc\fR             \fB\-p\fR
19 28
 Print bytecode source
20 29
 .TP
21
-\fB\-\-trace\fR <level>
30
+\fB\-\-printbcir\fR            \fB\-c\fR
31
+Print IR of bytecode signature
32
+.TP
33
+\fB\-\-input\fR                \fB\-r\fR
34
+Input file to run the bytecode on
35
+.TP
36
+\fB\-\-trace\fR <level>        \fB\-T\fR
22 37
 Set bytecode trace level 0..7 (default 7)
23 38
 .TP
24 39
 \fB\-\-no\-trace\-showsource\fR
25 40
 Don't show source line during tracing
26 41
 .TP
42
+\fB\-\-bytecode\-statistics\fR
43
+Collect and print bytecode execution statistics
44
+.TP
27 45
 file
28 46
 file to test
29 47
 .SH "CREDITS"
30 48
 Please check the full documentation for credits.
31 49
 .PP
32
-Clam AntiVirus Bytecode Testing Tool 0.96
33
-By The ClamAV Team: http://www.clamav.net/team
34
-(C) 2009 Sourcefire, Inc.
50
+Clam AntiVirus Bytecode Analysis and Testing Tool 0.98
51
+By The ClamAV Team: http://www.clamav.net/about.html#credits
52
+.LP
53
+(C) 2009-2013 Sourcefire, Inc.
54
+.LP
55
+(C) 2014 Cisco Systems, Inc. All Rights Reserved
... ...
@@ -54,7 +54,7 @@ Scan a file descriptor. After issuing a FILDES command a subsequent rfc2292/bsd4
54 54
 Alternatively the file descriptor may be sent in the same packet, including the extra character.
55 55
 .TP
56 56
 \fBSTATS\fR
57
-IIt is mandatory to newline terminate this command, or prefix with \fBn\fR or \fBz\fR, it is recommended to only use the \fBz\fR prefix.
57
+It is mandatory to newline terminate this command, or prefix with \fBn\fR or \fBz\fR, it is recommended to only use the \fBz\fR prefix.
58 58
 
59 59
 Replies with statistics about the scan queue, contents of scan queue, and memory
60 60
 usage. The exact reply format is subject to change in future releases.
... ...
@@ -334,12 +334,12 @@ Detect Possibly Unwanted Applications.
334 334
 Default: No
335 335
 .TP
336 336
 \fBExcludePUA CATEGORY\fR
337
-Exclude a specific PUA category. This directive can be used multiple times. See http://www.clamav.net/support/pua for the complete list of PUA categories.
337
+Exclude a specific PUA category. This directive can be used multiple times. See http://www.clamav.net/documentation.html#pua for the complete list of PUA categories.
338 338
 .br
339 339
 Default: disabled
340 340
 .TP
341 341
 \fBIncludePUA CATEGORY\fR
342
-Only include a specific PUA category. This directive can be used multiple times. See http://www.clamav.net/support/pua for the complete list of PUA categories.
342
+Only include a specific PUA category. This directive can be used multiple times. See http://www.clamav.net/documentation.html#pua for the complete list of PUA categories.
343 343
 .br
344 344
 Default: disabled
345 345
 .TP 
... ...
@@ -21,6 +21,7 @@ Display help information and exit.
21 21
 .TP 
22 22
 \fB\-V, \-\-version\fR
23 23
 Print version number and exit.
24
+.TP
24 25
 \fB\-\-config\-file=FILE\fR
25 26
 Read clamd settings from FILE, to determine how to connect to it.
26 27
 .TP 
... ...
@@ -109,10 +109,10 @@ Collect and print bytecode statistics.
109 109
 Detect Possibly Unwanted Applications.
110 110
 .TP 
111 111
 \fB\-\-exclude\-pua=CATEGORY\fR
112
-Exclude a specific PUA category. This option can be used multiple times. See http://www.clamav.net/support/pua for the complete list of PUA
112
+Exclude a specific PUA category. This option can be used multiple times. See http://www.clamav.net/documentation.html#pua for the complete list of PUA
113 113
 .TP 
114 114
 \fB\-\-include\-pua=CATEGORY\fR
115
-Only include a specific PUA category. This option can be used multiple times. See http://www.clamav.net/support/pua for the complete list of PUA
115
+Only include a specific PUA category. This option can be used multiple times. See http://www.clamav.net/documentation.html#pua for the complete list of PUA
116 116
 .TP 
117 117
 \fB\-\-detect\-structured[=yes/no(*)]\fR
118 118
 Use the DLP (Data Loss Prevention) module to detect SSN and Credit Card numbers inside documents/text files.
... ...
@@ -19,13 +19,13 @@ Display help to stderr and exit.
19 19
 Required option for setting the email address for the submission.
20 20
 .TP 
21 21
 \fB\-n FILE\fR
22
-Submit a file that reports as a false negative (ClamAV reports CLEAN). FILE can be - to specify stdin. Mutually exclusive with -p.
22
+Submit a file that reports as a false negative (ClamAV reports CLEAN). FILE can be \- to specify stdin. Mutually exclusive with \-p.
23 23
 .TP 
24 24
 \fB\-N NAME\fR
25 25
 Required option for setting the name of the sender for the submission.
26 26
 .TP
27 27
 \fB-p FILE\fR
28
-Submit a file that reports as a false positive (ClamAV flags the file as virus). FILE can be - to specify stdin. Mutually exclusive with -n.
28
+Submit a file that reports as a false positive (ClamAV flags the file as virus). FILE can be \- to specify stdin. Mutually exclusive with \-n.
29 29
 .SH "CREDITS"
30 30
 The idea of this tool is based on Postfix's postconf. clamconf was created under pressure from Tomasz Papszun ;-)
31 31
 .SH "AUTHOR"
... ...
@@ -65,10 +65,10 @@ Specify a custom flevel. Default: 77
65 65
 .TP 
66 66
 \fB\-\-cvd\-version\fR
67 67
 Specify the version number to use for the build. Default is to use the value+1
68
-from the current CVD in --datadir. If no datafile is found the default
68
+from the current CVD in \-\-datadir. If no datafile is found the default
69 69
 behaviour is to prompt for a version number, this switch will prevent the
70 70
 prompt.
71
-NOTE: If a CVD is found in the --datadir its version+1 is used and this value is ignored.
71
+NOTE: If a CVD is found in the \-\-datadir its version+1 is used and this value is ignored.
72 72
 .TP 
73 73
 \fB\-\-no\-cdiff\fR
74 74
 Don't create a .cdiff file when building a new database file.
75 75
Binary files a/docs/signatures.pdf and b/docs/signatures.pdf differ
... ...
@@ -332,7 +332,7 @@ How do I look in hex?
332 332
         (ClamAV$\ge$0.98.2)
333 333
 	\item \verb+HEXSIG[x-y]aa+ or \verb+aa[x-y]HEXSIG+\\
334 334
 	Match aa anchored to a hex-signature, see
335
-	\url{https://wwws.clamav.net/bugzilla/show_bug.cgi?id=776} for
335
+	\url{https://bugzilla.clamav.net/show_bug.cgi?id=776} for
336 336
 	discussion and examples.
337 337
 	\item \verb+(B)+\\
338 338
 	Match word boundary (including file boundaries).
... ...
@@ -296,6 +296,9 @@ JSON_LIBS = @JSON_LIBS@
296 296
 LCOV = @LCOV@
297 297
 LD = @LD@
298 298
 LDFLAGS = @LDFLAGS@
299
+LEX = @LEX@
300
+LEXLIB = @LEXLIB@
301
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
299 302
 LIBADD_DL = @LIBADD_DL@
300 303
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
301 304
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -358,6 +361,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
358 358
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
359 359
 XML_CPPFLAGS = @XML_CPPFLAGS@
360 360
 XML_LIBS = @XML_LIBS@
361
+YACC = @YACC@
362
+YFLAGS = @YFLAGS@
361 363
 abs_builddir = @abs_builddir@
362 364
 abs_srcdir = @abs_srcdir@
363 365
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -201,7 +201,7 @@ DatabaseMirror database.clamav.net
201 201
 # the statistics of this clamd installation by logging into
202 202
 # http://www.stats.clamav.net with the same credentials you used to
203 203
 # generate the HostID. For more information refer to:
204
-# http://www.clamav.net/support/faq/faq-cctts/
204
+# http://www.clamav.net/documentation.html#cctts 
205 205
 # This feature requires SubmitDetectionStats to be enabled.
206 206
 # Default: disabled
207 207
 #DetectionStatsHostID unique-id
... ...
@@ -216,7 +216,7 @@ DatabaseMirror database.clamav.net
216 216
 # Freshclam uses the ClamAV's mirror infrastructure to distribute the
217 217
 # database and its updates but all the contents are provided under Google's
218 218
 # terms of use. See http://www.google.com/transparencyreport/safebrowsing
219
-# and https://github.com/vrtadmin/clamav-faq/blob/master/faq/faq-safebrowsing.md
219
+# and http://www.clamav.net/documentation.html#safebrowsing 
220 220
 # for more information.
221 221
 # Default: disabled
222 222
 #SafeBrowsing yes
... ...
@@ -227,8 +227,7 @@ DatabaseMirror database.clamav.net
227 227
 #Bytecode yes
228 228
 
229 229
 # Download an additional 3rd party signature database distributed through
230
-# the ClamAV mirrors. Here you can find a list of available databases:
231
-# http://www.clamav.net/download/cvd/3rdparty
230
+# the ClamAV mirrors. 
232 231
 # This option can be used multiple times.
233 232
 #ExtraDatabase dbname1
234 233
 #ExtraDatabase dbname2
... ...
@@ -322,6 +322,9 @@ JSON_LIBS = @JSON_LIBS@
322 322
 LCOV = @LCOV@
323 323
 LD = @LD@
324 324
 LDFLAGS = @LDFLAGS@
325
+LEX = @LEX@
326
+LEXLIB = @LEXLIB@
327
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
325 328
 LIBADD_DL = @LIBADD_DL@
326 329
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
327 330
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -384,6 +387,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
384 384
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
385 385
 XML_CPPFLAGS = @XML_CPPFLAGS@
386 386
 XML_LIBS = @XML_LIBS@
387
+YACC = @YACC@
388
+YFLAGS = @YFLAGS@
387 389
 abs_builddir = @abs_builddir@
388 390
 abs_srcdir = @abs_srcdir@
389 391
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -149,7 +149,7 @@ help (void)
149 149
     mprintf ("\n");
150 150
     mprintf ("                   Clam AntiVirus: freshclam  %s\n",
151 151
              get_version ());
152
-    printf ("           By The ClamAV Team: http://www.clamav.net/team\n");
152
+    printf ("           By The ClamAV Team: http://www.clamav.net/about.html#credits\n");
153 153
     printf ("           (C) 2007-2009 Sourcefire, Inc. et al.\n\n");
154 154
 
155 155
     mprintf ("    --help               -h              show help\n");
... ...
@@ -244,7 +244,7 @@ download (const struct optstruct *opts, const char *cfgfile)
244 244
                     opt = (struct optstruct *) opt->nextarg;
245 245
                     if (!opt)
246 246
                     {
247
-                        logg ("Update failed. Your network may be down or none of the mirrors listed in %s is working. Check http://www.clamav.net/support/mirror-problem for possible reasons.\n", cfgfile);
247
+                        logg ("Update failed. Your network may be down or none of the mirrors listed in %s is working. Check http://www.clamav.net/documentation.html for possible reasons.\n", cfgfile);
248 248
                     }
249 249
                 }
250 250
 
... ...
@@ -2052,7 +2052,7 @@ updatedb (const char *dbname, const char *hostname, char *ip, int *signo,
2052 2052
             logg ("^Current functionality level = %d, recommended = %d\n",
2053 2053
                   flevel, current->fl);
2054 2054
             logg ("Please check if ClamAV tools are linked against the proper version of libclamav\n");
2055
-            logg ("DON'T PANIC! Read http://www.clamav.net/support/faq\n");
2055
+            logg ("DON'T PANIC! Read http://www.clamav.net/documentation.html\n");
2056 2056
         }
2057 2057
 
2058 2058
         *signo += current->sigs;
... ...
@@ -604,6 +604,9 @@ JSON_LIBS = @JSON_LIBS@
604 604
 LCOV = @LCOV@
605 605
 LD = @LD@
606 606
 LDFLAGS = @LDFLAGS@
607
+LEX = @LEX@
608
+LEXLIB = @LEXLIB@
609
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
607 610
 LIBADD_DL = @LIBADD_DL@
608 611
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
609 612
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -666,6 +669,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
666 666
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
667 667
 XML_CPPFLAGS = @XML_CPPFLAGS@
668 668
 XML_LIBS = @XML_LIBS@
669
+YACC = @YACC@
670
+YFLAGS = @YFLAGS@
669 671
 abs_builddir = @abs_builddir@
670 672
 abs_srcdir = @abs_srcdir@
671 673
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -3105,8 +3105,7 @@ extern unsigned cli_numapicalls;
3105 3105
 static void cli_bytetype_helper(const struct cli_bc *bc, unsigned tid)
3106 3106
 {
3107 3107
     unsigned i, j;
3108
-    const struct cli_bc_type *ty = &bc->types[i];
3109
-
3108
+    const struct cli_bc_type *ty;
3110 3109
 
3111 3110
     if (tid & 0x8000) {
3112 3111
         printf("alloc ");
... ...
@@ -3119,6 +3118,11 @@ static void cli_bytetype_helper(const struct cli_bc *bc, unsigned tid)
3119 3119
     }
3120 3120
 
3121 3121
     i = tid - 65;
3122
+    if (i >= bc->num_types) {
3123
+        printf("invaltype");
3124
+        return;
3125
+    }
3126
+    ty = &bc->types[i];
3122 3127
 
3123 3128
     switch (ty->kind) {
3124 3129
     case DFunctionType:
... ...
@@ -3234,7 +3238,7 @@ void cli_byteinst_describe(const struct cli_bc_inst *inst, unsigned *bbnum)
3234 3234
         return;
3235 3235
     }
3236 3236
 
3237
-    snprintf(inst_str, 256, "%-20s[%-3d/%3d/%3d]", bc_opstr[inst->opcode], 
3237
+    snprintf(inst_str, sizeof(inst_str), "%-20s[%-3d/%3d/%3d]", bc_opstr[inst->opcode], 
3238 3238
              inst->opcode, inst->interp_op, inst->interp_op%inst->opcode);
3239 3239
     printf("%-35s", inst_str);
3240 3240
     switch (inst->opcode) {
... ...
@@ -41,7 +41,7 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
41 41
 	    return CL_EBYTECODE;
42 42
 	}
43 43
     }
44
-    cli_dbgmsg("JIT not compiled in\n");
44
+    cli_dbgmsg("Cannot prepare for JIT, LLVM is not compiled or not linked\n");
45 45
     return CL_EBYTECODE;
46 46
 }
47 47
 
... ...
@@ -83,7 +83,7 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) {
83 83
     UNUSEDPARAM(ctx);
84 84
 }
85 85
 void cli_bytecode_printversion(void) {
86
-  printf("LLVM not compiled in\n");
86
+  printf("LLVM is not compiled or not linked\n");
87 87
 }
88 88
 int have_clamjit=0;
89 89
 void cli_printcxxver()
... ...
@@ -29,13 +29,20 @@
29 29
 #include "llvm/ADT/PostOrderIterator.h"
30 30
 #include "llvm/ADT/SCCIterator.h"
31 31
 #include "llvm/Analysis/CallGraph.h"
32
-#include "llvm/Analysis/Verifier.h"
33 32
 #if LLVM_VERSION < 32
34 33
 #include "llvm/Analysis/DebugInfo.h"
35
-#else
34
+#elif LLVM_VERSION < 35
36 35
 #include "llvm/DebugInfo.h"
36
+#else
37
+#include "llvm/IR/DebugInfo.h"
37 38
 #endif
39
+#if LLVM_VERSION < 35
38 40
 #include "llvm/Analysis/Dominators.h"
41
+#include "llvm/Analysis/Verifier.h"
42
+#else
43
+#include "llvm/IR/Dominators.h"
44
+#include "llvm/IR/Verifier.h"
45
+#endif
39 46
 #include "llvm/Analysis/ConstantFolding.h"
40 47
 #if LLVM_VERSION < 29
41 48
 //#include "llvm/Analysis/LiveValues.h" (unused)
... ...
@@ -50,9 +57,14 @@
50 50
 #include "llvm/Config/config.h"
51 51
 #include "llvm/Pass.h"
52 52
 #include "llvm/Support/CommandLine.h"
53
+#if LLVM_VERSION < 35
53 54
 #include "llvm/Support/DataFlow.h"
54 55
 #include "llvm/Support/InstIterator.h"
55 56
 #include "llvm/Support/GetElementPtrTypeIterator.h"
57
+#else
58
+#include "llvm/IR/InstIterator.h"
59
+#include "llvm/IR/GetElementPtrTypeIterator.h"
60
+#endif
56 61
 #include "llvm/ADT/DepthFirstIterator.h"
57 62
 #include "llvm/Transforms/Scalar.h"
58 63
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
... ...
@@ -71,7 +83,6 @@
71 71
 #include "llvm/Intrinsics.h"
72 72
 #include "llvm/LLVMContext.h"
73 73
 #include "llvm/Module.h"
74
-#include "llvm/Support/InstVisitor.h"
75 74
 #else
76 75
 #include "llvm/IR/DerivedTypes.h"
77 76
 #include "llvm/IR/Instructions.h"
... ...
@@ -79,7 +90,14 @@
79 79
 #include "llvm/IR/Intrinsics.h"
80 80
 #include "llvm/IR/LLVMContext.h"
81 81
 #include "llvm/IR/Module.h"
82
+#endif
83
+
84
+#if LLVM_VERSION < 33
85
+#include "llvm/Support/InstVisitor.h"
86
+#elif LLVM_VERSION < 35
82 87
 #include "llvm/InstVisitor.h"
88
+#else
89
+#include "llvm/IR/InstVisitor.h"
83 90
 #endif
84 91
 
85 92
 #define DEFINEPASS(passname) passname() : FunctionPass(ID)
... ...
@@ -95,7 +113,7 @@ static Value *GetUnderlyingObject(Value *P, TargetData *TD)
95 95
 
96 96
 namespace llvm {
97 97
   class PtrVerifier;
98
-#if LLVM_VERSION >= 30
98
+#if LLVM_VERSION >= 29
99 99
   void initializePtrVerifierPass(PassRegistry&);
100 100
 #endif
101 101
 
... ...
@@ -103,12 +121,20 @@ namespace llvm {
103 103
   private:
104 104
       DenseSet<Function*> badFunctions;
105 105
       std::vector<Instruction*> delInst;
106
+#if LLVM_VERSION < 35
106 107
       CallGraphNode *rootNode;
108
+#else
109
+      CallGraph *CG;
110
+#endif
107 111
   public:
108 112
       static char ID;
109
-      DEFINEPASS(PtrVerifier), rootNode(0), PT(), TD(), SE(), DT(),
110
-          AbrtBB(), Changed(false), valid(false), EP() {
111
-#if LLVM_VERSION >= 30
113
+#if LLVM_VERSION < 35
114
+      DEFINEPASS(PtrVerifier), rootNode(0), PT(), TD(), SE(), expander(),
115
+#else
116
+      DEFINEPASS(PtrVerifier), CG(0), PT(), TD(), SE(), expander(),
117
+#endif
118
+          DT(), AbrtBB(), Changed(false), valid(false), EP() {
119
+#if LLVM_VERSION >= 29
112 120
           initializePtrVerifierPass(*PassRegistry::getPassRegistry());
113 121
 #endif
114 122
       }
... ...
@@ -133,12 +159,21 @@ namespace llvm {
133 133
           AbrtBB = 0;
134 134
           valid = true;
135 135
 
136
+#if LLVM_VERSION < 35
136 137
           if (!rootNode) {
137 138
               rootNode = getAnalysis<CallGraph>().getRoot();
139
+#else
140
+          if (!CG) {
141
+              CG = &getAnalysis<CallGraphWrapperPass>().getCallGraph();
142
+#endif
138 143
               // No recursive functions for now.
139 144
               // In the future we may insert runtime checks for stack depth.
145
+#if LLVM_VERSION < 35
140 146
               for (scc_iterator<CallGraphNode*> SCCI = scc_begin(rootNode),
141 147
                        E = scc_end(rootNode); SCCI != E; ++SCCI) {
148
+#else
149
+              for (scc_iterator<CallGraph*> SCCI = scc_begin(CG); !SCCI.isAtEnd(); ++SCCI) {
150
+#endif
142 151
                   const std::vector<CallGraphNode*> &nextSCC = *SCCI;
143 152
                   if (nextSCC.size() > 1 || SCCI.hasLoop()) {
144 153
                       errs() << "INVALID: Recursion detected, callgraph SCC components: ";
... ...
@@ -164,12 +199,19 @@ namespace llvm {
164 164
           EP = &*It;
165 165
 #if LLVM_VERSION < 32
166 166
           TD = &getAnalysis<TargetData>();
167
-#else
167
+#elif LLVM_VERSION < 35
168 168
           TD = &getAnalysis<DataLayout>();
169
+#else
170
+          DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
171
+          TD = DLP ? &DLP->getDataLayout() : 0;
169 172
 #endif
170 173
           SE = &getAnalysis<ScalarEvolution>();
171 174
           PT = &getAnalysis<PointerTracking>();
175
+#if LLVM_VERSION < 35
172 176
           DT = &getAnalysis<DominatorTree>();
177
+#else
178
+          DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
179
+#endif
173 180
           expander = new SCEVExpander(*SE OPT("SCEVexpander"));
174 181
 
175 182
           std::vector<Instruction*> insns;
... ...
@@ -307,13 +349,23 @@ namespace llvm {
307 307
       virtual void getAnalysisUsage(AnalysisUsage &AU) const {
308 308
 #if LLVM_VERSION < 32
309 309
           AU.addRequired<TargetData>();
310
-#else
310
+#elif LLVM_VERSION < 35
311 311
           AU.addRequired<DataLayout>();
312
+#else
313
+          AU.addRequired<DataLayoutPass>();
312 314
 #endif
315
+#if LLVM_VERSION < 35
313 316
           AU.addRequired<DominatorTree>();
317
+#else
318
+          AU.addRequired<DominatorTreeWrapperPass>();
319
+#endif
314 320
           AU.addRequired<ScalarEvolution>();
315 321
           AU.addRequired<PointerTracking>();
322
+#if LLVM_VERSION < 35
316 323
           AU.addRequired<CallGraph>();
324
+#else
325
+          AU.addRequired<CallGraphWrapperPass>();
326
+#endif
317 327
       }
318 328
 
319 329
       bool isValid() const { return valid; }
... ...
@@ -321,8 +373,10 @@ namespace llvm {
321 321
       PointerTracking *PT;
322 322
 #if LLVM_VERSION < 32
323 323
       TargetData *TD;
324
-#else
324
+#elif LLVM_VERSION < 35
325 325
       DataLayout *TD;
326
+#else
327
+      const DataLayout *TD;
326 328
 #endif
327 329
       ScalarEvolution *SE;
328 330
       SCEVExpander *expander;
... ...
@@ -851,19 +905,27 @@ namespace llvm {
851 851
     char PtrVerifier::ID;
852 852
 
853 853
 } /* end namespace llvm */
854
-#if LLVM_VERSION >= 30
854
+#if LLVM_VERSION >= 29
855 855
 INITIALIZE_PASS_BEGIN(PtrVerifier, "", "", false, false)
856 856
 #if LLVM_VERSION < 32
857 857
 INITIALIZE_PASS_DEPENDENCY(TargetData)
858
-#else
858
+#elif LLVM_VERSION < 35
859 859
 INITIALIZE_PASS_DEPENDENCY(DataLayout)
860
+#else
861
+INITIALIZE_PASS_DEPENDENCY(DataLayoutPass)
860 862
 #endif
863
+#if LLVM_VERSION < 35
861 864
 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
865
+#else
866
+INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
867
+#endif
862 868
 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
863 869
 #if LLVM_VERSION < 34
864 870
 INITIALIZE_AG_DEPENDENCY(CallGraph)
865
-#else
871
+#elif LLVM_VERSION < 35
866 872
 INITIALIZE_PASS_DEPENDENCY(CallGraph)
873
+#else
874
+INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass)
867 875
 #endif
868 876
 INITIALIZE_PASS_DEPENDENCY(PointerTracking)
869 877
 INITIALIZE_PASS_END(PtrVerifier, "clambc-rtchecks", "ClamBC RTchecks", false, false)
... ...
@@ -34,9 +34,9 @@ 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 -DLLVM_VERSION=${LLVM_VERSION} @JSON_CPPFLAGS@
38
-libclamavcxx_la_LDFLAGS = @LLVMCONFIG_LDFLAGS@ @LLVMCONFIG_LIBS@ @LLVMCONFIG_LDFLAGS@ @JSON_LDFLAGS@
39
-libclamavcxx_la_DEPENDENCIES = @LLVMCONFIG_LIBFILES@ @JSON_LIBS@
37
+libclamavcxx_la_CXXFLAGS = $(AM_CPPFLAGS) @LLVMCONFIG_CXXFLAGS@ -fexceptions -DLLVM_VERSION=${LLVM_VERSION}
38
+libclamavcxx_la_LDFLAGS = @LLVMCONFIG_LDFLAGS@ @LLVMCONFIG_LIBS@ @LLVMCONFIG_LDFLAGS@
39
+libclamavcxx_la_DEPENDENCIES = @LLVMCONFIG_LIBFILES@
40 40
 noinst_LTLIBRARIES = libclamavcxx.la
41 41
 libclamavcxx_la_SOURCES += PointerTracking.cpp
42 42
 libclamavcxx_la_SOURCES += PointerTracking.h
... ...
@@ -48,7 +48,7 @@ noinst_LTLIBRARIES = libclamavcxx.la libllvmsystem.la\
48 48
 libclamavcxx_la_LIBADD=libllvmjit.la
49 49
 libclamavcxx_la_DEPENDENCIES=libllvmjit.la libllvmcodegen.la libllvmsystem.la
50 50
 libclamavcxx_la_LDFLAGS=-no-undefined
51
-libclamavcxx_la_CXXFLAGS = $(LLVM_CXXFLAGS) -DLLVM_VERSION=${LLVM_VERSION} @JSON_CPPFLAGS@
51
+libclamavcxx_la_CXXFLAGS = $(LLVM_CXXFLAGS) -DLLVM_VERSION=${LLVM_VERSION}
52 52
 
53 53
 
54 54
 if BUILD_X86
... ...
@@ -122,7 +122,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/check_gnu_make.m4 \
122 122
 	$(top_srcdir)/m4/cxx_flag_check.m4 $(top_srcdir)/m4/libtool.m4 \
123 123
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
124 124
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
125
-	$(top_srcdir)/../../m4/reorganization/libs/json.m4 \
126 125
 	$(top_srcdir)/configure.ac
127 126
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
128 127
 	$(ACLOCAL_M4)
... ...
@@ -955,9 +954,6 @@ INSTALL_DATA = @INSTALL_DATA@
955 955
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
956 956
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
957 957
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
958
-JSON_CPPFLAGS = @JSON_CPPFLAGS@
959
-JSON_LDFLAGS = @JSON_LDFLAGS@
960
-JSON_LIBS = @JSON_LIBS@
961 958
 LD = @LD@
962 959
 LDFLAGS = @LDFLAGS@
963 960
 LIBOBJS = @LIBOBJS@
... ...
@@ -1069,20 +1065,20 @@ 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 1071
 	$(am__append_1)
1072
-@BUILD_EXTERNAL_LLVM_FALSE@libclamavcxx_la_CXXFLAGS = $(LLVM_CXXFLAGS) -DLLVM_VERSION=${LLVM_VERSION} @JSON_CPPFLAGS@
1072
+@BUILD_EXTERNAL_LLVM_FALSE@libclamavcxx_la_CXXFLAGS = $(LLVM_CXXFLAGS) -DLLVM_VERSION=${LLVM_VERSION}
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) @LLVMCONFIG_CXXFLAGS@ -fexceptions -DLLVM_VERSION=${LLVM_VERSION} @JSON_CPPFLAGS@
1077
+@BUILD_EXTERNAL_LLVM_TRUE@libclamavcxx_la_CXXFLAGS = $(AM_CPPFLAGS) @LLVMCONFIG_CXXFLAGS@ -fexceptions -DLLVM_VERSION=${LLVM_VERSION}
1078 1078
 @BUILD_EXTERNAL_LLVM_FALSE@libclamavcxx_la_LDFLAGS = -no-undefined
1079
-@BUILD_EXTERNAL_LLVM_TRUE@libclamavcxx_la_LDFLAGS = @LLVMCONFIG_LDFLAGS@ @LLVMCONFIG_LIBS@ @LLVMCONFIG_LDFLAGS@ @JSON_LDFLAGS@
1079
+@BUILD_EXTERNAL_LLVM_TRUE@libclamavcxx_la_LDFLAGS = @LLVMCONFIG_LDFLAGS@ @LLVMCONFIG_LIBS@ @LLVMCONFIG_LDFLAGS@
1080 1080
 @BUILD_EXTERNAL_LLVM_FALSE@libclamavcxx_la_DEPENDENCIES =  \
1081 1081
 @BUILD_EXTERNAL_LLVM_FALSE@	libllvmjit.la libllvmcodegen.la \
1082 1082
 @BUILD_EXTERNAL_LLVM_FALSE@	libllvmsystem.la $(am__append_4) \
1083 1083
 @BUILD_EXTERNAL_LLVM_FALSE@	$(am__append_7)
1084 1084
 @BUILD_EXTERNAL_LLVM_TRUE@libclamavcxx_la_DEPENDENCIES =  \
1085
-@BUILD_EXTERNAL_LLVM_TRUE@	@LLVMCONFIG_LIBFILES@ @JSON_LIBS@ \
1085
+@BUILD_EXTERNAL_LLVM_TRUE@	@LLVMCONFIG_LIBFILES@ \
1086 1086
 @BUILD_EXTERNAL_LLVM_TRUE@	$(am__append_4) $(am__append_7)
1087 1087
 @BUILD_EXTERNAL_LLVM_FALSE@noinst_LTLIBRARIES = libclamavcxx.la \
1088 1088
 @BUILD_EXTERNAL_LLVM_FALSE@	libllvmsystem.la libllvmcodegen.la \
... ...
@@ -16,15 +16,19 @@
16 16
 #ifndef _WIN32
17 17
 
18 18
 #include "llvm/Analysis/ConstantFolding.h"
19
-#include "llvm/Analysis/Dominators.h"
20 19
 #include "llvm/Analysis/LoopInfo.h"
21 20
 #include "llvm/Analysis/MemoryBuiltins.h"
22 21
 #include "llvm/Analysis/ValueTracking.h"
23 22
 #include "PointerTracking.h"
24 23
 #include "llvm/Analysis/ScalarEvolution.h"
25 24
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
25
+#if LLVM_VERSION < 35
26 26
 #include "llvm/Support/CallSite.h"
27 27
 #include "llvm/Support/InstIterator.h"
28
+#else
29
+#include "llvm/IR/CallSite.h"
30
+#include "llvm/IR/InstIterator.h"
31
+#endif
28 32
 #include "llvm/Support/raw_ostream.h"
29 33
 #include "llvm/Target/TargetLibraryInfo.h"
30 34
 
... ...
@@ -55,23 +59,31 @@ static Value *GetUnderlyingObject(Value *P, TargetData *TD)
55 55
 }
56 56
 #endif
57 57
 
58
-#if LLVM_VERSION >= 30
58
+#if LLVM_VERSION >= 29
59 59
 namespace llvm {
60 60
     void initializePointerTrackingPass(llvm::PassRegistry&);
61 61
 };
62 62
 INITIALIZE_PASS_BEGIN(PointerTracking, "pointertracking",
63 63
                 "Track pointer bounds", false, true)
64
+#if LLVM_VERSION < 35
64 65
 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
66
+#else
67
+INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
68
+#endif
65 69
 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
66 70
 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
71
+#if LLVM_VERSION < 35
67 72
 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
73
+#else
74
+INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
75
+#endif
68 76
 INITIALIZE_PASS_END(PointerTracking, "pointertracking",
69 77
                 "Track pointer bounds", false, true)
70 78
 #endif
71 79
 
72 80
 char PointerTracking::ID = 0;
73 81
 PointerTracking::PointerTracking() : FunctionPass(ID) {
74
-#if LLVM_VERSION >= 30
82
+#if LLVM_VERSION >= 29
75 83
     initializePointerTrackingPass(*PassRegistry::getPassRegistry());
76 84
 #endif
77 85
 }
... ...
@@ -82,17 +94,28 @@ bool PointerTracking::runOnFunction(Function &F) {
82 82
   FF = &F;
83 83
 #if LLVM_VERSION < 32
84 84
   TD = getAnalysisIfAvailable<TargetData>();
85
-#else
85
+#elif LLVM_VERSION < 35
86 86
   TD = getAnalysisIfAvailable<DataLayout>();
87
+#else
88
+  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
89
+  TD = DLP ? &DLP->getDataLayout() : 0;
87 90
 #endif
88 91
   SE = &getAnalysis<ScalarEvolution>();
89 92
   LI = &getAnalysis<LoopInfo>();
93
+#if LLVM_VERSION < 35
90 94
   DT = &getAnalysis<DominatorTree>();
95
+#else
96
+  DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
97
+#endif
91 98
   return false;
92 99
 }
93 100
 
94 101
 void PointerTracking::getAnalysisUsage(AnalysisUsage &AU) const {
102
+#if LLVM_VERSION < 35
95 103
   AU.addRequiredTransitive<DominatorTree>();
104
+#else
105
+  AU.addRequiredTransitive<DominatorTreeWrapperPass>();
106
+#endif
96 107
   AU.addRequiredTransitive<LoopInfo>();
97 108
   AU.addRequiredTransitive<ScalarEvolution>();
98 109
   AU.setPreservesAll();
... ...
@@ -28,9 +28,15 @@
28 28
 #define LLVM_ANALYSIS_POINTERTRACKING_H
29 29
 
30 30
 #include "llvm/ADT/SmallPtrSet.h"
31
+#if LLVM_VERSION < 35
31 32
 #include "llvm/Analysis/Dominators.h"
32
-#include "llvm/Pass.h"
33 33
 #include "llvm/Support/PredIteratorCache.h"
34
+#else
35
+#include "llvm/IR/Dominators.h"
36
+#include "llvm/IR/PredIteratorCache.h"
37
+#include "llvm/IR/DataLayout.h"
38
+#endif
39
+#include "llvm/Pass.h"
34 40
 #include "llvm30_compat.h"
35 41
 
36 42
 #if LLVM_VERSION < 33
... ...
@@ -59,7 +65,7 @@ namespace llvm {
59 59
     Unknown // it can sometimes be true, sometimes false, or it is undecided
60 60
   };
61 61
 
62
-#if LLVM_VERSION >= 30
62
+#if LLVM_VERSION >= 29
63 63
   void initializePointerTrackingPass(PassRegistry&);
64 64
 #endif
65 65
 
... ...
@@ -117,8 +123,10 @@ namespace llvm {
117 117
     Function *FF;
118 118
 #if LLVM_VERSION < 32
119 119
     TargetData *TD;
120
-#else
120
+#elif LLVM_VERSION < 35
121 121
     DataLayout *TD;
122
+#else
123
+    const DataLayout *TD;
122 124
 #endif
123 125
     ScalarEvolution *SE;
124 126
     LoopInfo *LI;
... ...
@@ -44,8 +44,15 @@
44 44
 #include "llvm/ADT/SmallVector.h"
45 45
 #include "llvm/Analysis/LoopInfo.h"
46 46
 #include "llvm/Analysis/ScalarEvolution.h"
47
+#if LLVM_VERSION < 35
47 48
 #include "llvm/Analysis/Verifier.h"
48 49
 #include "llvm/AutoUpgrade.h"
50
+#include "llvm/Support/TargetFolder.h"
51
+#else
52
+#include "llvm/IR/Verifier.h"
53
+#include "llvm/IR/AutoUpgrade.h"
54
+#include "llvm/Analysis/TargetFolder.h"
55
+#endif
49 56
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
50 57
 #include "llvm/ExecutionEngine/JIT.h"
51 58
 #include "llvm/ExecutionEngine/JITEventListener.h"
... ...
@@ -100,15 +107,16 @@ void LLVMInitializePowerPCAsmPrinter();
100 100
 #endif
101 101
 
102 102
 #include "llvm/Target/TargetOptions.h"
103
-#include "llvm/Support/TargetFolder.h"
104 103
 #include "llvm/Transforms/Scalar.h"
105 104
 #include "llvm/Transforms/IPO.h"
106 105
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
107 106
 
108 107
 #if LLVM_VERSION < 32
109 108
 #include "llvm/Analysis/DebugInfo.h"
110
-#else
109
+#elif LLVM_VERSION < 35
111 110
 #include "llvm/DebugInfo.h"
111
+#else
112
+#include "llvm/IR/DebugInfo.h"
112 113
 #endif
113 114
 
114 115
 #if LLVM_VERSION < 32
... ...
@@ -144,6 +152,10 @@ void LLVMInitializePowerPCAsmPrinter();
144 144
 #include "llvm/Analysis/CFG.h"
145 145
 #endif
146 146
 
147
+#if LLVM_VERSION >= 35
148
+#include "llvm/IR/Dominators.h"
149
+#endif
150
+
147 151
 //#define TIMING
148 152
 #undef TIMING
149 153
 
... ...
@@ -657,7 +669,11 @@ public:
657 657
 	}
658 658
 	BBSetTy  needsTimeoutCheck;
659 659
 	BBMapTy BBMap;
660
+#if LLVM_VERSION < 35
660 661
 	DominatorTree &DT = getAnalysis<DominatorTree>();
662
+#else
663
+	DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
664
+#endif
661 665
 	for (Function::iterator I=F.begin(),E=F.end(); I != E; ++I) {
662 666
 	    BasicBlock *BB = &*I;
663 667
 	    unsigned apicalls = 0;
... ...
@@ -784,7 +800,11 @@ public:
784 784
       AU.setPreservesAll();
785 785
       AU.addRequired<LoopInfo>();
786 786
       AU.addRequired<ScalarEvolution>();
787
+#if LLVM_VERSION < 35
787 788
       AU.addRequired<DominatorTree>();
789
+#else
790
+      AU.addRequired<DominatorTreeWrapperPass>();
791
+#endif
788 792
     }
789 793
 };
790 794
 char RuntimeLimits::ID;
... ...
@@ -1701,9 +1721,8 @@ public:
1701 1701
 			    Value *Dst = convertOperand(func, inst, inst->u.three[0]);
1702 1702
 			    Dst = Builder.CreatePointerCast(Dst, PointerType::getUnqual(Type::getInt8Ty(Context)));
1703 1703
 			    Value *Val = convertOperand(func, Type::getInt8Ty(Context), inst->u.three[1]);
1704
-			    //Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]);
1705
-                            Value *Len = convertOperand(func, Type::getInt64Ty(Context), inst->u.three[2]);
1706
-#if LLVM_VERSION < 30
1704
+			    Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]);
1705
+#if LLVM_VERSION < 29
1707 1706
 			    CallInst *c = Builder.CreateCall4(CF->FMemset, Dst, Val, Len,
1708 1707
 								ConstantInt::get(Type::getInt32Ty(Context), 1));
1709 1708
 #else
... ...
@@ -1723,9 +1742,8 @@ public:
1723 1723
 			    Dst = Builder.CreatePointerCast(Dst, PointerType::getUnqual(Type::getInt8Ty(Context)));
1724 1724
 			    Value *Src = convertOperand(func, inst, inst->u.three[1]);
1725 1725
 			    Src = Builder.CreatePointerCast(Src, PointerType::getUnqual(Type::getInt8Ty(Context)));
1726
-			    //Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]);
1727
-                            Value *Len = convertOperand(func, Type::getInt64Ty(Context), inst->u.three[2]);
1728
-#if LLVM_VERSION < 30
1726
+			    Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]);
1727
+#if LLVM_VERSION < 29
1729 1728
 			    CallInst *c = Builder.CreateCall4(CF->FMemcpy, Dst, Src, Len,
1730 1729
 								ConstantInt::get(Type::getInt32Ty(Context), 1));
1731 1730
 #else
... ...
@@ -1745,9 +1763,8 @@ public:
1745 1745
 			    Dst = Builder.CreatePointerCast(Dst, PointerType::getUnqual(Type::getInt8Ty(Context)));
1746 1746
 			    Value *Src = convertOperand(func, inst, inst->u.three[1]);
1747 1747
 			    Src = Builder.CreatePointerCast(Src, PointerType::getUnqual(Type::getInt8Ty(Context)));
1748
-                            //Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]);
1749
-                            Value *Len = convertOperand(func, Type::getInt64Ty(Context), inst->u.three[2]);
1750
-#if LLVM_VERSION < 30
1748
+			    Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]);
1749
+#if LLVM_VERSION < 29
1751 1750
 			    CallInst *c = Builder.CreateCall4(CF->FMemmove, Dst, Src, Len,
1752 1751
 								ConstantInt::get(Type::getInt32Ty(Context), 1));
1753 1752
 #else
... ...
@@ -1856,7 +1873,11 @@ public:
1856 1856
 
1857 1857
 	    // If successful so far, run verifyFunction
1858 1858
 	    if (!broken) {
1859
+#if LLVM_VERSION < 35
1859 1860
 		if (verifyFunction(*F, PrintMessageAction)) {
1861
+#else
1862
+		if (verifyFunction(*F, &errs())) {
1863
+#endif
1860 1864
 		    // verification failed
1861 1865
 		    broken = true;
1862 1866
 		    cli_warnmsg("[Bytecode JIT]: Verification failed\n");
... ...
@@ -1945,7 +1966,11 @@ public:
1945 1945
 	ReturnInst::Create(Context, CI, BB);
1946 1946
 
1947 1947
 	delete [] Functions;
1948
+#if LLVM_VERSION < 35
1948 1949
 	if (verifyFunction(*F, PrintMessageAction))
1950
+#else
1951
+	if (verifyFunction(*F, &errs()))
1952
+#endif
1949 1953
 	    return 0;
1950 1954
 
1951 1955
 /*			DEBUG(errs() << "Generating code\n");
... ...
@@ -2003,21 +2028,18 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M
2003 2003
     std::vector<constType*> args;
2004 2004
     args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context)));
2005 2005
     args.push_back(Type::getInt8Ty(Context));
2006
-    //args.push_back(Type::getInt32Ty(Context));
2007
-    args.push_back(Type::getInt64Ty(Context));
2008 2006
     args.push_back(Type::getInt32Ty(Context));
2009
-#if LLVM_VERSION >= 30
2007
+    args.push_back(Type::getInt32Ty(Context));
2008
+#if LLVM_VERSION >= 29
2010 2009
     args.push_back(Type::getInt1Ty(Context));
2011 2010
 #endif
2012 2011
     FunctionType* FuncTy_3 = FunctionType::get(Type::getVoidTy(Context),
2013 2012
 					       args, false);
2014 2013
     CF->FMemset = Function::Create(FuncTy_3, GlobalValue::ExternalLinkage,
2015
-#if LLVM_VERSION < 30
2016
-                                   //"llvm.memset.i32",
2017
-                                   "llvm.memset.i64",
2014
+#if LLVM_VERSION < 29
2015
+                                   "llvm.memset.i32",
2018 2016
 #else
2019
-                                   //"llvm.memset.p0i8.i32",
2020
-                                   "llvm.memset.p0i8.i64",
2017
+                                   "llvm.memset.p0i8.i32",
2021 2018
 #endif
2022 2019
                                    M);
2023 2020
     CF->FMemset->setDoesNotThrow();
... ...
@@ -2030,21 +2052,18 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M
2030 2030
     args.clear();
2031 2031
     args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context)));
2032 2032
     args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context)));
2033
-    //args.push_back(Type::getInt32Ty(Context));
2034
-    args.push_back(Type::getInt64Ty(Context));
2035 2033
     args.push_back(Type::getInt32Ty(Context));
2036
-#if LLVM_VERSION >= 30
2034
+    args.push_back(Type::getInt32Ty(Context));
2035
+#if LLVM_VERSION >= 29
2037 2036
     args.push_back(Type::getInt1Ty(Context));
2038 2037
 #endif
2039 2038
     FunctionType* FuncTy_4 = FunctionType::get(Type::getVoidTy(Context),
2040 2039
 					       args, false);
2041 2040
     CF->FMemmove = Function::Create(FuncTy_4, GlobalValue::ExternalLinkage,
2042
-#if LLVM_VERSION < 30
2043
-                                    //"llvm.memmove.i32",
2044
-                                    "llvm.memcpy.i64",
2041
+#if LLVM_VERSION < 29
2042
+                                    "llvm.memmove.i32",
2045 2043
 #else
2046
-                                    //"llvm.memmove.p0i8.i32",
2047
-                                    "llvm.memmove.p0i8.i64",
2044
+                                    "llvm.memmove.p0i8.i32",
2048 2045
 #endif
2049 2046
                                     M);
2050 2047
     CF->FMemmove->setDoesNotThrow();
... ...
@@ -2055,12 +2074,10 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M
2055 2055
 #endif
2056 2056
 
2057 2057
     CF->FMemcpy = Function::Create(FuncTy_4, GlobalValue::ExternalLinkage,
2058
-#if LLVM_VERSION < 30
2059
-                                   //"llvm.memcpy.i32",
2060
-                                   "llvm.memcpy.i64",
2058
+#if LLVM_VERSION < 29
2059
+                                   "llvm.memcpy.i32",
2061 2060
 #else
2062
-                                   //"llvm.memcpy.p0i8.p0i8.i32",
2063
-                                   "llvm.memcpy.p0i8.p0i8.i64",
2061
+                                   "llvm.memcpy.p0i8.p0i8.i32",
2064 2062
 #endif
2065 2063
                                    M);
2066 2064
     CF->FMemcpy->setDoesNotThrow();
... ...
@@ -2125,7 +2142,11 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M
2125 2125
 INITIALIZE_PASS_BEGIN(RuntimeLimits, "rl", "Runtime Limits", false, false)
2126 2126
 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
2127 2127
 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
2128
+#if LLVM_VERSION < 35
2128 2129
 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
2130
+#else
2131
+INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
2132
+#endif
2129 2133
 INITIALIZE_PASS_END(RuntimeLimits, "rl" ,"Runtime Limits", false, false)
2130 2134
 #endif
2131 2135
 
... ...
@@ -2341,16 +2362,20 @@ static void setGuard(unsigned char* guardbuf)
2341 2341
 }
2342 2342
 #if LLVM_VERSION < 32
2343 2343
 static void addFPasses(FunctionPassManager &FPM, bool trusted, const TargetData *TD)
2344
-#else
2344
+#elif LLVM_VERSION < 35
2345 2345
 static void addFPasses(FunctionPassManager &FPM, bool trusted, const DataLayout *TD)
2346
+#else
2347
+static void addFPasses(FunctionPassManager &FPM, bool trusted, const Module *M)
2346 2348
 #endif
2347 2349
 {
2348 2350
     // Set up the optimizer pipeline.  Start with registering info about how
2349 2351
     // the target lays out data structures.
2350 2352
 #if LLVM_VERSION < 32
2351 2353
     FPM.add(new TargetData(*TD));
2352
-#else
2354
+#elif LLVM_VERSION < 35
2353 2355
     FPM.add(new DataLayout(*TD));
2356
+#else
2357
+    FPM.add(new DataLayoutPass(M));
2354 2358
 #endif
2355 2359
     // Promote allocas to registers.
2356 2360
     FPM.add(createPromoteMemoryToRegisterPass());
... ...
@@ -2428,9 +2453,12 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
2428 2428
 #if LLVM_VERSION < 32
2429 2429
 	addFPasses(OurFPM, true, EE->getTargetData());
2430 2430
 	addFPasses(OurFPMUnsigned, false, EE->getTargetData());
2431
-#else
2431
+#elif LLVM_VERSION < 35
2432 2432
 	addFPasses(OurFPM, true, EE->getDataLayout());
2433 2433
 	addFPasses(OurFPMUnsigned, false, EE->getDataLayout());
2434
+#else
2435
+	addFPasses(OurFPM, true, M);
2436
+	addFPasses(OurFPMUnsigned, false, M);
2434 2437
 #endif
2435 2438
 
2436 2439
 
... ...
@@ -2541,8 +2569,10 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
2541 2541
 	PassManager PM;
2542 2542
 #if LLVM_VERSION < 32
2543 2543
 	PM.add(new TargetData(*EE->getTargetData()));
2544
-#else
2544
+#elif LLVM_VERSION < 35
2545 2545
 	PM.add(new DataLayout(*EE->getDataLayout()));
2546
+#else
2547
+	PM.add(new DataLayoutPass(M));
2546 2548
 #endif
2547 2549
 	// TODO: only run this on the untrusted bytecodes, not all of them...
2548 2550
 	if (has_untrusted)
... ...
@@ -2601,10 +2631,17 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
2601 2601
 int bytecode_init(void)
2602 2602
 {
2603 2603
     // If already initialized return
2604
+#if LLVM_VERSION < 35
2604 2605
     if (llvm_is_multithreaded()) {
2605 2606
 	cli_warnmsg("bytecode_init: already initialized\n");
2606 2607
 	return CL_EARG;
2607 2608
     }
2609
+#else
2610
+    if (!LLVMIsMultithreaded()) {
2611
+        cli_warnmsg("bytecode_init: LLVM is compiled without multithreading support\n");
2612
+    }
2613
+#endif
2614
+
2608 2615
     llvm_install_error_handler(llvm_error_handler);
2609 2616
 #ifdef CL_DEBUG
2610 2617
     sys::PrintStackTraceOnErrorSignal();
... ...
@@ -2628,7 +2665,11 @@ int bytecode_init(void)
2628 2628
 #endif
2629 2629
     llvm::DwarfExceptionHandling = false;
2630 2630
 #endif
2631
+#if LLVM_VERSION < 33
2631 2632
     llvm_start_multithreaded();
2633
+#else
2634
+    // This is now deprecated/useless: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THREADS in LLVM.
2635
+#endif
2632 2636
 
2633 2637
     // If we have a native target, initialize it to ensure it is linked in and
2634 2638
     // usable by the JIT.
... ...
@@ -2638,7 +2679,11 @@ int bytecode_init(void)
2638 2638
     InitializeAllTargets();
2639 2639
 #endif
2640 2640
 
2641
+#if LLVM_VERSION < 35
2641 2642
     if (!llvm_is_multithreaded()) {
2643
+#else
2644
+    if (!LLVMIsMultithreaded()) {
2645
+#endif
2642 2646
 	//TODO:cli_dbgmsg
2643 2647
 	DEBUG(errs() << "WARNING: ClamAV JIT built w/o atomic builtins\n"
2644 2648
 	      << "On x86 for best performance ClamAV should be built for i686, not i386!\n");
... ...
@@ -2710,7 +2755,7 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx)
2710 2710
 	std::string ErrorMessage;
2711 2711
 #if LLVM_VERSION < 29
2712 2712
 	lines->buffer = MemoryBuffer::getFile(path, &ErrorMessage);
2713
-#else
2713
+#elif LLVM_VERSION < 35
2714 2714
 	OwningPtr<MemoryBuffer> File;
2715 2715
 	error_code ec = MemoryBuffer::getFile(path, File);
2716 2716
 	if (ec) {
... ...
@@ -2718,6 +2763,15 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx)
2718 2718
 	    lines->buffer = 0;
2719 2719
 	} else
2720 2720
 	    lines->buffer = File.take();
2721
+#else
2722
+	ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr = MemoryBuffer::getFile(path);
2723
+	if (!FileOrErr) {
2724
+		// TODO: How to handle ErrorMessage?
2725
+		lines->buffer = 0;
2726
+	}
2727
+	else {
2728
+		lines->buffer = FileOrErr.get().release();
2729
+	}
2721 2730
 #endif
2722 2731
 	if (!lines->buffer) {
2723 2732
 	    errs() << "Unable to open file '" << path << "'\n";
... ...
@@ -2863,7 +2917,10 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName,
2863 2863
   StringRef G;
2864 2864
   StringRef H;
2865 2865
 #endif
2866
+#if LLVM_VERSION < 35
2866 2867
   DIType TypeD;
2868
+#endif
2869
+  StringRef T;
2867 2870
 
2868 2871
   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(const_cast<Value*>(V))) {
2869 2872
     Value *DIGV = findDbgGlobalDeclare(GV);
... ...
@@ -2880,7 +2937,11 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName,
2880 2880
     G = Var.getFilename();
2881 2881
     H = Var.getDirectory();
2882 2882
 #endif
2883
+#if LLVM_VERSION < 35
2883 2884
     TypeD = Var.getType();
2885
+#else
2886
+    T = Var.getType().getName();
2887
+#endif
2884 2888
   } else if (Function *F = dyn_cast<Function>(const_cast<Value*>(V))){
2885 2889
     Value *DIF = findDbgSubprogramDeclare(F);
2886 2890
     if (!DIF) return false;
... ...
@@ -2896,7 +2957,11 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName,
2896 2896
     G = Var.getFilename();
2897 2897
     H = Var.getDirectory();
2898 2898
 #endif
2899
+#if LLVM_VERSION < 35
2899 2900
     TypeD = Var.getType();
2901
+#else
2902
+    T = Var.getType().getName();
2903
+#endif
2900 2904
   } else {
2901 2905
     const DbgDeclareInst *DDI = findDbgDeclare(V);
2902 2906
     if (!DDI) return false;
... ...
@@ -2913,10 +2978,16 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName,
2913 2913
     G = StringRef();
2914 2914
     H = StringRef();
2915 2915
 #endif
2916
+#if LLVM_VERSION < 35
2916 2917
     TypeD = Var.getType();
2918
+#else
2919
+    T = Var.getType().getName();
2920
+#endif
2917 2921
   }
2918 2922
 
2919
-  StringRef T = TypeD.getName();
2923
+#if LLVM_VERSION < 35
2924
+  T = TypeD.getName();
2925
+#endif
2920 2926
   if (!T.empty())
2921 2927
     Type = T;
2922 2928
 #if LLVM_VERSION < 33
... ...
@@ -3,19 +3,12 @@
3 3
 /* Define if building universal (internal helper macro) */
4 4
 #undef AC_APPLE_UNIVERSAL_BUILD
5 5
 
6
-/* Define to 1 if you have a deprecated version of the 'libjson' library
7
-   (-ljson). */
8
-#undef HAVE_DEPRECATED_JSON
9
-
10 6
 /* Define to 1 if you have the <dlfcn.h> header file. */
11 7
 #undef HAVE_DLFCN_H
12 8
 
13 9
 /* Define to 1 if you have the <inttypes.h> header file. */
14 10
 #undef HAVE_INTTYPES_H
15 11
 
16
-/* Define to 1 if you have the 'libjson' library (-ljson). */
17
-#undef HAVE_JSON
18
-
19 12
 /* Define to 1 if you have the <memory.h> header file. */
20 13
 #undef HAVE_MEMORY_H
21 14
 
... ...
@@ -637,9 +637,6 @@ ac_subst_vars='am__EXEEXT_FALSE
637 637
 am__EXEEXT_TRUE
638 638
 LTLIBOBJS
639 639
 LIBOBJS
640
-JSON_CPPFLAGS
641
-JSON_LDFLAGS
642
-JSON_LIBS
643 640
 BUILD_EXTERNAL_LLVM_FALSE
644 641
 BUILD_EXTERNAL_LLVM_TRUE
645 642
 NO_MISSING_FIELD_INITIALIZERS
... ...
@@ -802,7 +799,6 @@ with_system_llvm
802 802
 enable_llvm
803 803
 enable_optimized
804 804
 enable_all_jit_targets
805
-with_libjson
806 805
 '
807 806
       ac_precious_vars='build_alias
808 807
 host_alias
... ...
@@ -1463,10 +1459,9 @@ Optional Packages:
1463 1463
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
1464 1464
   --with-sysroot=DIR Search for dependent libraries within DIR
1465 1465
                         (or the compiler's sysroot if not specified).
1466
-  -with-system-llvm       Use system llvm instead of built-in, requires full
1467
-                          path to llvm-config
1468
-  --with-libjson=DIR   path to directory containing libjson (default=
1469
-    /usr/local or /usr if not found in /usr/local)
1466
+  --with-system-llvm      Use system llvm instead of built-in, uses full path
1467
+                          to llvm-config (default= search /usr/local or /usr
1468
+                          if not found in /usr/local)
1470 1469
 
1471 1470
 Some influential environment variables:
1472 1471
   CXX         C++ compiler command
... ...
@@ -15606,31 +15601,43 @@ llvmconfig=
15606 15606
 if test "${with_system_llvm+set}" = set; then :
15607 15607
   withval=$with_system_llvm; case "$withval" in
15608 15608
   yes)
15609
-    as_fn_error $? "--with-system-llvm needs full path to llvm-config" "$LINENO" 5
15610
-    ;;
15609
+     llvmconfig="/usr/local/bin/llvm-config"
15610
+     if test ! -x "$llvmconfig"; then
15611
+     llvmconfig="/usr/bin/llvm-config"
15612
+       if test ! -x "$llvmconfig"; then
15613
+         as_fn_error $? "llvm-config cannot be found within defaults" "$LINENO" 5
15614
+       fi
15615
+     fi
15616
+     ;;
15611 15617
   no) ;;
15612 15618
   *)
15613
-    llvmconfig="$withval"
15614
-    llvmver=`$llvmconfig --version`
15619
+     llvmconfig="$withval"
15620
+     if test ! -x "$llvmconfig"; then
15621
+       as_fn_error $? "llvm-config does not exist at $llvmconfig" "$LINENO" 5
15622
+     fi
15623
+     ;;
15624
+  esac
15625
+
15626
+ if test "x$llvmconfig" != "x"; then
15627
+     llvmver=`$llvmconfig --version`
15615 15628
 
15616
-    LLVMCONFIG_CXXFLAGS=`$llvmconfig --cxxflags`
15629
+     LLVMCONFIG_CXXFLAGS=`$llvmconfig --cxxflags`
15617 15630
 
15618
-    LLVMCONFIG_LDFLAGS=`$llvmconfig --ldflags`
15631
+     LLVMCONFIG_LDFLAGS=`$llvmconfig --ldflags`
15619 15632
 
15620
-    LLVMCONFIG_LIBS=`$llvmconfig --libs jit nativecodegen scalaropts ipo`
15633
+     LLVMCONFIG_LIBS=`$llvmconfig --libs jit nativecodegen scalaropts ipo`
15621 15634
 
15622
-    LLVMCONFIG_LIBFILES=`$llvmconfig --libfiles jit nativecodegen scalaropts ipo`
15635
+     LLVMCONFIG_LIBFILES=`$llvmconfig --libfiles jit nativecodegen scalaropts ipo`
15623 15636
 
15624
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Using external LLVM" >&5
15637
+     { $as_echo "$as_me:${as_lineno-$LINENO}: Using external LLVM" >&5
15625 15638
 $as_echo "$as_me: Using external LLVM" >&6;}
15626
-    { $as_echo "$as_me:${as_lineno-$LINENO}: CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS" >&5
15639
+     { $as_echo "$as_me:${as_lineno-$LINENO}: CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS" >&5
15627 15640
 $as_echo "$as_me: CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS" >&6;}
15628
-    { $as_echo "$as_me:${as_lineno-$LINENO}: LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS" >&5
15641
+     { $as_echo "$as_me:${as_lineno-$LINENO}: LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS" >&5
15629 15642
 $as_echo "$as_me: LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS" >&6;}
15630
-    { $as_echo "$as_me:${as_lineno-$LINENO}: LIBS from llvm-config: $LLVMCONFIG_LIBS" >&5
15643
+     { $as_echo "$as_me:${as_lineno-$LINENO}: LIBS from llvm-config: $LLVMCONFIG_LIBS" >&5
15631 15644
 $as_echo "$as_me: LIBS from llvm-config: $LLVMCONFIG_LIBS" >&6;}
15632
-    ;;
15633
-  esac
15645
+ fi
15634 15646
 
15635 15647
 fi
15636 15648
 
... ...
@@ -15663,10 +15670,10 @@ elif test $llvmver_test -lt 290; then
15663 15663
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no ($llvmver)" >&5
15664 15664
 $as_echo "no ($llvmver)" >&6; }
15665 15665
     as_fn_error $? "LLVM >= 2.9 required, but \"$llvmver\"($llvmver_test) found" "$LINENO" 5
15666
-elif test $llvmver_test -gt 342; then
15666
+elif test $llvmver_test -ge 360; then
15667 15667
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no ($llvmver)" >&5
15668 15668
 $as_echo "no ($llvmver)" >&6; }
15669
-    as_fn_error $? "LLVM <= 3.4.2 required, but \"$llvmver\"($llvmver_test) found" "$LINENO" 5
15669
+    as_fn_error $? "LLVM < 3.6 required, but \"$llvmver\"($llvmver_test) found" "$LINENO" 5
15670 15670
 else
15671 15671
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok ($llvmver)" >&5
15672 15672
 $as_echo "ok ($llvmver)" >&6; }
... ...
@@ -15905,220 +15912,6 @@ else
15905 15905
 fi
15906 15906
 
15907 15907
 
15908
-
15909
-
15910
-# Check whether --with-libjson was given.
15911
-if test "${with_libjson+set}" = set; then :
15912
-  withval=$with_libjson;
15913
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjson installation" >&5
15914
-$as_echo_n "checking for libjson installation... " >&6; }
15915
-if test "X$withval" != "Xyes"
15916
-then
15917
-  LIBJSON_HOME="$withval"
15918
-  if test -f "$LIBJSON_HOME/include/json/json.h" -o -f "$LIBJSON_HOME/include/json-c/json.h"
15919
-  then
15920
-    have_json_header="yes"
15921
-  fi
15922
-else
15923
-  LIBJSON_HOME=/usr/local
15924
-  if test -f "$LIBJSON_HOME/include/json/json.h" -o -f "$LIBJSON_HOME/include/json-c/json.h"
15925
-  then
15926
-    have_json_header="yes"
15927
-  else
15928
-    LIBJSON_HOME=/usr
15929
-    if test -f "$LIBJSON_HOME/include/json/json.h" -o -f "$LIBJSON_HOME/include/json-c/json.h"
15930
-    then
15931
-      have_json_header="yes"
15932
-    else
15933
-      have_json_header="no"
15934
-      LIBJSON_HOME=""
15935
-    fi
15936
-  fi
15937
-fi
15938
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBJSON_HOME" >&5
15939
-$as_echo "$LIBJSON_HOME" >&6; }
15940
-
15941
-else
15942
-
15943
-have_json_header="no"
15944
-
15945
-fi
15946
-
15947
-
15948
-if test "X$have_json_header" = "Xyes"
15949
-then
15950
-  if test -f "$LIBJSON_HOME/include/json/json.h"
15951
-  then
15952
-    JSON_INCLUDE="include/json"
15953
-  fi
15954
-  if test -f "$LIBJSON_HOME/include/json-c/json.h"
15955
-  then
15956
-    JSON_INCLUDE="include/json-c"
15957
-  fi
15958
-  if test -z $JSON_INCLUDE
15959
-  then
15960
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: json header lost." >&5
15961
-$as_echo "$as_me: WARNING: json header lost." >&2;}
15962
-  fi
15963
-
15964
-  JSON_CPPFLAGS="-I$LIBJSON_HOME/$JSON_INCLUDE"
15965
-  save_LDFLAGS="$LDFLAGS"
15966
-  save_CFLAGS="$CFLAGS"
15967
-  save_LIBS="$LIBS"
15968
-  LIBS=""
15969
-  JSON_LIBS=""
15970
-  if test "$LIBJSON_HOME" != "/usr"
15971
-  then
15972
-    JSON_LDFLAGS="-L$LIBJSON_HOME/lib"
15973
-    LDFLAGS="$LDFLAGS $JSON_LDFLAGS"
15974
-    CFLAGS="$CFLAGS $JSON_CPPFLAGS"
15975
-  fi
15976
-
15977
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing json_object_object_get_ex" >&5
15978
-$as_echo_n "checking for library containing json_object_object_get_ex... " >&6; }
15979
-if ${ac_cv_search_json_object_object_get_ex+:} false; then :
15980
-  $as_echo_n "(cached) " >&6
15981
-else
15982
-  ac_func_search_save_LIBS=$LIBS
15983
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15984
-/* end confdefs.h.  */
15985
-
15986
-/* Override any GCC internal prototype to avoid an error.
15987
-   Use char because int might match the return type of a GCC
15988
-   builtin and then its argument prototype would still apply.  */
15989
-#ifdef __cplusplus
15990
-extern "C"
15991
-#endif
15992
-char json_object_object_get_ex ();
15993
-int
15994
-main ()
15995
-{
15996
-return json_object_object_get_ex ();
15997
-  ;
15998
-  return 0;
15999
-}
16000
-_ACEOF
16001
-for ac_lib in '' json-c json; do
16002
-  if test -z "$ac_lib"; then
16003
-    ac_res="none required"
16004
-  else
16005
-    ac_res=-l$ac_lib
16006
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
16007
-  fi
16008
-  if ac_fn_c_try_link "$LINENO"; then :
16009
-  ac_cv_search_json_object_object_get_ex=$ac_res
16010
-fi
16011
-rm -f core conftest.err conftest.$ac_objext \
16012
-    conftest$ac_exeext
16013
-  if ${ac_cv_search_json_object_object_get_ex+:} false; then :
16014
-  break
16015
-fi
16016
-done
16017
-if ${ac_cv_search_json_object_object_get_ex+:} false; then :
16018
-
16019
-else
16020
-  ac_cv_search_json_object_object_get_ex=no
16021
-fi
16022
-rm conftest.$ac_ext
16023
-LIBS=$ac_func_search_save_LIBS
16024
-fi
16025
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_json_object_object_get_ex" >&5
16026
-$as_echo "$ac_cv_search_json_object_object_get_ex" >&6; }
16027
-ac_res=$ac_cv_search_json_object_object_get_ex
16028
-if test "$ac_res" != no; then :
16029
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
16030
-
16031
-have_json="yes"
16032
-have_deprecated_json="no"
16033
-else
16034
-
16035
-have_json="no"
16036
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing json_object_object_get" >&5
16037
-$as_echo_n "checking for library containing json_object_object_get... " >&6; }
16038
-if ${ac_cv_search_json_object_object_get+:} false; then :
16039
-  $as_echo_n "(cached) " >&6
16040
-else
16041
-  ac_func_search_save_LIBS=$LIBS
16042
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16043
-/* end confdefs.h.  */
16044
-
16045
-/* Override any GCC internal prototype to avoid an error.
16046
-   Use char because int might match the return type of a GCC
16047
-   builtin and then its argument prototype would still apply.  */
16048
-#ifdef __cplusplus
16049
-extern "C"
16050
-#endif
16051
-char json_object_object_get ();
16052
-int
16053
-main ()
16054
-{
16055
-return json_object_object_get ();
16056
-  ;
16057
-  return 0;
16058
-}
16059
-_ACEOF
16060
-for ac_lib in '' json-c json; do
16061
-  if test -z "$ac_lib"; then
16062
-    ac_res="none required"
16063
-  else
16064
-    ac_res=-l$ac_lib
16065
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
16066
-  fi
16067
-  if ac_fn_c_try_link "$LINENO"; then :
16068
-  ac_cv_search_json_object_object_get=$ac_res
16069
-fi
16070
-rm -f core conftest.err conftest.$ac_objext \
16071
-    conftest$ac_exeext
16072
-  if ${ac_cv_search_json_object_object_get+:} false; then :
16073
-  break
16074
-fi
16075
-done
16076
-if ${ac_cv_search_json_object_object_get+:} false; then :
16077
-
16078
-else
16079
-  ac_cv_search_json_object_object_get=no
16080
-fi
16081
-rm conftest.$ac_ext
16082
-LIBS=$ac_func_search_save_LIBS
16083
-fi
16084
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_json_object_object_get" >&5
16085
-$as_echo "$ac_cv_search_json_object_object_get" >&6; }
16086
-ac_res=$ac_cv_search_json_object_object_get
16087
-if test "$ac_res" != no; then :
16088
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
16089
-
16090
-have_json="yes"
16091
-have_deprecated_json="yes"
16092
-
16093
-fi
16094
-
16095
-
16096
-fi
16097
-
16098
-
16099
-  CFLAGS="$save_CFLAGS"
16100
-  LDFLAGS="$save_LDFLAGS"
16101
-fi
16102
-
16103
-if test "X$have_json" = "Xyes"; then
16104
-
16105
-$as_echo "#define HAVE_JSON 1" >>confdefs.h
16106
-
16107
-  if test "X$have_deprecated_json" = "Xyes"; then
16108
-
16109
-$as_echo "#define HAVE_DEPRECATED_JSON 1" >>confdefs.h
16110
-
16111
-  fi
16112
-  JSON_LIBS="$LIBS"
16113
-fi
16114
-
16115
-LIBS="$save_LIBS"
16116
-
16117
-
16118
-
16119
-
16120
-
16121
-
16122 15908
 ac_config_files="$ac_config_files Makefile"
16123 15909
 
16124 15910
 cat >confcache <<\_ACEOF
... ...
@@ -49,27 +49,40 @@ GMAKE="$llvm_cv_gnu_make_command"
49 49
 AC_SUBST([GMAKE])
50 50
 
51 51
 llvmconfig=
52
-AC_ARG_WITH([system-llvm], AC_HELP_STRING([-with-system-llvm],
53
-[Use system llvm instead of built-in, requires full path to llvm-config]),
52
+AC_ARG_WITH([system-llvm], AC_HELP_STRING([--with-system-llvm],
53
+[Use system llvm instead of built-in, uses full path to llvm-config (default=
54
+    search /usr/local or /usr if not found in /usr/local)]),
54 55
 [case "$withval" in
55 56
   yes)
56
-    AC_MSG_ERROR([--with-system-llvm needs full path to llvm-config])
57
-    ;;
57
+     llvmconfig="/usr/local/bin/llvm-config"
58
+     if test ! -x "$llvmconfig"; then
59
+     llvmconfig="/usr/bin/llvm-config"
60
+       if test ! -x "$llvmconfig"; then
61
+         AC_MSG_ERROR([llvm-config cannot be found within defaults])
62
+       fi
63
+     fi
64
+     ;;
58 65
   no) ;;
59 66
   *)
60
-    llvmconfig="$withval"
61
-    llvmver=`$llvmconfig --version`
62
-
63
-    AC_SUBST(LLVMCONFIG_CXXFLAGS, [`$llvmconfig --cxxflags`])
64
-    AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`])
65
-    AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs jit nativecodegen scalaropts ipo`])
66
-    AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles jit nativecodegen scalaropts ipo`])
67
-    AC_MSG_NOTICE([Using external LLVM])
68
-    AC_MSG_NOTICE([CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS])
69
-    AC_MSG_NOTICE([LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS])
70
-    AC_MSG_NOTICE([LIBS from llvm-config: $LLVMCONFIG_LIBS])
71
-    ;;
67
+     llvmconfig="$withval"
68
+     if test ! -x "$llvmconfig"; then
69
+       AC_MSG_ERROR([llvm-config does not exist at $llvmconfig])
70
+     fi
71
+     ;;
72 72
   esac
73
+
74
+ if test "x$llvmconfig" != "x"; then
75
+     llvmver=`$llvmconfig --version`
76
+
77
+     AC_SUBST(LLVMCONFIG_CXXFLAGS, [`$llvmconfig --cxxflags`])
78
+     AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`])
79
+     AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs jit nativecodegen scalaropts ipo`])
80
+     AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles jit nativecodegen scalaropts ipo`])
81
+     AC_MSG_NOTICE([Using external LLVM])
82
+     AC_MSG_NOTICE([CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS])
83
+     AC_MSG_NOTICE([LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS])
84
+     AC_MSG_NOTICE([LIBS from llvm-config: $LLVMCONFIG_LIBS])
85
+ fi
73 86
 ])
74 87
 
75 88
 AC_MSG_CHECKING([for supported LLVM version])
... ...
@@ -97,9 +110,9 @@ if test "x$packaged_llvm" = "xyes"; then
97 97
 elif test $llvmver_test -lt 290; then
98 98
     AC_MSG_RESULT([no ($llvmver)])
99 99
     AC_MSG_ERROR([LLVM >= 2.9 required, but "$llvmver"($llvmver_test) found])
100
-elif test $llvmver_test -gt 342; then
100
+elif test $llvmver_test -ge 360; then
101 101
     AC_MSG_RESULT([no ($llvmver)])
102
-    AC_MSG_ERROR([LLVM <= 3.4.2 required, but "$llvmver"($llvmver_test) found])
102
+    AC_MSG_ERROR([LLVM < 3.6 required, but "$llvmver"($llvmver_test) found])
103 103
 else
104 104
     AC_MSG_RESULT([ok ($llvmver)])
105 105
 fi
... ...
@@ -254,11 +267,6 @@ AC_MSG_RESULT([$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS])
254 254
 
255 255
 AM_CONDITIONAL(BUILD_EXTERNAL_LLVM, [test -n "$llvmconfig"])
256 256
 
257
-m4_include([../../m4/reorganization/libs/json.m4])
258
-AC_SUBST([JSON_LIBS])
259
-AC_SUBST([JSON_LDFLAGS])
260
-AC_SUBST([JSON_CPPFLAGS])
261
-
262 257
 AC_OUTPUT([
263 258
     Makefile
264 259
 ])
... ...
@@ -660,7 +660,7 @@ int cli_cvdload(FILE *fs, struct cl_engine *engine, unsigned int *signo, unsigne
660 660
     if(cvd.fl > cl_retflevel()) {
661 661
 	cli_warnmsg("***********************************************************\n");
662 662
 	cli_warnmsg("***  This version of the ClamAV engine is outdated.     ***\n");
663
-	cli_warnmsg("*** DON'T PANIC! Read http://www.clamav.net/support/faq ***\n");
663
+	cli_warnmsg("***   Read http://www.clamav.net/documentation.html     ***\n");
664 664
 	cli_warnmsg("***********************************************************\n");
665 665
     }
666 666
 
... ...
@@ -209,7 +209,7 @@ int cli_scandmg(cli_ctx *ctx)
209 209
 #if HAVE_LIBXML2
210 210
 
211 211
 /* XML_PARSE_NOENT | XML_PARSE_NONET | XML_PARSE_COMPACT */
212
-#define DMG_XML_PARSE_OPTS (1 << 1 | 1 << 11 | 1 << 16)
212
+#define DMG_XML_PARSE_OPTS ((1 << 1 | 1 << 11 | 1 << 16) | CLAMAV_MIN_XMLREADER_FLAGS)
213 213
 
214 214
     reader = xmlReaderForMemory(outdata, (int)hdr.xmlLength, "toc.xml", NULL, DMG_XML_PARSE_OPTS);
215 215
     if (!reader) {
... ...
@@ -181,6 +181,7 @@ cli_file_t cli_partitiontype(const unsigned char *buf, size_t buflen, const stru
181 181
 	ptype = ptype->next;
182 182
     }
183 183
 
184
+    cli_dbgmsg("Partition type is potentially unsupported\n");
184 185
     return CL_TYPE_PART_ANY;
185 186
 }
186 187
 
... ...
@@ -266,7 +267,8 @@ cli_file_t cli_filetype2(fmap_t *map, const struct cl_engine *engine, cli_file_t
266 266
             const unsigned char * znamep = buff;
267 267
             int32_t zlen = bread;
268 268
             int lhc = 0;
269
-            int zi;
269
+            int zi, likely_ooxml = 0;
270
+            cli_file_t ret2;
270 271
             
271 272
             for (zi=0; zi<32; zi++) {
272 273
                 znamep = (const unsigned char *)cli_memstr((const char *)znamep, zlen, lhdr_magic, 4);
... ...
@@ -283,9 +285,34 @@ cli_file_t cli_filetype2(fmap_t *map, const struct cl_engine *engine, cli_file_t
283 283
                         } else if (0 == memcmp(znamep, "word/", 5)) {
284 284
                             cli_dbgmsg("Recognized OOXML Word file\n");
285 285
                             return CL_TYPE_OOXML_WORD;
286
+                        } else if (0 == memcmp(znamep, "docProps/", 5)) {
287
+                            likely_ooxml = 1;
288
+                        }
289
+
290
+                        if (++lhc > 2) {
291
+                            /* only check first three zip headers unless likely ooxml */
292
+                            if (likely_ooxml) {
293
+                                cli_dbgmsg("Likely OOXML, checking additional zip headers\n");
294
+                                if ((ret2 = cli_ooxml_filetype(NULL, map)) != CL_SUCCESS) {
295
+                                    /* either an error or retyping has occurred, return error or just CL_TYPE_ZIP? */
296
+                                    switch (ret2) {
297
+                                    case CL_TYPE_OOXML_XL:
298
+                                        cli_dbgmsg("Recognized OOXML XL file\n");
299
+                                        break;
300
+                                    case CL_TYPE_OOXML_PPT:
301
+                                        cli_dbgmsg("Recognized OOXML PPT file\n");
302
+                                        break;
303
+                                    case CL_TYPE_OOXML_WORD:
304
+                                        cli_dbgmsg("Recognized OOXML WORD file\n");
305
+                                        break;
306
+                                    default:
307
+                                        cli_dbgmsg("unexpected ooxml_filetype return: %i\n", ret2);
308
+                                    }
309
+                                    return ret2;
310
+                                }
311
+                            }
312
+                            break;
286 313
                         }
287
-                        if (++lhc > 2)
288
-                            break; /* only check first three zip headers */
289 314
                     }
290 315
                     else {
291 316
                         znamep = NULL; /* force to map more */
... ...
@@ -1811,10 +1811,11 @@ abort:
1811 1811
 		if(file_buff_text->fd != -1)
1812 1812
 			close(file_buff_text->fd);
1813 1813
 		free(file_buff_text);
1814
+        file_buff_text=NULL;
1814 1815
 	}
1815 1816
 	if(file_tmp_o1) {
1816 1817
 		html_output_flush(file_tmp_o1);
1817
-		if(file_buff_text->fd != -1)
1818
+		if(file_buff_text && file_buff_text->fd != -1)
1818 1819
 			close(file_tmp_o1->fd);
1819 1820
 		free(file_tmp_o1);
1820 1821
 	}
... ...
@@ -3315,7 +3315,7 @@ getline_from_mbox(char *buffer, size_t buffer_len, fmap_t *map, size_t *at)
3315 3315
 	return NULL;
3316 3316
     }
3317 3317
     if((buffer_len == 0) || (buffer == NULL)) {
3318
-	cli_errmsg("Invalid call to getline_from_mbox(). Refer to http://www.clamav.net/bugs\n");
3318
+	cli_errmsg("Invalid call to getline_from_mbox(). Refer to http://www.clamav.net/documentation.html\n");
3319 3319
 	return NULL;
3320 3320
     }
3321 3321
 
... ...
@@ -454,7 +454,7 @@ static int mbr_check_mbr(struct mbr_boot_record *record, size_t maplen, size_t s
454 454
 
455 455
     /* check the maplen */
456 456
     if ((maplen / sectorsize) < 2) {
457
-        cli_dbgmsg("cli_scanmbr: file is too small to hold disk image\n");
457
+        cli_dbgmsg("cli_scanmbr: bootstrap code or file is too small to hold disk image\n");
458 458
         return CL_EFORMAT;
459 459
     }
460 460
 
... ...
@@ -28,12 +28,17 @@
28 28
 #include <fcntl.h>
29 29
 #include <stdio.h>
30 30
 #include <string.h>
31
+#include <ctype.h>
32
+#include <stdlib.h>
33
+#include <errno.h>
34
+#include <conv.h>
31 35
 #ifdef	HAVE_UNISTD_H
32 36
 #include <unistd.h>
33 37
 #endif
34
-#include <ctype.h>
35
-#include <stdlib.h>
36
-#include "clamav.h"
38
+
39
+#if HAVE_ICONV
40
+#include <iconv.h>
41
+#endif
37 42
 
38 43
 #include "clamav.h"
39 44
 #include "cltypes.h"
... ...
@@ -1318,7 +1323,7 @@ abort:
1318 1318
 
1319 1319
 #define WINUNICODE 0x04B0
1320 1320
 #define PROPCNTLIMIT 25
1321
-#define PROPSTRLIMIT 62
1321
+#define PROPSTRLIMIT 128 /* affects property strs, NOT sanitized strs (may result in a buffer allocating PROPSTRLIMIT*6) */
1322 1322
 
1323 1323
 #define sum16_endian_convert(v) le16_to_host((uint16_t)(v))
1324 1324
 #define sum32_endian_convert(v) le32_to_host((uint32_t)(v))
... ...
@@ -1415,7 +1420,7 @@ typedef struct propset_summary_entry {
1415 1415
     uint32_t offset;
1416 1416
 } propset_entry_t;
1417 1417
 
1418
-/* metadata structures */
1418
+/* error codes */
1419 1419
 #define OLE2_SUMMARY_ERROR_TOOSMALL      0x00000001
1420 1420
 #define OLE2_SUMMARY_ERROR_OOB           0x00000002
1421 1421
 #define OLE2_SUMMARY_ERROR_DATABUF       0x00000004
... ...
@@ -1427,6 +1432,13 @@ typedef struct propset_summary_entry {
1427 1427
 #define OLE2_SUMMARY_FLAG_UNHANDLED_PROPTYPE 0x00000100
1428 1428
 #define OLE2_SUMMARY_FLAG_TRUNC_STR      0x00000200
1429 1429
 
1430
+#define OLE2_CODEPAGE_ERROR_NOTFOUND     0x00000400
1431
+#define OLE2_CODEPAGE_ERROR_UNINITED     0x00000800
1432
+#define OLE2_CODEPAGE_ERROR_INVALID      0x00001000
1433
+#define OLE2_CODEPAGE_ERROR_INCOMPLETE   0x00002000
1434
+#define OLE2_CODEPAGE_ERROR_OUTBUFTOOSMALL 0x00002000
1435
+
1436
+/* metadata structures */
1430 1437
 typedef struct summary_ctx {
1431 1438
     cli_ctx *ctx;
1432 1439
     int mode;
... ...
@@ -1447,6 +1459,264 @@ typedef struct summary_ctx {
1447 1447
     int toval;
1448 1448
 } summary_ctx_t;
1449 1449
 
1450
+/* string conversion */
1451
+struct codepage_entry {
1452
+    int16_t codepage;
1453
+    const char *encoding;
1454
+};
1455
+
1456
+#define NUMCODEPAGES 152
1457
+static const struct codepage_entry codepage_entries[NUMCODEPAGES] = {
1458
+    { 37,    "IBM037" },      /* IBM EBCDIC US-Canada */
1459
+    { 437,   "IBM437" },      /* OEM United States */
1460
+    { 500,   "IBM500" },      /* IBM EBCDIC International */
1461
+    { 708,   "ASMO-708" },    /* Arabic (ASMO 708) */
1462
+    { 709,   NULL },          /* Arabic (ASMO-449+, BCON V4) */
1463
+    { 710,   NULL },          /* Arabic - Transparent Arabic */
1464
+    { 720,   NULL },          /* Arabic (Transparent ASMO); Arabic (DOS) */
1465
+    { 737,   NULL },          /* OEM Greek (formerly 437G); Greek (DOS) */
1466
+    { 775,   "IBM775" },      /* OEM Baltic; Baltic (DOS) */
1467
+    { 850,   "IBM850" },      /* OEM Multilingual Latin 1; Western European (DOS) */
1468
+    { 852,   "IBM852" },      /* OEM Latin 2; Central European (DOS) */
1469
+    { 855,   "IBM855" },      /* OEM Cyrillic (primarily Russian) */
1470
+    { 857,   "IBM857" },      /* OEM Turkish; Turkish (DOS) */
1471
+    { 858,   NULL },          /* OEM Multilingual Latin 1 + Euro symbol */
1472
+    { 860,   "IBM860" },      /* OEM Portuguese; Portuguese (DOS) */
1473
+    { 861,   "IBM861" },      /* OEM Icelandic; Icelandic (DOS) */
1474
+    { 862,   NULL },          /* OEM Hebrew; Hebrew (DOS) */
1475
+    { 863,   "IBM863" },      /* OEM French Canadian; French Canadian (DOS) */
1476
+    { 864,   "IBM864" },      /* OEM Arabic; Arabic (864) */
1477
+    { 865,   "IBM865" },      /* OEM Nordic; Nordic (DOS) */
1478
+    { 866,   "CP866" },       /* OEM Russian; Cyrillic (DOS) */
1479
+    { 869,   "IBM869" },      /* OEM Modern Greek; Greek, Modern (DOS) */
1480
+    { 870,   "IBM870" },      /* IBM EBCDIC Multilingual/ROECE (Latin 2); IBM EBCDIC Multilingual Latin 2 */
1481
+    { 874,   "WINDOWS-874" }, /* ANSI/OEM Thai (ISO 8859-11); Thai (Windows) */
1482
+    { 875,   "CP875" },       /* IBM EBCDIC Greek Modern */
1483
+    { 932,   "SHIFT_JIS" },   /* ANSI/OEM Japanese; Japanese (Shift-JIS) */
1484
+    { 936,   "GB2312" },      /* ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312) */
1485
+    { 949,   NULL },          /* ANSI/OEM Korean (Unified Hangul Code) */
1486
+    { 950,   "BIG5" },        /* ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5) */
1487
+    { 1026,  "IBM1026" },     /* IBM EBCDIC Turkish (Latin 5) */
1488
+    { 1047,  NULL },          /* IBM EBCDIC Latin 1/Open System */
1489
+    { 1140,  NULL },          /* IBM EBCDIC US-Canada (037 + Euro symbol); IBM EBCDIC (US-Canada-Euro) */
1490
+    { 1141,  NULL },          /* IBM EBCDIC Germany (20273 + Euro symbol); IBM EBCDIC (Germany-Euro) */
1491
+    { 1142,  NULL },          /* IBM EBCDIC Denmark-Norway (20277 + Euro symbol); IBM EBCDIC (Denmark-Norway-Euro) */
1492
+    { 1143,  NULL },          /* IBM EBCDIC Finland-Sweden (20278 + Euro symbol); IBM EBCDIC (Finland-Sweden-Euro) */
1493
+    { 1144,  NULL },          /* IBM EBCDIC Italy (20280 + Euro symbol); IBM EBCDIC (Italy-Euro) */
1494
+    { 1145,  NULL },          /* IBM EBCDIC Latin America-Spain (20284 + Euro symbol); IBM EBCDIC (Spain-Euro) */
1495
+    { 1146,  NULL },          /* IBM EBCDIC United Kingdom (20285 + Euro symbol); IBM EBCDIC (UK-Euro) */
1496
+    { 1147,  NULL },          /* IBM EBCDIC France (20297 + Euro symbol); IBM EBCDIC (France-Euro) */
1497
+    { 1148,  NULL },          /* IBM EBCDIC International (500 + Euro symbol); IBM EBCDIC (International-Euro) */
1498
+    { 1149,  NULL },          /* IBM EBCDIC Icelandic (20871 + Euro symbol); IBM EBCDIC (Icelandic-Euro) */
1499
+    { 1200,  "UTF-16LE" },    /* Unicode UTF-16, little endian byte order (BMP of ISO 10646); available only to managed applications */
1500
+    { 1201,  "UTF-16BE" },    /* Unicode UTF-16, big endian byte order; available only to managed applications */
1501
+    { 1250,  "WINDOWS-1250" }, /* ANSI Central European; Central European (Windows) */
1502
+    { 1251,  "WINDOWS-1251" }, /* ANSI Cyrillic; Cyrillic (Windows) */
1503
+    { 1252,  "WINDOWS-1252" }, /* ANSI Latin 1; Western European (Windows) */
1504
+    { 1253,  "WINDOWS-1253" }, /* ANSI Greek; Greek (Windows) */
1505
+    { 1254,  "WINDOWS-1254" }, /* ANSI Turkish; Turkish (Windows) */
1506
+    { 1255,  "WINDOWS-1255" }, /* ANSI Hebrew; Hebrew (Windows) */
1507
+    { 1256,  "WINDOWS-1256" }, /* ANSI Arabic; Arabic (Windows) */
1508
+    { 1257,  "WINDOWS-1257" }, /* ANSI Baltic; Baltic (Windows) */
1509
+    { 1258,  "WINDOWS-1258" }, /* ANSI/OEM Vietnamese; Vietnamese (Windows) */
1510
+    { 1361,  "JOHAB" },       /* Korean (Johab) */
1511
+    { 10000, "MACINTOSH" },   /* MAC Roman; Western European (Mac) */
1512
+    { 10001, NULL },          /* Japanese (Mac) */
1513
+    { 10002, NULL },          /* MAC Traditional Chinese (Big5); Chinese Traditional (Mac) */
1514
+    { 10003, NULL },          /* Korean (Mac) */
1515
+    { 10004, NULL },          /* Arabic (Mac) */
1516
+    { 10005, NULL },          /* Hebrew (Mac) */
1517
+    { 10006, NULL },          /* Greek (Mac) */
1518
+    { 10007, NULL },          /* Cyrillic (Mac) */
1519
+    { 10008, NULL },          /* MAC Simplified Chinese (GB 2312); Chinese Simplified (Mac) */
1520
+    { 10010, NULL },          /* Romanian (Mac) */
1521
+    { 10017, NULL },          /* Ukrainian (Mac) */
1522
+    { 10021, NULL },          /* Thai (Mac) */
1523
+    { 10029, NULL },          /* MAC Latin 2; Central European (Mac) */
1524
+    { 10079, NULL },          /* Icelandic (Mac) */
1525
+    { 10081, NULL },          /* Turkish (Mac) */
1526
+    { 10082, NULL },          /* Croatian (Mac) */
1527
+    { 12000, "UTF-32LE" },    /* Unicode UTF-32, little endian byte order; available only to managed applications */
1528
+    { 12001, "UTF-32BE" },    /* Unicode UTF-32, big endian byte order; available only to managed applications */
1529
+    { 20000, NULL },          /* CNS Taiwan; Chinese Traditional (CNS) */
1530
+    { 20001, NULL },          /* TCA Taiwan */
1531
+    { 20002, NULL },          /* Eten Taiwan; Chinese Traditional (Eten) */
1532
+    { 20003, NULL },          /* IBM5550 Taiwan */
1533
+    { 20004, NULL },          /* TeleText Taiwan */
1534
+    { 20005, NULL },          /* Wang Taiwan */
1535
+    { 20105, NULL },          /* IA5 (IRV International Alphabet No. 5, 7-bit); Western European (IA5) */
1536
+    { 20106, NULL },          /* IA5 German (7-bit) */
1537
+    { 20107, NULL },          /* IA5 Swedish (7-bit) */
1538
+    { 20108, NULL },          /* IA5 Norwegian (7-bit) */
1539
+    { 20127, "US-ASCII" },    /* US-ASCII (7-bit) */
1540
+    { 20261, NULL },          /* T.61 */
1541
+    { 20269, NULL },          /* ISO 6937 Non-Spacing Accent */
1542
+    { 20273, "IBM273" },      /* IBM EBCDIC Germany */
1543
+    { 20277, "IBM277" },      /* IBM EBCDIC Denmark-Norway */
1544
+    { 20278, "IBM278" },      /* IBM EBCDIC Finland-Sweden */
1545
+    { 20280, "IBM280" },      /* IBM EBCDIC Italy */
1546
+    { 20284, "IBM284" },      /* IBM EBCDIC Latin America-Spain */
1547
+    { 20285, "IBM285" },      /* IBM EBCDIC United Kingdom */
1548
+    { 20290, "IBM290" },      /* IBM EBCDIC Japanese Katakana Extended */
1549
+    { 20297, "IBM297" },      /* IBM EBCDIC France */
1550
+    { 20420, "IBM420" },      /* IBM EBCDIC Arabic */
1551
+    { 20423, "IBM423" },      /* IBM EBCDIC Greek */
1552
+    { 20424, "IBM424" },      /* IBM EBCDIC Hebrew */
1553
+    { 20833, NULL },          /* IBM EBCDIC Korean Extended */
1554
+    { 20838, NULL },          /* IBM EBCDIC Thai */
1555
+    { 20866, "KOI8-R" },      /* Russian (KOI8-R); Cyrillic (KOI8-R) */
1556
+    { 20871, "IBM871" },      /* IBM EBCDIC Icelandic */
1557
+    { 20880, "IBM880" },      /* IBM EBCDIC Cyrillic Russian */
1558
+    { 20905, "IBM905" },      /* IBM EBCDIC Turkish */
1559
+    { 20924, NULL },          /* IBM EBCDIC Latin 1/Open System (1047 + Euro symbol) */
1560
+    { 20932, "EUC-JP" },      /* Japanese (JIS 0208-1990 and 0212-1990) */
1561
+    { 20936, NULL },          /* Simplified Chinese (GB2312); Chinese Simplified (GB2312-80) */
1562
+    { 20949, NULL },          /* Korean Wansung */
1563
+    { 21025, "CP1025" },      /* IBM EBCDIC Cyrillic Serbian-Bulgarian */
1564
+    { 21027, NULL },          /* (deprecated) */
1565
+    { 21866, "KOI8-U" },      /* Ukrainian (KOI8-U); Cyrillic (KOI8-U) */
1566
+    { 28591, "ISO-8859-1" },  /* ISO 8859-1 Latin 1; Western European (ISO) */
1567
+    { 28592, "ISO-8859-2" },  /* ISO 8859-2 Central European; Central European (ISO) */
1568
+    { 28593, "ISO-8859-3" },  /* ISO 8859-3 Latin 3 */
1569
+    { 28594, "ISO-8859-4" },  /* ISO 8859-4 Baltic */
1570
+    { 28595, "ISO-8859-5" },  /* ISO 8859-5 Cyrillic */
1571
+    { 28596, "ISO-8859-6" },  /* ISO 8859-6 Arabic */
1572
+    { 28597, "ISO-8859-7" },  /* ISO 8859-7 Greek */
1573
+    { 28598, "ISO-8859-8" },  /* ISO 8859-8 Hebrew; Hebrew (ISO-Visual) */
1574
+    { 28599, "ISO-8859-9" },  /* ISO 8859-9 Turkish */
1575
+    { 28603, "ISO-8859-13" }, /* ISO 8859-13 Estonian */
1576
+    { 28605, "ISO-8859-15" }, /* ISO 8859-15 Latin 9 */
1577
+    { 29001, NULL },          /* Europa 3 */
1578
+    { 38598, NULL },          /* ISO 8859-8 Hebrew; Hebrew (ISO-Logical) */
1579
+    { 50220, "ISO-2022-JP" },   /* ISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS) (guess) */
1580
+    { 50221, "ISO-2022-JP-2" }, /* ISO 2022 Japanese with halfwidth Katakana; Japanese (JIS-Allow 1 byte Kana) (guess) */
1581
+    { 50222, "ISO-2022-JP-3" }, /* ISO 2022 Japanese JIS X 0201-1989; Japanese (JIS-Allow 1 byte Kana - SO/SI) (guess) */
1582
+    { 50225, "ISO-2022-KR" }, /* ISO 2022 Korean */
1583
+    { 50227, NULL },          /* ISO 2022 Simplified Chinese; Chinese Simplified (ISO 2022) */
1584
+    { 50229, NULL },          /* ISO 2022 Traditional Chinese */
1585
+    { 50930, NULL },          /* EBCDIC Japanese (Katakana) Extended */
1586
+    { 50931, NULL },          /* EBCDIC US-Canada and Japanese */
1587
+    { 50933, NULL },          /* EBCDIC Korean Extended and Korean */
1588
+    { 50935, NULL },          /* EBCDIC Simplified Chinese Extended and Simplified Chinese */
1589
+    { 50936, NULL },          /* EBCDIC Simplified Chinese */
1590
+    { 50937, NULL },          /* EBCDIC US-Canada and Traditional Chinese */
1591
+    { 50939, NULL },          /* EBCDIC Japanese (Latin) Extended and Japanese */
1592
+    { 51932, "EUC-JP" },      /* EUC Japanese */
1593
+    { 51936, "EUC-CN" },      /* EUC Simplified Chinese; Chinese Simplified (EUC) */
1594
+    { 51949, "EUC-KR" },      /* EUC Korean */
1595
+    { 51950, NULL },          /* EUC Traditional Chinese */
1596
+    { 52936, NULL },          /* HZ-GB2312 Simplified Chinese; Chinese Simplified (HZ) */
1597
+    { 54936, "GB18030" },     /* Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030) */
1598
+    { 57002, NULL },          /* ISCII Devanagari */
1599
+    { 57003, NULL },          /* ISCII Bengali */
1600
+    { 57004, NULL },          /* ISCII Tamil */
1601
+    { 57005, NULL },          /* ISCII Telugu */
1602
+    { 57006, NULL },          /* ISCII Assamese */
1603
+    { 57007, NULL },          /* ISCII Oriya */
1604
+    { 57008, NULL },          /* ISCII Kannada */
1605
+    { 57009, NULL },          /* ISCII Malayalam */
1606
+    { 57010, NULL },          /* ISCII Gujarati */
1607
+    { 57011, NULL },          /* ISCII Punjabi */
1608
+    { 65000, "UTF-7" },       /* Unicode (UTF-7) */
1609
+    { 65001, "UTF-8" }        /* Unicode (UTF-8) */
1610
+};
1611
+
1612
+static char *
1613
+ole2_convert_utf(summary_ctx_t *sctx, char *begin, size_t sz, const char *encoding)
1614
+{
1615
+#if HAVE_ICONV
1616
+    char *res=NULL;
1617
+    char *buf, *outbuf, *p1, *p2;
1618
+    size_t inlen, outlen, nonrev, sz2;
1619
+    int i, try;
1620
+    iconv_t cd;
1621
+
1622
+    buf = cli_calloc(1, sz);
1623
+    if (!(buf))
1624
+        return NULL;
1625
+
1626
+    memcpy(buf, begin, sz);
1627
+
1628
+    outbuf = NULL;
1629
+    inlen = sz;
1630
+
1631
+    /* encoding lookup if not specified */
1632
+    if (!encoding) {
1633
+        for (i = 0; i < NUMCODEPAGES; ++i) {
1634
+            if (sctx->codepage == codepage_entries[i].codepage)
1635
+                encoding = codepage_entries[i].encoding;
1636
+            else if (sctx->codepage < codepage_entries[i].codepage) {
1637
+                /* assuming sorted array */
1638
+                break;
1639
+            }
1640
+        }
1641
+
1642
+        if (!encoding) {
1643
+            cli_warnmsg("ole2_convert_utf: could not locate codepage encoding for %d\n", sctx->codepage);
1644
+            sctx->flags |= OLE2_CODEPAGE_ERROR_NOTFOUND;
1645
+            free(buf);
1646
+            return NULL;
1647
+        }
1648
+    }
1649
+
1650
+    cd = iconv_open("UTF-8", encoding);
1651
+    if (cd == (iconv_t)(-1)) {
1652
+        cli_errmsg("ole2_convert_utf: could not initialize iconv\n");
1653
+        sctx->flags |= OLE2_CODEPAGE_ERROR_UNINITED;
1654
+    }
1655
+    else {
1656
+        for (try = 1; try <= 3; ++try) {
1657
+            p1 = buf;
1658
+
1659
+            if (outbuf)
1660
+                free(outbuf);
1661
+            outlen = sz2 = (try*2) * sz;
1662
+            p2 = outbuf = cli_calloc(1, sz2);
1663
+            if (!outbuf) {
1664
+                free(buf);
1665
+                return NULL;
1666
+            }
1667
+
1668
+            nonrev = iconv(cd, (char **)(&p1), &inlen, &p2, &outlen);
1669
+
1670
+            if (errno == EILSEQ) {
1671
+                cli_dbgmsg("ole2_convert_utf: input buffer contains invalid character for its encoding\n");
1672
+                sctx->flags |= OLE2_CODEPAGE_ERROR_INVALID;
1673
+                break;
1674
+            }
1675
+            else if (errno == EINVAL && nonrev == (size_t)-1) {
1676
+                cli_dbgmsg("ole2_convert_utf: input buffer contains incomplete multibyte character\n");
1677
+                sctx->flags |= OLE2_CODEPAGE_ERROR_INCOMPLETE;
1678
+                break;
1679
+            }
1680
+            else if (inlen == 0) {
1681
+                //cli_dbgmsg("ole2_convert_utf: input buffer is successfully translated\n");
1682
+                break;
1683
+            }
1684
+
1685
+            cli_dbgmsg("ole2_convert_utf: outbuf is too small, resizing %llu -> %llu\n",
1686
+                       (long long unsigned)((try*2) * sz), (long long unsigned)(((try+1)*2) * sz));
1687
+        }
1688
+
1689
+        if (inlen != 0 || (errno == E2BIG && nonrev == (size_t)-1)) {
1690
+            cli_dbgmsg("ole2_convert_utf: buffer could not be fully translated\n");
1691
+            sctx->flags |= OLE2_CODEPAGE_ERROR_OUTBUFTOOSMALL;
1692
+        }
1693
+
1694
+        outbuf[sz2 - outlen] = '\0';
1695
+        res = strdup(outbuf);
1696
+    }
1697
+
1698
+    iconv_close(cd);
1699
+    free(buf);
1700
+    free(outbuf);
1701
+    return res;
1702
+#else
1703
+    /* this should force base64 encoding */
1704
+    return NULL;
1705
+#endif
1706
+}
1707
+
1450 1708
 static int
1451 1709
 ole2_process_property(summary_ctx_t *sctx, unsigned char *databuf, uint32_t offset)
1452 1710
 {
... ...
@@ -1662,7 +1932,7 @@ ole2_process_property(summary_ctx_t *sctx, unsigned char *databuf, uint32_t offs
1662 1662
         }
1663 1663
         else if (sctx->codepage != WINUNICODE) {
1664 1664
             uint32_t strsize;
1665
-            char *outstr;
1665
+            char *outstr, *outstr2;
1666 1666
 
1667 1667
             if (offset+sizeof(strsize) > sctx->pssize) {
1668 1668
                 sctx->flags |= OLE2_SUMMARY_ERROR_OOB;
... ...
@@ -1692,8 +1962,28 @@ ole2_process_property(summary_ctx_t *sctx, unsigned char *databuf, uint32_t offs
1692 1692
                 return CL_EMEM;
1693 1693
             }
1694 1694
             strncpy(outstr, (const char *)(databuf+offset), strsize);
1695
-            ret = cli_jsonstr(sctx->summary, sctx->propname, outstr);
1695
+
1696
+            /* conversion of various encodings to UTF-8 */
1697
+            outstr2 = ole2_convert_utf(sctx, outstr, strsize, NULL);
1698
+            if (!outstr2) {
1699
+                /* use base64 encoding when all else fails! */
1700
+                char b64jstr[PROPSTRLIMIT];
1701
+
1702
+                outstr2 = cl_base64_encode(outstr, strsize);
1703
+                if (!outstr2) {
1704
+                    free(outstr);
1705
+                    return CL_EMEM;
1706
+                }
1707
+
1708
+                snprintf(b64jstr, PROPSTRLIMIT, "%s_base64", sctx->propname);
1709
+                ret = cli_jsonbool(sctx->summary, b64jstr, 1);
1710
+                if (ret != CL_SUCCESS)
1711
+                    return ret;
1712
+            }
1713
+
1714
+            ret = cli_jsonstr(sctx->summary, sctx->propname, outstr2);
1696 1715
             free(outstr);
1716
+            free(outstr2);
1697 1717
             break;
1698 1718
         }
1699 1719
         /* fall-through for unicode strings */
... ...
@@ -1738,13 +2028,28 @@ ole2_process_property(summary_ctx_t *sctx, unsigned char *databuf, uint32_t offs
1738 1738
             if (!outstr) {
1739 1739
                 return CL_EMEM;
1740 1740
             }
1741
-            strncpy(outstr, (const char *)(databuf+offset), strsize);
1742
-            outstr2 = (char*)get_property_name2(outstr, strsize);
1743
-            if (outstr2) {
1744
-                ret = cli_jsonstr(sctx->summary, sctx->propname, outstr2);
1745
-                free(outstr2);
1741
+            memcpy(outstr, (const char *)(databuf+offset), strsize);
1742
+            /* conversion of 16-width char strings to UTF-8 */
1743
+            outstr2 = ole2_convert_utf(sctx, outstr, strsize, "UTF-16");
1744
+            if (!outstr2) {
1745
+                /* use base64 encoding when all else fails! */
1746
+                char b64jstr[PROPSTRLIMIT];
1747
+
1748
+                outstr2 = cl_base64_encode(outstr, strsize);
1749
+                if (!outstr2) {
1750
+                    free(outstr);
1751
+                    return CL_EMEM;
1752
+                }
1753
+
1754
+                snprintf(b64jstr, PROPSTRLIMIT, "%s_base64", sctx->propname);
1755
+                ret = cli_jsonbool(sctx->summary, b64jstr, 1);
1756
+                if (ret != CL_SUCCESS)
1757
+                    return ret;
1746 1758
             }
1759
+
1760
+            ret = cli_jsonstr(sctx->summary, sctx->propname, outstr2);
1747 1761
             free(outstr);
1762
+            free(outstr2);
1748 1763
             break;
1749 1764
 	}
1750 1765
     case PT_FILETIME:
... ...
@@ -2050,7 +2355,7 @@ static int cli_ole2_summary_json_cleanup(summary_ctx_t *sctx, int retcode)
2050 2050
     if (sctx->flags) {
2051 2051
         jarr = cli_jsonarray(sctx->summary, "ParseErrors");
2052 2052
 
2053
-        /* check errors */
2053
+        /* summary errors */
2054 2054
         if (sctx->flags & OLE2_SUMMARY_ERROR_TOOSMALL) {
2055 2055
             cli_jsonstr(jarr, NULL, "OLE2_SUMMARY_ERROR_TOOSMALL");
2056 2056
         }
... ...
@@ -2081,6 +2386,23 @@ static int cli_ole2_summary_json_cleanup(summary_ctx_t *sctx, int retcode)
2081 2081
         if (sctx->flags & OLE2_SUMMARY_FLAG_TRUNC_STR) {
2082 2082
             cli_jsonstr(jarr, NULL, "OLE2_SUMMARY_FLAG_TRUNC_STR");
2083 2083
         }
2084
+
2085
+        /* codepage translation errors */
2086
+        if (sctx->flags & OLE2_CODEPAGE_ERROR_NOTFOUND) {
2087
+            cli_jsonstr(jarr, NULL, "OLE2_CODEPAGE_ERROR_NOTFOUND");
2088
+        }
2089
+        if (sctx->flags & OLE2_CODEPAGE_ERROR_UNINITED) {
2090
+            cli_jsonstr(jarr, NULL, "OLE2_CODEPAGE_ERROR_UNINITED");
2091
+        }
2092
+        if (sctx->flags & OLE2_CODEPAGE_ERROR_INVALID) {
2093
+            cli_jsonstr(jarr, NULL, "OLE2_CODEPAGE_ERROR_INVALID");
2094
+        }
2095
+        if (sctx->flags & OLE2_CODEPAGE_ERROR_INCOMPLETE) {
2096
+            cli_jsonstr(jarr, NULL, "OLE2_CODEPAGE_ERROR_INCOMPLETE");
2097
+        }
2098
+        if (sctx->flags & OLE2_CODEPAGE_ERROR_OUTBUFTOOSMALL) {
2099
+            cli_jsonstr(jarr, NULL, "OLE2_CODEPAGE_ERROR_OUTBUFTOOSMALL");
2100
+        }
2084 2101
     }
2085 2102
 
2086 2103
     return retcode;
... ...
@@ -51,6 +51,18 @@
51 51
 #define OOXML_JSON_RECLEVEL_MAX 5
52 52
 #define OOXML_JSON_STRLEN_MAX 100
53 53
 
54
+#define check_state(state)                                              \
55
+    do {                                                                \
56
+        if (state == -1) {                                              \
57
+            cli_warnmsg("check_state: CL_EPARSE @ ln%d\n", __LINE__);   \
58
+            return CL_EPARSE;                                           \
59
+        }                                                               \
60
+        else if (state == 0) {                                          \
61
+            cli_dbgmsg("check_state: CL_BREAK @ ln%d\n", __LINE__);     \
62
+            return CL_BREAK;                                            \
63
+        }                                                               \
64
+    } while(0)
65
+
54 66
 static int ooxml_is_int(const char *value, size_t len, int32_t *val)
55 67
 {
56 68
     long val2;
... ...
@@ -214,22 +226,25 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
214 214
     const char *element_tag = NULL, *end_tag = NULL;
215 215
     const xmlChar *node_name = NULL, *node_value = NULL;
216 216
     json_object *thisjobj = NULL;
217
-    int node_type, ret = CL_SUCCESS, endtag = 0, toval = 0;
217
+    int node_type, ret = CL_SUCCESS, endtag = 0, toval = 0, state = 1;
218 218
 
219 219
     cli_dbgmsg("in ooxml_parse_element @ layer %d\n", rlvl);
220 220
 
221 221
     /* check recursion level */
222 222
     if (rlvl >= OOXML_JSON_RECLEVEL_MAX) {
223 223
         cli_dbgmsg("ooxml_parse_element: reached ooxml json recursion limit\n");
224
-        /* skip it */
225
-        xmlTextReaderNext(reader);
226
-        //return CL_EMAXREC;
227 224
         cli_jsonbool(root, "HitRecursiveLimit", 1);
225
+        /* skip it */
226
+        state = xmlTextReaderNext(reader);
227
+        check_state(state);
228 228
         return CL_SUCCESS;
229 229
     }
230 230
 
231 231
     /* acquire element type */
232 232
     node_type = xmlTextReaderNodeType(reader);
233
+    if (node_type == -1)
234
+        return CL_EPARSE;
235
+
233 236
     if (node_type != XML_READER_TYPE_ELEMENT) {
234 237
         cli_dbgmsg("ooxml_parse_element: first node typed %d, not %d\n", node_type, XML_READER_TYPE_ELEMENT);
235 238
         return CL_EPARSE; /* first type is not an element */
... ...
@@ -244,7 +259,8 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
244 244
     if (!element_tag) {
245 245
         cli_dbgmsg("ooxml_parse_element: invalid element tag [%s]\n", node_name);
246 246
         /* skip it */
247
-        xmlTextReaderNext(reader);
247
+        state = xmlTextReaderNext(reader);
248
+        check_state(state);
248 249
         return CL_SUCCESS;
249 250
     }
250 251
 
... ...
@@ -259,7 +275,8 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
259 259
         root = thisjobj;
260 260
 
261 261
     /* handle attributes */
262
-    if (xmlTextReaderHasAttributes(reader) == 1) {
262
+    state = xmlTextReaderHasAttributes(reader);
263
+    if (state == 1) {
263 264
         json_object *attributes;
264 265
 
265 266
         attributes = cli_jsonobj(thisjobj, "Attributes");
... ...
@@ -279,15 +296,21 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
279 279
             cli_jsonstr(attributes, name, (const char *)value);
280 280
         }
281 281
     }
282
+    else if (state == -1)
283
+        return CL_EPARSE;
282 284
 
283
-    if (xmlTextReaderIsEmptyElement(reader)) {
284
-        xmlTextReaderNext(reader);
285
+    state = xmlTextReaderIsEmptyElement(reader);
286
+    if (state == 1) {
287
+        state = xmlTextReaderNext(reader);
288
+        check_state(state);
285 289
         return CL_SUCCESS;
286 290
     }
291
+    else if (state == -1)
292
+        return CL_EPARSE;
287 293
 
288 294
     /* advance to first content node */
289
-    if (xmlTextReaderRead(reader) != 1)
290
-        return CL_EPARSE;
295
+    state = xmlTextReaderRead(reader);
296
+    check_state(state);
291 297
 
292 298
     /* parse until the end element tag */
293 299
     while (!endtag) {
... ...
@@ -296,6 +319,9 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
296 296
         }
297 297
 
298 298
         node_type = xmlTextReaderNodeType(reader);
299
+        if (node_type == -1)
300
+            return CL_EPARSE;
301
+
299 302
         switch (node_type) {
300 303
         case XML_READER_TYPE_ELEMENT:
301 304
             ret = ooxml_parse_element(ctx, reader, thisjobj, rlvl+1, root);
... ...
@@ -323,8 +349,8 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
323 323
             }
324 324
 
325 325
             /* advance to next element tag */
326
-            if (xmlTextReaderRead(reader) != 1)
327
-                return CL_EPARSE;
326
+            state = xmlTextReaderRead(reader);
327
+            check_state(state);
328 328
 
329 329
             endtag = 1;
330 330
             break;
... ...
@@ -339,8 +365,8 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
339 339
             cli_dbgmsg("ooxml_parse_element: added json value [%s: %s]\n", element_tag, node_value);
340 340
 
341 341
             /* advance to next element tag */
342
-            if (xmlTextReaderRead(reader) != 1)
343
-                return CL_EPARSE;
342
+            state = xmlTextReaderRead(reader);
343
+            check_state(state);
344 344
 
345 345
             break;
346 346
 
... ...
@@ -351,7 +377,8 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
351 351
 
352 352
             cli_dbgmsg("ooxml_parse_element: unhandled xml node %s [%d]: %s\n", node_name, node_type, node_value);
353 353
 #endif
354
-            xmlTextReaderNext(reader);
354
+            state = xmlTextReaderNext(reader);
355
+            check_state(state);
355 356
             return CL_SUCCESS;
356 357
         }
357 358
     }
... ...
@@ -366,7 +393,7 @@ static int ooxml_parse_document(int fd, cli_ctx *ctx)
366 366
 
367 367
     cli_dbgmsg("in ooxml_parse_document\n");
368 368
 
369
-    reader = xmlReaderForFd(fd, "properties.xml", NULL, 0);
369
+    reader = xmlReaderForFd(fd, "properties.xml", NULL, CLAMAV_MIN_XMLREADER_FLAGS);
370 370
     if (reader == NULL) {
371 371
         cli_dbgmsg("ooxml_parse_document: xmlReaderForFd error\n");
372 372
         return CL_SUCCESS; // internal error from libxml2
... ...
@@ -379,8 +406,10 @@ static int ooxml_parse_document(int fd, cli_ctx *ctx)
379 379
 
380 380
     ret = ooxml_parse_element(ctx, reader, ctx->wrkproperty, 0, NULL);
381 381
 
382
-    if (ret != CL_SUCCESS && ret != CL_ETIMEOUT)
382
+    if (ret != CL_SUCCESS && ret != CL_ETIMEOUT && ret != CL_BREAK) {
383
+        cli_warnmsg("ooxml_parse_document: encountered issue in parsing properties document\n");
383 384
         cli_jsonbool(ctx->wrkproperty, "ParseError", 1);
385
+    }
384 386
 
385 387
     xmlTextReaderClose(reader);
386 388
     xmlFreeTextReader(reader);
... ...
@@ -412,7 +441,7 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
412 412
 
413 413
     cli_dbgmsg("in ooxml_content_cb\n");
414 414
 
415
-    reader = xmlReaderForFd(fd, "[Content_Types].xml", NULL, 0);
415
+    reader = xmlReaderForFd(fd, "[Content_Types].xml", NULL, CLAMAV_MIN_XMLREADER_FLAGS);
416 416
     if (reader == NULL) {
417 417
         cli_dbgmsg("ooxml_content_cb: xmlReaderForFd error for ""[Content_Types].xml""\n");
418 418
         return CL_SUCCESS; // libxml2 failed!
... ...
@@ -430,7 +459,7 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
430 430
 
431 431
         if (strcmp((const char *)name, "Override")) continue;
432 432
 
433
-        if (!xmlTextReaderHasAttributes(reader)) continue;
433
+        if (xmlTextReaderHasAttributes(reader) != 1) continue;
434 434
 
435 435
         CT = PN = NULL;
436 436
         while (xmlTextReaderMoveToNextAttribute(reader) == 1) {
... ...
@@ -453,7 +482,7 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
453 453
         if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-package.core-properties+xml")) {
454 454
             if (!core) {
455 455
                 /* default: /docProps/core.xml*/
456
-                tmp = unzip_search(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
456
+                tmp = unzip_search_single(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
457 457
                 if (tmp == CL_ETIMEOUT) {
458 458
                     ret = tmp;
459 459
                 }
... ...
@@ -471,7 +500,7 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
471 471
         else if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-officedocument.extended-properties+xml")) {
472 472
             if (!extn) {
473 473
                 /* default: /docProps/app.xml */
474
-                tmp = unzip_search(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
474
+                tmp = unzip_search_single(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
475 475
                 if (tmp == CL_ETIMEOUT) {
476 476
                     ret = tmp;
477 477
                 }
... ...
@@ -489,7 +518,7 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
489 489
         else if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-officedocument.custom-properties+xml")) {
490 490
             if (!cust) {
491 491
                 /* default: /docProps/custom.xml */
492
-                tmp = unzip_search(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
492
+                tmp = unzip_search_single(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
493 493
                 if (tmp == CL_ETIMEOUT) {
494 494
                     ret = tmp;
495 495
                 }
... ...
@@ -508,10 +537,11 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
508 508
             dsig++;
509 509
         }
510 510
 
511
-        if (ret != CL_SUCCESS)
511
+        if (ret != CL_BREAK && ret != CL_SUCCESS)
512 512
             goto ooxml_content_exit;
513 513
     }
514 514
 
515
+ ooxml_content_exit:
515 516
     if (core)
516 517
         cli_jsonint(ctx->wrkproperty, "CorePropertiesFileCount", core);
517 518
     else if (!mcore)
... ...
@@ -537,13 +567,45 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
537 537
         cli_jsonint(ctx->wrkproperty, "DigitalSignaturesCount", dsig);
538 538
     }
539 539
 
540
- ooxml_content_exit:
541 540
     xmlTextReaderClose(reader);
542 541
     xmlFreeTextReader(reader);
543 542
     return ret;
544 543
 }
545 544
 #endif /* HAVE_LIBXML2 && HAVE_JSON */
546 545
 
546
+int cli_ooxml_filetype(cli_ctx *ctx, fmap_t *map)
547
+{
548
+    struct zip_requests requests;
549
+    int ret;
550
+
551
+    memset(&requests, 0, sizeof(struct zip_requests));
552
+
553
+    if ((ret = unzip_search_add(&requests, "xl/", 3)) != CL_SUCCESS) {
554
+        return CL_SUCCESS;
555
+    }
556
+    if ((ret = unzip_search_add(&requests, "ppt/", 4)) != CL_SUCCESS) {
557
+        return CL_SUCCESS;
558
+    }
559
+    if ((ret = unzip_search_add(&requests, "word/", 5)) != CL_SUCCESS) {
560
+        return CL_SUCCESS;
561
+    }
562
+
563
+    if ((ret = unzip_search(ctx, map, &requests)) == CL_VIRUS) {
564
+        switch (requests.found) {
565
+        case 0:
566
+            return CL_TYPE_OOXML_XL;
567
+        case 1:
568
+            return CL_TYPE_OOXML_PPT;
569
+        case 2:
570
+            return CL_TYPE_OOXML_WORD;
571
+        default:
572
+            return CL_SUCCESS;
573
+        }
574
+    }
575
+
576
+    return CL_SUCCESS;
577
+}
578
+
547 579
 int cli_process_ooxml(cli_ctx *ctx)
548 580
 {
549 581
 #if HAVE_LIBXML2 && HAVE_JSON
... ...
@@ -556,7 +618,7 @@ int cli_process_ooxml(cli_ctx *ctx)
556 556
     }
557 557
 
558 558
     /* find "[Content Types].xml" */
559
-    tmp = unzip_search(ctx, "[Content_Types].xml", 18, &loff);
559
+    tmp = unzip_search_single(ctx, "[Content_Types].xml", 18, &loff);
560 560
     if (tmp == CL_ETIMEOUT) {
561 561
         return CL_ETIMEOUT;
562 562
     }
... ...
@@ -26,6 +26,7 @@
26 26
 #endif
27 27
 
28 28
 #include "others.h"
29
+int cli_ooxml_filetype(cli_ctx *, fmap_t *);
29 30
 int cli_process_ooxml(cli_ctx *);
30 31
 
31 32
 #endif
... ...
@@ -197,7 +197,7 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine, unsigned
197 197
 
198 198
     cli_dbgmsg("openioc_parse: XML parsing file %s\n", fname);
199 199
 
200
-    reader = xmlReaderForFd(fd, NULL, NULL, 0);
200
+    reader = xmlReaderForFd(fd, NULL, NULL, CLAMAV_MIN_XMLREADER_FLAGS);
201 201
     if (reader == NULL) {
202 202
         cli_dbgmsg("openioc_parse: xmlReaderForFd error\n");
203 203
         return CL_EOPEN;
... ...
@@ -54,6 +54,10 @@
54 54
 #include "json.h"
55 55
 #endif
56 56
 
57
+#if HAVE_LIBXML2
58
+#define CLAMAV_MIN_XMLREADER_FLAGS (XML_PARSE_NOERROR | XML_PARSE_NONET)
59
+#endif
60
+
57 61
 /*
58 62
  * CL_FLEVEL is the signature f-level specific to the current code and
59 63
  *	     should never be modified
... ...
@@ -2183,6 +2183,7 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O,
2183 2183
             dbg_printhex("computed U (R>=3)", (const char *)result, 16);
2184 2184
             if (!memcmp(result, U, 16))
2185 2185
                 password_empty = 1;
2186
+            free(d);
2186 2187
         } else {
2187 2188
             cli_dbgmsg("cli_pdf: invalid revision %d\n", R);
2188 2189
             noisy_warnmsg("cli_pdf: invalid revision %d\n", R);
... ...
@@ -107,7 +107,7 @@ char *pdf_convert_utf(char *begin, size_t sz)
107 107
             continue;
108 108
         }
109 109
 
110
-        iconv(cd, (const char **)(&p1), &inlen, &p2, &outlen);
110
+        iconv(cd, (char **)(&p1), &inlen, &p2, &outlen);
111 111
 
112 112
         if (outlen == sz) {
113 113
             /* Decoding unsuccessful right from the start */
... ...
@@ -229,6 +229,7 @@ char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char *
229 229
     char *res;
230 230
     int likelyutf = 0;
231 231
     uint32_t objid;
232
+    size_t i;
232 233
 
233 234
     /*
234 235
      * Yes, all of this is required to find the start and end of a potentially UTF-* string
... ...
@@ -324,7 +325,7 @@ char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char *
324 324
         }
325 325
 
326 326
         if (sb.st_size) {
327
-            begin = calloc(1, sb.st_size);
327
+            begin = calloc(1, sb.st_size+1);
328 328
             if (!(begin)) {
329 329
                 close(fd);
330 330
                 cli_unlink(newobj->path);
... ...
@@ -349,11 +350,21 @@ char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char *
349 349
                     free(begin);
350 350
                     break;
351 351
                 default:
352
-                    res = pdf_convert_utf(begin, sb.st_size);
353
-                    if (!(res))
352
+                    for (i=0; i < sb.st_size; i++) {
353
+                        if (begin[i] >= 0x7f) {
354
+                            likelyutf=1;
355
+                            break;
356
+                        }
357
+                    }
358
+
359
+                    res = likelyutf ? pdf_convert_utf(begin, sb.st_size) : NULL;
360
+
361
+                    if (!(res)) {
354 362
                         res = begin;
355
-                    else
363
+                        res[sb.st_size] = '\0';
364
+                    } else {
356 365
                         free(begin);
366
+                    }
357 367
             }
358 368
         }
359 369
 
... ...
@@ -2596,6 +2596,7 @@ static int magic_scandesc(cli_ctx *ctx, cli_file_t type)
2596 2596
             if (type == CL_TYPE_PDF ||   /* file types we collect properties about */
2597 2597
                 type == CL_TYPE_MSOLE2 ||
2598 2598
                 type == CL_TYPE_MSEXE ||
2599
+                //type == CL_TYPE_ZIP ||
2599 2600
                 type == CL_TYPE_OOXML_WORD ||
2600 2601
                 type == CL_TYPE_OOXML_PPT ||
2601 2602
                 type == CL_TYPE_OOXML_XL) { 
... ...
@@ -166,7 +166,7 @@ cli_tnef(const char *dir, cli_ctx *ctx)
166 166
 					if(fout >= 0) {
167 167
 						int count;
168 168
 
169
-						cli_warnmsg("Saving dump to %s:  refer to http://www.clamav.net/bugs\n", filename);
169
+						cli_warnmsg("Saving dump to %s:  refer to http://www.clamav.net/documentation.html\n", filename);
170 170
 
171 171
 						pos = 0;
172 172
 						while ((count = fmap_readn(*ctx->fmap, buffer, pos, sizeof(buffer))) > 0) {
... ...
@@ -53,14 +53,6 @@
53 53
 #define UNZIP_PRIVATE
54 54
 #include "unzip.h"
55 55
 
56
-typedef struct zip_request {
57
-    const char *name;
58
-    size_t namelen;
59
-    uint32_t loff;
60
-
61
-    int found;
62
-} zip_request_t;
63
-
64 56
 static int wrap_inflateinit2(void *a, int b) {
65 57
   return inflateInit2(a, b);
66 58
 }
... ...
@@ -427,7 +419,7 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int
427 427
   return zip-lh;
428 428
 }
429 429
 
430
-static unsigned int chdr(fmap_t *map, uint32_t coff, uint32_t zsize, unsigned int *fu, unsigned int fc, int *ret, cli_ctx *ctx, char *tmpd, zip_request_t *request) {
430
+static unsigned int chdr(fmap_t *map, uint32_t coff, uint32_t zsize, unsigned int *fu, unsigned int fc, int *ret, cli_ctx *ctx, char *tmpd, struct zip_requests *requests) {
431 431
   char name[256];
432 432
   int last = 0;
433 433
   const uint8_t *ch;
... ...
@@ -447,7 +439,7 @@ static unsigned int chdr(fmap_t *map, uint32_t coff, uint32_t zsize, unsigned in
447 447
   }
448 448
 
449 449
   name[0]='\0';
450
-  if((cli_debug_flag && !last) || request) {
450
+  if((cli_debug_flag && !last) || requests) {
451 451
       unsigned int size = (CH_flen>=sizeof(name))?sizeof(name)-1:CH_flen;
452 452
       const char *src = fmap_need_off_once(map, coff, size);
453 453
       if(src) {
... ...
@@ -470,16 +462,26 @@ static unsigned int chdr(fmap_t *map, uint32_t coff, uint32_t zsize, unsigned in
470 470
   }
471 471
   coff+=CH_clen;
472 472
 
473
-  if (!request) {
473
+  if (!requests) {
474 474
       if(CH_off<zsize-SIZEOF_LH) {
475 475
           lhdr(map, CH_off, zsize-CH_off, fu, fc, ch, ret, ctx, tmpd, 1, zip_scan_cb);
476 476
       } else cli_dbgmsg("cli_unzip: ch - local hdr out of file\n");
477 477
   }
478 478
   else {
479
-      size_t len = MIN(sizeof(name)-1, request->namelen);
480
-      if (!last && !strncmp(request->name, name, len)) {
481
-          request->found = 1;
482
-          request->loff = CH_off;
479
+      int i;
480
+      size_t len;
481
+
482
+      if (!last) {
483
+          for (i = 0; i < requests->namecnt; ++i) {
484
+              cli_dbgmsg("checking for %i: %s\n", i, requests->names[i]);
485
+
486
+              len = MIN(sizeof(name)-1, requests->namelens[i]);      
487
+              if (!strncmp(requests->names[i], name, len)) {
488
+                  requests->match = 1;
489
+                  requests->found = i;
490
+                  requests->loff = CH_off;
491
+              }
492
+          }
483 493
       }
484 494
   }
485 495
 
... ...
@@ -603,27 +605,46 @@ int cli_unzip_single(cli_ctx *ctx, off_t lhoffl) {
603 603
     return unzip_single_internal(ctx, lhoffl, zip_scan_cb);
604 604
 }
605 605
 
606
-int unzip_search(cli_ctx *ctx, const char *name, size_t nlen, uint32_t *loff)
606
+int unzip_search_add(struct zip_requests *requests, const char *name, size_t nlen)
607
+{
608
+    cli_dbgmsg("in unzip_search_add\n");
609
+
610
+    if (requests->namecnt >= MAX_ZIP_REQUESTS) {
611
+        cli_dbgmsg("DEBUGGING MESSAGE GOES HERE!\n");
612
+        return CL_BREAK;
613
+    }
614
+
615
+    cli_dbgmsg("unzip_search_add: adding %s (len %llu)\n", name, (long long unsigned)nlen);
616
+
617
+    requests->names[requests->namecnt] = name;
618
+    requests->namelens[requests->namecnt] = nlen;
619
+    requests->namecnt++;
620
+
621
+    return CL_SUCCESS;
622
+}
623
+
624
+int unzip_search(cli_ctx *ctx, fmap_t *map, struct zip_requests *requests)
607 625
 {
608 626
     unsigned int fc = 0;
609
-    fmap_t *map;
627
+    fmap_t *zmap = map;
610 628
     size_t fsize;
611 629
     uint32_t coff = 0;
612 630
     const char *ptr;
613
-    zip_request_t request; 
614 631
     int ret = CL_CLEAN;
615 632
 #if HAVE_JSON
616 633
     uint32_t toval = 0;
617 634
 #endif
618
-
619 635
     cli_dbgmsg("in unzip_search\n");
620
-    if (!ctx) {
636
+
637
+    if ((!ctx && !map) || !requests) {
621 638
         return CL_ENULLARG;
622 639
     }
623 640
 
624
-    map = *ctx->fmap;
625
-    fsize = map->len;
626
-    if(sizeof(off_t)!=sizeof(uint32_t) && fsize!=map->len) {
641
+    /* get priority to given map over *ctx->fmap */
642
+    if (ctx && !map)
643
+        zmap = *ctx->fmap;
644
+    fsize = zmap->len;
645
+    if(sizeof(off_t)!=sizeof(uint32_t) && fsize!=zmap->len) {
627 646
         cli_dbgmsg("unzip_search: file too big\n");
628 647
         return CL_CLEAN;
629 648
     }
... ...
@@ -633,7 +654,7 @@ int unzip_search(cli_ctx *ctx, const char *name, size_t nlen, uint32_t *loff)
633 633
     }
634 634
 
635 635
     for(coff=fsize-22 ; coff>0 ; coff--) { /* sizeof(EOC)==22 */
636
-        if(!(ptr = fmap_need_off_once(map, coff, 20)))
636
+        if(!(ptr = fmap_need_off_once(zmap, coff, 20)))
637 637
             continue;
638 638
         if(cli_readint32(ptr)==0x06054b50) {
639 639
             uint32_t chptr = cli_readint32(&ptr[16]);
... ...
@@ -643,25 +664,20 @@ int unzip_search(cli_ctx *ctx, const char *name, size_t nlen, uint32_t *loff)
643 643
         }
644 644
     }
645 645
 
646
-    request.name = name;
647
-    request.namelen = nlen;
648
-    request.found = 0;
649
-
650 646
     if(coff) {
651 647
         cli_dbgmsg("unzip_search: central @%x\n", coff);
652
-        while(ret==CL_CLEAN && (coff=chdr(map, coff, fsize, NULL, fc+1, &ret, ctx, NULL, &request))) {
653
-            if (request.found) {
654
-                *loff = request.loff;
648
+        while(ret==CL_CLEAN && (coff=chdr(zmap, coff, fsize, NULL, fc+1, &ret, ctx, NULL, requests))) {
649
+            if (requests->match) {
655 650
                 return CL_VIRUS;
656 651
             }
657 652
 
658 653
             fc++;
659
-            if (ctx->engine->maxfiles && fc >= ctx->engine->maxfiles) {
654
+            if (ctx && ctx->engine->maxfiles && fc >= ctx->engine->maxfiles) {
660 655
                 cli_dbgmsg("cli_unzip: Files limit reached (max: %u)\n", ctx->engine->maxfiles);
661 656
                 ret=CL_EMAXFILES;
662 657
             }
663 658
 #if HAVE_JSON
664
-            if (cli_json_timeout_cycle_check(ctx, (int *)(&toval)) != CL_SUCCESS) {
659
+            if (ctx && cli_json_timeout_cycle_check(ctx, (int *)(&toval)) != CL_SUCCESS) {
665 660
                 return CL_ETIMEOUT;
666 661
             }
667 662
 #endif
... ...
@@ -673,3 +689,26 @@ int unzip_search(cli_ctx *ctx, const char *name, size_t nlen, uint32_t *loff)
673 673
     return ret;
674 674
 }
675 675
 
676
+int unzip_search_single(cli_ctx *ctx, const char *name, size_t nlen, uint32_t *loff)
677
+{
678
+    struct zip_requests requests;
679
+    int ret;
680
+
681
+    cli_dbgmsg("in unzip_search_single\n");
682
+    if (!ctx) {
683
+        return CL_ENULLARG;
684
+    }
685
+
686
+    memset(&requests, 0, sizeof(struct zip_requests));
687
+
688
+    if ((ret = unzip_search_add(&requests, name, nlen)) != CL_SUCCESS) {
689
+        return ret;
690
+    }
691
+
692
+    if ((ret = unzip_search(ctx, NULL, &requests)) == CL_VIRUS) {
693
+        *loff = requests.loff;
694
+    }
695
+
696
+    return ret;
697
+}
698
+
... ...
@@ -25,15 +25,30 @@
25 25
 #include "clamav-config.h"
26 26
 #endif
27 27
 
28
+#include "others.h"
29
+
28 30
 typedef int (*zip_cb)(int fd, cli_ctx *ctx);
29 31
 #define zip_scan_cb cli_magic_scandesc
30 32
 
31
-#include "others.h"
33
+#define MAX_ZIP_REQUESTS 10
34
+struct zip_requests {
35
+    const char *names[MAX_ZIP_REQUESTS];
36
+    size_t namelens[MAX_ZIP_REQUESTS];
37
+    int namecnt;
38
+
39
+    uint32_t loff;
40
+    int found, match;
41
+};
42
+
32 43
 int cli_unzip(cli_ctx *);
33 44
 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);
45
+int unzip_single_internal(cli_ctx *, off_t, zip_cb);
35 46
 int cli_unzip_single(cli_ctx *, off_t);
36
-int unzip_search(cli_ctx *, const char *, size_t, uint32_t *);
47
+
48
+int unzip_search_add(struct zip_requests *, const char *, size_t);
49
+int unzip_search(cli_ctx *, fmap_t *, struct zip_requests *);
50
+int unzip_search_single(cli_ctx *, const char *, size_t, uint32_t *);
51
+
37 52
 
38 53
 #ifdef UNZIP_PRIVATE
39 54
 #define F_ENCR  (1<<0)
... ...
@@ -422,6 +422,8 @@ int cli_scanxar(cli_ctx *ctx)
422 422
     xmlTextReaderPtr reader = NULL;
423 423
     int a_hash, e_hash;
424 424
     unsigned char *a_cksum = NULL, *e_cksum = NULL;
425
+    void *a_hash_ctx = NULL, *e_hash_ctx = NULL;
426
+    char result[SHA1_HASH_SIZE];
425 427
 
426 428
     memset(&strm, 0x00, sizeof(z_stream));
427 429
 
... ...
@@ -516,7 +518,7 @@ int cli_scanxar(cli_ctx *ctx)
516 516
             goto exit_toc;
517 517
     }
518 518
 
519
-    reader = xmlReaderForMemory(toc, hdr.toc_length_decompressed, "noname.xml", NULL, 0);
519
+    reader = xmlReaderForMemory(toc, hdr.toc_length_decompressed, "noname.xml", NULL, CLAMAV_MIN_XMLREADER_FLAGS);
520 520
     if (reader == NULL) {
521 521
         cli_dbgmsg("cli_scanxar: xmlReaderForMemory error for TOC\n");
522 522
         goto exit_toc;
... ...
@@ -537,8 +539,6 @@ int cli_scanxar(cli_ctx *ctx)
537 537
         unsigned char * blockp;
538 538
         void *a_sc, *e_sc;
539 539
         void *a_mc, *e_mc;
540
-        void *a_hash_ctx, *e_hash_ctx;
541
-        char result[SHA1_HASH_SIZE];
542 540
         char * expected;
543 541
 
544 542
         /* clean up temp file from previous loop iteration */
... ...
@@ -561,7 +561,11 @@ int cli_scanxar(cli_ctx *ctx)
561 561
 
562 562
 
563 563
         a_hash_ctx = xar_hash_init(a_hash, &a_sc, &a_mc);
564
+        if (a_hash_ctx == NULL)
565
+            goto exit_tmpfile;
564 566
         e_hash_ctx = xar_hash_init(e_hash, &e_sc, &e_mc);
567
+        if (e_hash_ctx == NULL)
568
+            goto exit_tmpfile;
565 569
 
566 570
         switch (encoding) {
567 571
         case CL_TYPE_GZ:
... ...
@@ -779,6 +783,7 @@ int cli_scanxar(cli_ctx *ctx)
779 779
 
780 780
         if (rc == CL_SUCCESS) {
781 781
             xar_hash_final(a_hash_ctx, result, a_hash);
782
+            a_hash_ctx = NULL;
782 783
             if (a_cksum != NULL) {
783 784
                 expected = cli_hex2str((char *)a_cksum);
784 785
                 if (xar_hash_check(a_hash, result, expected) != 0) {
... ...
@@ -789,9 +794,10 @@ int cli_scanxar(cli_ctx *ctx)
789 789
                 }
790 790
                 free(expected);
791 791
             }
792
+            xar_hash_final(e_hash_ctx, result, e_hash);
793
+            e_hash_ctx = NULL;
792 794
             if (e_cksum != NULL) {
793 795
                 if (do_extract_cksum) {
794
-                    xar_hash_final(e_hash_ctx, result, e_hash);
795 796
                     expected = cli_hex2str((char *)e_cksum);
796 797
                     if (xar_hash_check(e_hash, result, expected) != 0) {
797 798
                         cli_dbgmsg("cli_scanxar: extracted-checksum missing or mismatch.\n");
... ...
@@ -828,7 +834,11 @@ int cli_scanxar(cli_ctx *ctx)
828 828
 
829 829
  exit_tmpfile:
830 830
     xar_cleanup_temp_file(ctx, fd, tmpname);
831
-
831
+    if (a_hash_ctx != NULL)
832
+        xar_hash_final(a_hash_ctx, result, a_hash);
833
+    if (e_hash_ctx != NULL)
834
+        xar_hash_final(e_hash_ctx, result, e_hash);
835
+ 
832 836
  exit_reader:
833 837
     if (a_cksum != NULL)
834 838
         xmlFree(a_cksum);   
... ...
@@ -58,8 +58,12 @@
58 58
 #include "scanners.h"
59 59
 #include "conv.h"
60 60
 #include "xdp.h"
61
+#include "bignum_fast.h"
62
+#include "filetypes.h"
61 63
 
62
-char *dump_xdp(cli_ctx *ctx, const char *start, size_t sz)
64
+static char *dump_xdp(cli_ctx *ctx, const char *start, size_t sz);
65
+
66
+static char *dump_xdp(cli_ctx *ctx, const char *start, size_t sz)
63 67
 {
64 68
     int fd;
65 69
     char *filename;
... ...
@@ -102,8 +106,8 @@ int cli_scanxdp(cli_ctx *ctx)
102 102
     char *decoded;
103 103
     size_t decodedlen;
104 104
     int rc = CL_SUCCESS;
105
-    int fd;
106 105
     char *dumpname;
106
+    size_t i;
107 107
     
108 108
     buf = (const char *)fmap_need_off_once(map, map->offset, map->len);
109 109
     if (!(buf))
... ...
@@ -122,7 +126,7 @@ int cli_scanxdp(cli_ctx *ctx)
122 122
      * silently ignore the error and return CL_SUCCESS so the filetyping code can
123 123
      * continue on.
124 124
      */
125
-    reader = xmlReaderForMemory(buf, (int)(map->len), "noname.xml", NULL, XML_PARSE_NOERROR);
125
+    reader = xmlReaderForMemory(buf, (int)(map->len), "noname.xml", NULL, CLAMAV_MIN_XMLREADER_FLAGS);
126 126
     if (!(reader))
127 127
         return CL_SUCCESS;
128 128
 
... ...
@@ -136,14 +140,41 @@ int cli_scanxdp(cli_ctx *ctx)
136 136
             if (value) {
137 137
                 decoded = cl_base64_decode((char *)value, strlen((const char *)value), NULL, &decodedlen, 0);
138 138
                 if (decoded) {
139
+                    unsigned int shouldscan=0;
140
+
141
+                    if (decodedlen > 5) {
142
+                        for (i=0; i < MIN(MAGIC_BUFFER_SIZE, decodedlen-5); i++) {
143
+                            if (decoded[i] != '%')
144
+                                continue;
145
+
146
+                            if (decoded[i+1] == 'P' || decoded[i+1] == 'p') {
147
+                                if (decoded[i+2] == 'D' || decoded[i+2] == 'd') {
148
+                                    if (decoded[i+3] == 'F' || decoded[i+3] == 'f') {
149
+                                        if (decoded[i+4] == '-') {
150
+                                            shouldscan=1;
151
+                                            break;
152
+                                        }
153
+                                    }
154
+                                }
155
+                            }
156
+                        }
157
+                    }
158
+
159
+                    if (!shouldscan) {
160
+                        free(decoded);
161
+                        xmlFree((void *)value);
162
+                        break;
163
+                    }
164
+
139 165
                     rc = cli_mem_scandesc(decoded, decodedlen, ctx);
140 166
                     free(decoded);
141 167
                     if (rc != CL_SUCCESS || rc == CL_BREAK) {
142
-                        xmlFree(value);
168
+                        xmlFree((void *)value);
143 169
                         break;
144 170
                     }
145 171
                 }
146
-                xmlFree(value);
172
+
173
+                xmlFree((void *)value);
147 174
             }
148 175
         }
149 176
     }
... ...
@@ -31,7 +31,6 @@
31 31
 #include <stdlib.h>
32 32
 #include <string.h>
33 33
 
34
-#include "libclamav/clamav.h"
35 34
 #include "libclamunrar/unrar.h"
36 35
 #include "libclamunrar/unrarppm.h"
37 36
 #include "libclamunrar/unrarvm.h"
... ...
@@ -44,7 +43,7 @@
44 44
 #ifdef RAR_HIGH_DEBUG
45 45
 #define rar_dbgmsg printf
46 46
 #else
47
-static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); }
47
+static void rar_dbgmsg(const char* fmt,...){}
48 48
 #endif
49 49
 
50 50
 static void insert_old_dist(unpack_data_t *unpack_data, unsigned int distance)
... ...
@@ -124,7 +123,7 @@ int rar_unp_read_buf(int fd, unpack_data_t *unpack_data)
124 124
 		data_size = unpack_data->read_top;
125 125
 	}
126 126
 	/* RAR2 depends on us only reading upto the end of the current compressed file */
127
-	if (unpack_data->pack_size < (unsigned int)(((MAX_BUF_SIZE-data_size)&~0xf))) {
127
+	if (unpack_data->pack_size < ((MAX_BUF_SIZE-data_size)&~0xf)) {
128 128
 		read_size = unpack_data->pack_size;
129 129
 	} else {
130 130
 		read_size = (MAX_BUF_SIZE-data_size)&~0xf;
... ...
@@ -219,7 +218,7 @@ static void unp_write_buf(unpack_data_t *unpack_data)
219 219
 	struct UnpackFilter *flt, *next_filter;
220 220
 	struct rarvm_prepared_program *prg, *next_prg;
221 221
 	uint8_t *filtered_data;
222
-	size_t i, j;
222
+	int i, j;
223 223
 	
224 224
 	rar_dbgmsg("in unp_write_buf\n");
225 225
 	written_border = unpack_data->wr_ptr;
... ...
@@ -396,9 +395,8 @@ static int read_tables(int fd, unpack_data_t *unpack_data)
396 396
 	uint8_t bit_length[BC];
397 397
 	unsigned char table[HUFF_TABLE_SIZE];
398 398
 	unsigned int bit_field;
399
-	int length, zero_count, number, n;
399
+	int i, length, zero_count, number, n;
400 400
 	const int table_size=HUFF_TABLE_SIZE;
401
-    unsigned int i;
402 401
 	
403 402
 	rar_dbgmsg("in read_tables Offset=%ld in_addr=%d read_top=%d\n", lseek(fd, 0, SEEK_CUR),
404 403
 				unpack_data->in_addr, unpack_data->read_top);
... ...
@@ -471,8 +469,7 @@ static int read_tables(int fd, unpack_data_t *unpack_data)
471 471
 				rar_addbits(unpack_data, 7);
472 472
 			}
473 473
 			while (n-- > 0 && i < table_size) {
474
-                if (i>0)
475
-                    table[i] = table[i-1];
474
+				table[i] = table[i-1];
476 475
 				i++;
477 476
 			}
478 477
 		} else {
... ...
@@ -542,11 +539,10 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte,
542 542
 			unsigned char *vmcode, int code_size)
543 543
 {
544 544
 	rarvm_input_t rarvm_input;
545
-	unsigned int filter_pos, new_filter, block_start, init_mask, cur_size, data_size;
545
+	unsigned int filter_pos, new_filter, block_start, init_mask, cur_size;
546 546
 	struct UnpackFilter *filter, *stack_filter;
547
-	int empty_count, stack_pos, vm_codesize, static_size;
547
+	int i, empty_count, stack_pos, vm_codesize, static_size, data_size;
548 548
 	unsigned char *vm_code, *global_data;
549
-    size_t i;
550 549
 	
551 550
 	rar_dbgmsg("in add_vm_code first_byte=0x%x code_size=%d\n", first_byte, code_size);
552 551
 	rarvm_input.in_buf = vmcode;
... ...
@@ -566,7 +562,7 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte,
566 566
 	}
567 567
 	rar_dbgmsg("filter_pos = %u\n", filter_pos);
568 568
 	if (filter_pos > unpack_data->Filters.num_items ||
569
-			filter_pos > (unsigned int)(unpack_data->old_filter_lengths_size)) {
569
+			filter_pos > unpack_data->old_filter_lengths_size) {
570 570
 		rar_dbgmsg("filter_pos check failed\n");
571 571
 		return FALSE;
572 572
 	}
... ...
@@ -629,7 +625,7 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte,
629 629
 	if (first_byte & 0x20) {
630 630
 		stack_filter->block_length = rarvm_read_data(&rarvm_input);
631 631
 	} else {
632
-		stack_filter->block_length = filter_pos < (unsigned int)(unpack_data->old_filter_lengths_size) ?
632
+		stack_filter->block_length = filter_pos < unpack_data->old_filter_lengths_size ?
633 633
 				unpack_data->old_filter_lengths[filter_pos] : 0;
634 634
 	}
635 635
 	rar_dbgmsg("block_length=%u\n", stack_filter->block_length);
... ...
@@ -664,7 +660,7 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte,
664 664
 		    rar_dbgmsg("unrar: add_vm_code: rar_malloc failed for vm_code\n");
665 665
 		    return FALSE;
666 666
 		}
667
-		for (i=0 ; i < (size_t)vm_codesize ; i++) {
667
+		for (i=0 ; i < vm_codesize ; i++) {
668 668
 			vm_code[i] = rarvm_getbits(&rarvm_input) >> 8;
669 669
 			rarvm_addbits(&rarvm_input, 8);
670 670
 		}
... ...
@@ -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
-	unsigned int i;
125
+	int i;
126 126
 	
127
-	for (num&=0xfff0, i=0 ; dec_tab[i] <= (unsigned int)num ; i++) {
127
+	for (num&=0xfff0, i=0 ; dec_tab[i] <= num ; i++) {
128 128
 		start_pos++;
129 129
 	}
130 130
 	rar_addbits(unpack_data, start_pos);
... ...
@@ -19,14 +19,13 @@
19 19
 #include <stdio.h>
20 20
 #include <string.h>
21 21
 
22
-#include "libclamav/clamav.h"
23 22
 #include "libclamunrar/unrar.h"
24 23
 #include "libclamunrar/unrar20.h"
25 24
 
26 25
 #ifdef RAR_HIGH_DEBUG
27 26
 #define rar_dbgmsg printf
28 27
 #else
29
-static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); }
28
+static void rar_dbgmsg(const char* fmt,...){}
30 29
 #endif
31 30
 
32 31
 void unpack_init_data20(int solid, unpack_data_t *unpack_data)
... ...
@@ -33,7 +33,7 @@ void rar_filter_array_init(rar_filter_array_t *filter_a)
33 33
 
34 34
 void rar_filter_array_reset(rar_filter_array_t *filter_a)
35 35
 {
36
-	size_t i;
36
+	int i;
37 37
 	
38 38
 	if (!filter_a) {
39 39
 		return;
... ...
@@ -13,13 +13,12 @@
13 13
 #include <stdio.h>
14 14
 #include <stdlib.h>
15 15
 
16
-#include "libclamav/clamav.h"
17 16
 #include "libclamunrar/unrarhlp.h"
18 17
 
19 18
 #ifdef RAR_HIGH_DEBUG
20 19
 #define rar_dbgmsg printf
21 20
 #else
22
-static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); }
21
+static void rar_dbgmsg(const char* fmt,...){}
23 22
 #endif
24 23
 
25 24
 #define RAR_MAX_ALLOCATION 184549376
... ...
@@ -21,14 +21,13 @@
21 21
 #include <stdio.h>
22 22
 #include <string.h>
23 23
 
24
-#include "libclamav/clamav.h"
25 24
 #include "libclamunrar/unrar.h"
26 25
 #include "libclamunrar/unrarppm.h"
27 26
 
28 27
 #ifdef RAR_HIGH_DEBUG
29 28
 #define rar_dbgmsg printf
30 29
 #else
31
-static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); }
30
+static void rar_dbgmsg(const char* fmt,...){}
32 31
 #endif
33 32
 
34 33
 #define MAX_O 64
... ...
@@ -755,7 +754,7 @@ static void update1(ppm_data_t *ppm_data, struct state_tag *p, struct ppm_contex
755 755
 static int ppm_decode_symbol1(ppm_data_t *ppm_data, struct ppm_context *context)
756 756
 {
757 757
 	struct state_tag *p;
758
-	unsigned int i, hi_cnt, count;
758
+	int i, hi_cnt, count;
759 759
 	
760 760
 	rar_dbgmsg("in ppm_decode_symbol1\n");
761 761
 	ppm_data->coder.scale = context->con_ut.u.summ_freq;
... ...
@@ -868,7 +867,7 @@ static struct see2_context_tag *make_esc_freq(ppm_data_t *ppm_data,
868 868
 
869 869
 static int ppm_decode_symbol2(ppm_data_t *ppm_data, struct ppm_context *context)
870 870
 {
871
-	unsigned int count, hi_cnt, i;
871
+	int count, hi_cnt, i;
872 872
 	struct see2_context_tag *psee2c;
873 873
 	struct state_tag *ps[256], **pps, *p;
874 874
 	
... ...
@@ -22,7 +22,6 @@
22 22
 #include <stdio.h>
23 23
 #include <string.h>
24 24
 
25
-#include "libclamav/clamav.h"
26 25
 #include "libclamunrar/unrar.h"
27 26
 #include "libclamunrar/unrarvm.h"
28 27
 #include "libclamunrar/unrarcmd.h"
... ...
@@ -30,7 +29,7 @@
30 30
 #ifdef RAR_HIGH_DEBUG
31 31
 #define rar_dbgmsg printf
32 32
 #else
33
-static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); }
33
+static void rar_dbgmsg(const char* fmt,...){}
34 34
 #endif
35 35
 
36 36
 #define VMCF_OP0             0
... ...
@@ -156,7 +155,7 @@ const uint32_t crc_tab[256]={
156 156
 uint32_t rar_crc(uint32_t start_crc, void *addr, uint32_t size)
157 157
 {
158 158
 	unsigned char *data;
159
-	uint32_t i;
159
+	int i;
160 160
 
161 161
 	data = addr;
162 162
 #if WORDS_BIGENDIAN == 0
... ...
@@ -265,7 +264,7 @@ unsigned int rarvm_read_data(rarvm_input_t *rarvm_input)
265 265
 static rarvm_standard_filters_t is_standard_filter(unsigned char *code, int code_size)
266 266
 {
267 267
 	uint32_t code_crc;
268
-	uint32_t i;
268
+	int i;
269 269
 
270 270
 	struct standard_filter_signature
271 271
 	{
... ...
@@ -341,12 +340,11 @@ static void filter_itanium_setbits(unsigned char *data, unsigned int bit_field,
341 341
 static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_filters_t filter_type)
342 342
 {
343 343
 	unsigned char *data, cmp_byte2, cur_byte, *src_data, *dest_data;
344
-	int channels, border, width, PosR;
344
+	int i, j, data_size, channels, src_pos, dest_pos, border, width, PosR;
345 345
 	int op_type, cur_channel, byte_count, start_pos, pa, pb, pc;
346
-	unsigned int file_offset, cur_pos, predicted, data_size, src_pos, dest_pos;
346
+	unsigned int file_offset, cur_pos, predicted;
347 347
 	int32_t offset, addr;
348 348
 	const int file_size=0x1000000;
349
-    unsigned int i, j;
350 349
 
351 350
 	switch(filter_type) {
352 351
 	case VMSF_E8:
... ...
@@ -433,7 +431,7 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil
433 433
 		}
434 434
 		for (cur_channel=0 ; cur_channel < channels ; cur_channel++) {
435 435
 			unsigned char prev_byte = 0;
436
-			for (dest_pos=data_size+cur_channel ; dest_pos<(unsigned int)border ; dest_pos+=channels) {
436
+			for (dest_pos=data_size+cur_channel ; dest_pos<border ; dest_pos+=channels) {
437 437
 				rarvm_data->mem[dest_pos] = (prev_byte -= rarvm_data->mem[src_pos++]);
438 438
 			}
439 439
 		}
... ...
@@ -477,7 +475,7 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil
477 477
 				dest_data[i] = prev_byte = (unsigned char)(predicted-*(src_data++));
478 478
 			}
479 479
 		}
480
-		for (i=PosR,border=data_size-2 ; i < (unsigned int)border ; i+=3) {
480
+		for (i=PosR,border=data_size-2 ; i < border ; i+=3) {
481 481
 			unsigned char g=dest_data[i+1];
482 482
 			dest_data[i] += g;
483 483
 			dest_data[i+2] += g;
... ...
@@ -651,13 +649,13 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data,
651 651
 			break;
652 652
 		case VM_JZ:
653 653
 			if ((rarvm_data->Flags & VM_FZ) != 0) {
654
-				SET_IP((int)GET_VALUE(FALSE, op1));
654
+				SET_IP(GET_VALUE(FALSE, op1));
655 655
 				continue;
656 656
 			}
657 657
 			break;
658 658
 		case VM_JNZ:
659 659
 			if ((rarvm_data->Flags & VM_FZ) == 0) {
660
-				SET_IP((int)GET_VALUE(FALSE, op1));
660
+				SET_IP(GET_VALUE(FALSE, op1));
661 661
 				continue;
662 662
 			}
663 663
 			break;
... ...
@@ -684,7 +682,7 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data,
684 684
 			SET_VALUE(FALSE, op1, GET_VALUE(FALSE, op1)-1);
685 685
 			break;
686 686
 		case VM_JMP:
687
-			SET_IP((int)GET_VALUE(FALSE, op1));
687
+			SET_IP(GET_VALUE(FALSE, op1));
688 688
 			continue;
689 689
 		case VM_XOR:
690 690
 			result = UINT32(GET_VALUE(cmd->byte_mode, op1)^GET_VALUE(cmd->byte_mode, op2));
... ...
@@ -707,37 +705,37 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data,
707 707
 			break;
708 708
 		case VM_JS:
709 709
 			if ((rarvm_data->Flags & VM_FS) != 0) {
710
-				SET_IP((int)GET_VALUE(FALSE, op1));
710
+				SET_IP(GET_VALUE(FALSE, op1));
711 711
 				continue;
712 712
 			}
713 713
 			break;
714 714
 		case VM_JNS:
715 715
 			if ((rarvm_data->Flags & VM_FS) == 0) {
716
-				SET_IP((int)GET_VALUE(FALSE, op1));
716
+				SET_IP(GET_VALUE(FALSE, op1));
717 717
 				continue;
718 718
 			}
719 719
 			break;
720 720
 		case VM_JB:
721 721
 			if ((rarvm_data->Flags & VM_FC) != 0) {
722
-				SET_IP((int)GET_VALUE(FALSE, op1));
722
+				SET_IP(GET_VALUE(FALSE, op1));
723 723
 				continue;
724 724
 			}
725 725
 			break;
726 726
 		case VM_JBE:
727 727
 			if ((rarvm_data->Flags & (VM_FC|VM_FZ)) != 0) {
728
-				SET_IP((int)GET_VALUE(FALSE, op1));
728
+				SET_IP(GET_VALUE(FALSE, op1));
729 729
 				continue;
730 730
 			}
731 731
 			break;
732 732
 		case VM_JA:
733 733
 			if ((rarvm_data->Flags & (VM_FC|VM_FZ)) == 0) {
734
-				SET_IP((int)GET_VALUE(FALSE, op1));
734
+				SET_IP(GET_VALUE(FALSE, op1));
735 735
 				continue;
736 736
 			}
737 737
 			break;
738 738
 		case VM_JAE:
739 739
 			if ((rarvm_data->Flags & VM_FC) == 0) {
740
-				SET_IP((int)GET_VALUE(FALSE, op1));
740
+				SET_IP(GET_VALUE(FALSE, op1));
741 741
 				continue;
742 742
 			}
743 743
 			break;
... ...
@@ -755,7 +753,7 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data,
755 755
 			rarvm_data->R[7] -= 4;
756 756
 			SET_VALUE(FALSE, (unsigned int *)&rarvm_data->mem[rarvm_data->R[7] &
757 757
 					RARVM_MEMMASK], cmd-prepared_code+1);
758
-			SET_IP((int)GET_VALUE(FALSE, op1));
758
+			SET_IP(GET_VALUE(FALSE, op1));
759 759
 			continue;
760 760
 		case VM_NOT:
761 761
 			SET_VALUE(cmd->byte_mode, op1, ~GET_VALUE(cmd->byte_mode, op1));
... ...
@@ -862,7 +860,7 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data,
862 862
 			if (rarvm_data->R[7] >= RARVM_MEMSIZE) {
863 863
 				return TRUE;
864 864
 			}
865
-			SET_IP((int)GET_VALUE(FALSE, (unsigned int *)&rarvm_data->mem[rarvm_data->R[7] &
865
+			SET_IP(GET_VALUE(FALSE, (unsigned int *)&rarvm_data->mem[rarvm_data->R[7] &
866 866
 				RARVM_MEMMASK]));
867 867
 			rarvm_data->R[7] += 4;
868 868
 			continue;
... ...
@@ -30,7 +30,6 @@
30 30
 #include <unistd.h>
31 31
 #endif
32 32
 
33
-#include "libclamav/clamav.h"
34 33
 #include "libclamunrar/unrar.h"
35 34
 
36 35
 #include "unrar_iface.h"
... ...
@@ -53,7 +52,7 @@ static uint32_t unrar_endian_convert_32(uint32_t v)
53 53
 #ifdef RAR_DEBUG_MODE
54 54
 #define unrar_dbgmsg printf
55 55
 #else
56
-static void unrar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); }
56
+static void unrar_dbgmsg(const char* fmt,...){}
57 57
 #endif
58 58
 
59 59
 static void *read_header(int fd, header_type hdr_type)
... ...
@@ -396,7 +395,6 @@ int unrar_extract_next_prepare(unrar_state_t *state, const char *dirname)
396 396
 	int ofd;
397 397
 	unrar_metadata_t *new_metadata;
398 398
 
399
-    UNUSEDPARAM(dirname);
400 399
 
401 400
     state->file_header = read_block(state->fd, FILE_HEAD);
402 401
     if(!state->file_header)
... ...
@@ -137,6 +137,12 @@ CLEANFILES		       += libltdl.la \
137 137
 CLEANFILES	       += $(ltdl_LIBOBJS) $(ltdl_LTLIBOBJS)
138 138
 
139 139
 EXTRA_DIST	       += COPYING.LIB \
140
+			   \
141
+			   \
142
+			   \
143
+			   \
144
+			   \
145
+			   \
140 146
 			  README
141 147
 
142 148
 ## --------------------------- ##
... ...
@@ -151,7 +157,6 @@ EXTRA_DIST	+= argz_.h \
151 151
 # doesn't have one that works with the given compiler.
152 152
 all-local $(lib_OBJECTS): $(ARGZ_H)
153 153
 argz.h: argz_.h
154
-	$(mkinstalldirs) . 
155 154
 	cp $(srcdir)/argz_.h $@-t
156 155
 	mv $@-t $@
157 156
 MOSTLYCLEANFILES += argz.h \
... ...
@@ -397,6 +397,9 @@ JSON_LIBS = @JSON_LIBS@
397 397
 LCOV = @LCOV@
398 398
 LD = @LD@
399 399
 LDFLAGS = @LDFLAGS@
400
+LEX = @LEX@
401
+LEXLIB = @LEXLIB@
402
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
400 403
 LIBADD_DL = @LIBADD_DL@
401 404
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
402 405
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -459,6 +462,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
459 459
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
460 460
 XML_CPPFLAGS = @XML_CPPFLAGS@
461 461
 XML_LIBS = @XML_LIBS@
462
+YACC = @YACC@
463
+YFLAGS = @YFLAGS@
462 464
 abs_builddir = @abs_builddir@
463 465
 abs_srcdir = @abs_srcdir@
464 466
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -1130,7 +1135,6 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES \
1130 1130
 # doesn't have one that works with the given compiler.
1131 1131
 all-local $(lib_OBJECTS): $(ARGZ_H)
1132 1132
 argz.h: argz_.h
1133
-	$(mkinstalldirs) . 
1134 1133
 	cp $(srcdir)/argz_.h $@-t
1135 1134
 	mv $@-t $@
1136 1135
 
... ...
@@ -1,4 +1,6 @@
1 1
 AC_PROG_CC
2
+AM_PROG_LEX
3
+AC_PROG_YACC
2 4
 AC_PROG_INSTALL
3 5
 AC_PROG_LN_S
4 6
 AC_PROG_MAKE_SET
... ...
@@ -1,8 +1,32 @@
1
+AC_ARG_WITH([system-llvm], AC_HELP_STRING([--with-system-llvm],
2
+[Use system llvm instead of built-in, uses full path to llvm-config (default=
3
+/usr/local or /usr if not found in /usr/local)]),
4
+[case "$withval" in
5
+  yes)
6
+    system_llvm="default"
7
+    ;;
8
+  no)
9
+    system_llvm="built-in"
10
+    ;;
11
+  *)
12
+    system_llvm=$withval
13
+ esac
14
+], [system_llvm="built-in"])
15
+
1 16
 AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm],
2
-				    [Enable 'llvm' JIT/verifier support @<:@default=auto@:>@]),
3
-				    [enable_llvm=$enableval], [enable_llvm="auto"])
17
+[Enable 'llvm' JIT/verifier support @<:@default=auto@:>@]),
18
+[enable_llvm=$enableval],
19
+[
20
+if test "x$system_llvm" != "xbuilt-in"; then
21
+    enable_llvm="yes"
22
+else
23
+    enable_llvm="auto"
24
+fi
25
+])
4 26
 
5 27
 if test "$enable_llvm" != "no"; then
6 28
     dnl Try to configure subdir, optionally
7 29
     AC_CONFIG_SUBDIRS_OPTIONAL([libclamav/c++])
30
+else
31
+    system_llvm="none"
8 32
 fi
... ...
@@ -141,9 +141,9 @@ 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
+    { NULL, "printbcir", 'c', CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Print IR of bytecode signature", ""},
145 145
     { NULL, "input", 'r', CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMBC, "Input file to run the bytecode n", ""},
146
-    { NULL, "trace", 't', CLOPT_TYPE_NUMBER, MATCH_NUMBER, 7, NULL, 0, OPT_CLAMBC, "bytecode trace level",""},
146
+    { NULL, "trace", 'T', CLOPT_TYPE_NUMBER, MATCH_NUMBER, 7, NULL, 0, OPT_CLAMBC, "bytecode trace level",""},
147 147
     { NULL, "no-trace-showsource", 's', CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Don't show source line during tracing",""},
148 148
 
149 149
     { NULL, "archive-verbose", 'a', CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "", ""},
... ...
@@ -301,7 +301,7 @@ const struct clam_option __clam_options[] = {
301 301
 
302 302
    { "DetectPUA", "detect-pua", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "Detect Potentially Unwanted Applications.", "yes" },
303 303
 
304
-    { "ExcludePUA", "exclude-pua", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, FLAG_MULTIPLE, OPT_CLAMD | OPT_CLAMSCAN, "Exclude a specific PUA category. This directive can be used multiple times.\nSee http://www.clamav.net/support/pua for the complete list of PUA\ncategories.", "NetTool\nPWTool" },
304
+    { "ExcludePUA", "exclude-pua", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, FLAG_MULTIPLE, OPT_CLAMD | OPT_CLAMSCAN, "Exclude a specific PUA category. This directive can be used multiple times.\nSee http://www.clamav.net/documentation.html#pua for the complete list of PUA\ncategories.", "NetTool\nPWTool" },
305 305
 
306 306
     { "IncludePUA", "include-pua", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, FLAG_MULTIPLE, OPT_CLAMD | OPT_CLAMSCAN, "Only include a specific PUA category. This directive can be used multiple\ntimes.", "Spy\nScanner\nRAT" },
307 307
 
... ...
@@ -464,9 +464,9 @@ const struct clam_option __clam_options[] = {
464 464
 
465 465
     { "DetectionStatsCountry", NULL, 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM, "Country of origin of malware/detection statistics (for statistical\npurposes only). The statistics collector at ClamAV.net will look up\nyour IP address to determine the geographical origin of the malware\nreported by your installation. If this installation is mainly used to\nscan data which comes from a different location, please enable this\noption and enter a two-letter code (see http://www.iana.org/domains/root/db/)\nof the country of origin.", "country-code" },
466 466
 
467
-    { "DetectionStatsHostID", NULL, 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM, "This option enables support for our \"Personal Statistics\" service.\nWhen this option is enabled, the information on malware detected by\nyour clamd installation is made available to you through our website.\nTo get your HostID, log on http://www.stats.clamav.net and add a new\nhost to your host list. Once you have the HostID, uncomment this option\nand paste the HostID here. As soon as your freshclam starts submitting\ninformation to our stats collecting service, you will be able to view\nthe statistics of this clamd installation by logging into\nhttp://www.stats.clamav.net with the same credentials you used to\ngenerate the HostID. For more information refer to:\nhttp://www.clamav.net/support/faq/faq-cctts/\nThis feature requires SubmitDetectionStats to be enabled.", "unique-id" },
467
+    { "DetectionStatsHostID", NULL, 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM, "This option enables support for our \"Personal Statistics\" service.\nWhen this option is enabled, the information on malware detected by\nyour clamd installation is made available to you through our website.\nTo get your HostID, log on http://www.stats.clamav.net and add a new\nhost to your host list. Once you have the HostID, uncomment this option\nand paste the HostID here. As soon as your freshclam starts submitting\ninformation to our stats collecting service, you will be able to view\nthe statistics of this clamd installation by logging into\nhttp://www.stats.clamav.net with the same credentials you used to\ngenerate the HostID. For more information refer to:\nhttp://www.clamav.net/documentation.html#cctts\nThis feature requires SubmitDetectionStats to be enabled.", "unique-id" },
468 468
 
469
-    { "SafeBrowsing", NULL, 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM, "This option enables support for Google Safe Browsing. When activated for\nthe first time, freshclam will download a new database file (safebrowsing.cvd)\nwhich will be automatically loaded by clamd and clamscan during the next\nreload, provided that the heuristic phishing detection is turned on. This\ndatabase includes information about websites that may be phishing sites or\npossible sources of malware. When using this option, it's mandatory to run\nfreshclam at least every 30 minutes.\nFreshclam uses the ClamAV's mirror infrastructure to distribute the\ndatabase and its updates but all the contents are provided under Google's\nterms of use. See http://www.google.com/transparencyreport/safebrowsing\nand https://github.com/vrtadmin/clamav-faq/blob/master/faq/faq-safebrowsing.md for more information.", "yes" },
469
+    { "SafeBrowsing", NULL, 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM, "This option enables support for Google Safe Browsing. When activated for\nthe first time, freshclam will download a new database file (safebrowsing.cvd)\nwhich will be automatically loaded by clamd and clamscan during the next\nreload, provided that the heuristic phishing detection is turned on. This\ndatabase includes information about websites that may be phishing sites or\npossible sources of malware. When using this option, it's mandatory to run\nfreshclam at least every 30 minutes.\nFreshclam uses the ClamAV's mirror infrastructure to distribute the\ndatabase and its updates but all the contents are provided under Google's\nterms of use. See http://www.google.com/transparencyreport/safebrowsing\nand http://www.clamav.net/documentation.html for more information.", "yes" },
470 470
 
471 471
     { "Bytecode", NULL, 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 1, NULL, 0, OPT_FRESHCLAM, "This option enables downloading of bytecode.cvd, which includes additional\ndetection mechanisms and improvements to the ClamAV engine.", "yes" },
472 472
 
... ...
@@ -319,6 +319,9 @@ JSON_LIBS = @JSON_LIBS@
319 319
 LCOV = @LCOV@
320 320
 LD = @LD@
321 321
 LDFLAGS = @LDFLAGS@
322
+LEX = @LEX@
323
+LEXLIB = @LEXLIB@
324
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
322 325
 LIBADD_DL = @LIBADD_DL@
323 326
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
324 327
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -381,6 +384,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
381 381
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
382 382
 XML_CPPFLAGS = @XML_CPPFLAGS@
383 383
 XML_LIBS = @XML_LIBS@
384
+YACC = @YACC@
385
+YFLAGS = @YFLAGS@
384 386
 abs_builddir = @abs_builddir@
385 387
 abs_srcdir = @abs_srcdir@
386 388
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -373,7 +373,7 @@ static char *getdsig(const char *host, const char *user, const unsigned char *da
373 373
 	    closesocket(sockd);
374 374
 	    return NULL;
375 375
 	} else {
376
-	    mprintf("Signature received (length = %zu)\n", strlen(buff) - 10);
376
+	    mprintf("Signature received (length = %lu)\n", (unsigned long)strlen(buff) - 10);
377 377
 	}
378 378
     } else {
379 379
 	mprintf("!getdsig: Communication error with remote server\n");
... ...
@@ -712,6 +712,7 @@ static int build(const struct optstruct *opts)
712 712
 			dblist2 = (char **) realloc(dblist2, (dblist2cnt + 1) * sizeof(char *));
713 713
 			if(!dblist2) { /* dblist2 leaked but we don't really care */
714 714
 			    mprintf("!build: Memory allocation error\n");
715
+                            closedir(dd);
715 716
 			    return -1;
716 717
 			}
717 718
 			dblist2[dblist2cnt] = strdup(dent->d_name);
... ...
@@ -847,6 +848,7 @@ static int build(const struct optstruct *opts)
847 847
 	mprintf("Builder name: ");
848 848
 	if(scanf("%32s", builder) == EOF || !pt) {
849 849
 	    mprintf("!build: Can't get builder name\n");
850
+	    free(dblist2);
850 851
 	    return -1;
851 852
 	}
852 853
     }
... ...
@@ -1123,6 +1125,11 @@ static int unpack(const struct optstruct *opts)
1123 1123
 	name[sizeof(name)-1]='\0';
1124 1124
     }
1125 1125
 
1126
+    if (cl_cvdverify(name) != CL_SUCCESS) {
1127
+        mprintf("!unpack: %s is not a valid CVD\n", name);
1128
+        return -1;
1129
+    }
1130
+
1126 1131
     if(cli_cvdunpack(name, ".") == -1) {
1127 1132
 	mprintf("!unpack: Can't unpack file %s\n", name);
1128 1133
 	return -1;
... ...
@@ -249,6 +249,9 @@ JSON_LIBS = @JSON_LIBS@
249 249
 LCOV = @LCOV@
250 250
 LD = @LD@
251 251
 LDFLAGS = @LDFLAGS@
252
+LEX = @LEX@
253
+LEXLIB = @LEXLIB@
254
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
252 255
 LIBADD_DL = @LIBADD_DL@
253 256
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
254 257
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -311,6 +314,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
311 311
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
312 312
 XML_CPPFLAGS = @XML_CPPFLAGS@
313 313
 XML_LIBS = @XML_LIBS@
314
+YACC = @YACC@
315
+YFLAGS = @YFLAGS@
314 316
 abs_builddir = @abs_builddir@
315 317
 abs_srcdir = @abs_srcdir@
316 318
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -539,6 +539,9 @@ JSON_LIBS = @JSON_LIBS@
539 539
 LCOV = @LCOV@
540 540
 LD = @LD@
541 541
 LDFLAGS = @LDFLAGS@
542
+LEX = @LEX@
543
+LEXLIB = @LEXLIB@
544
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
542 545
 LIBADD_DL = @LIBADD_DL@
543 546
 LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
544 547
 LIBADD_DLOPEN = @LIBADD_DLOPEN@
... ...
@@ -601,6 +604,8 @@ WERR_CFLAGS = @WERR_CFLAGS@
601 601
 WERR_CFLAGS_MILTER = @WERR_CFLAGS_MILTER@
602 602
 XML_CPPFLAGS = @XML_CPPFLAGS@
603 603
 XML_LIBS = @XML_LIBS@
604
+YACC = @YACC@
605
+YFLAGS = @YFLAGS@
604 606
 abs_builddir = @abs_builddir@
605 607
 abs_srcdir = @abs_srcdir@
606 608
 abs_top_builddir = @abs_top_builddir@
... ...
@@ -186,7 +186,7 @@ somecommand | "C:\Program Files\ClamAV for Windows\clamav\SigUI.exe" -w
186 186
 \section{Setting up a local mirror}
187 187
 \label{sec:localmirror}
188 188
 
189
-If you have a lot of ClamAV installations on your local network, then you can setup \gls{freshclam} as described in the answer for  \emph{I’m running ClamAV on a lot of clients on my local network} at \url{http://www.clamav.net/lang/en/support/faq/faq-cvd/}.
189
+If you have a lot of ClamAV installations on your local network, then you can setup \gls{freshclam} as described in the answer for  \emph{I’m running ClamAV on a lot of clients on my local network} at \url{http://www.clamav.net/documentation.html} under the Private Mirrors section.
190 190
 Once you've setup the local mirror you can configure it:
191 191
 \begin{itemize}
192 192
 \item Open SigUI