Commit graph

28 commits

Author SHA1 Message Date
Val Snyder
7ff29b8c37
Bump copyright dates for 2025 2025-02-14 10:24:30 -05:00
Micah Snyder
9cb28e51e6 Bump copyright dates for 2024 2024-01-22 11:27:17 -05:00
Micah Snyder
5c5120d1e6 Assorted unit test Coverity fixes
Coverity-344508: Fix out-of-bound read in check_str test.
The len argument cannot be longer than the size of the source buffer.
The original test was attempting to test an append failure.
The updated test checks for correct behavior with two consecutive
appends.

Also added function comments to document correct use of textbuffer
functions.

Coverity-344493: Fix out-of-bounds read in check_jsnorm test.
The buffers passed to tokenizer_test must be NULL-terminated.
2023-04-26 10:43:13 -07:00
Micah Snyder
6eebecc303 Bump copyright for 2023 2023-02-12 11:20:22 -08:00
Micah Snyder
0bd2ae26bc Scanners: Remove allmatch checks + significant code cleanup
Also fixed a number of conditions where magic_scan() critical errors may
be ignored.

To ensure that the scan truly aborts for signature matches (not in
allmatch mode) and for timeouts, the `ctx->abort` option is now set in
these two conditions, and checked in several spots in magic_scan().

Additionally, I've consolidated some of the "scan must halt" type of
checks (mostly large switch statements) into a function so that we can
use the exact same logic in a few places in magic_scan().

I've also fixed a few minor warnings and code format issues.
2022-10-19 13:13:57 -07:00
micasnyd
140c88aa4e Bump copyright for 2022
Includes minor format corrections.
2022-01-09 14:23:25 -07:00
Micah Snyder (micasnyd)
b9ca6ea103 Update copyright dates for 2021
Also fixes up clang-format.
2021-03-19 15:12:26 -07:00
Micah Snyder (micasnyd)
9e20cdf6ea Add CMake build tooling
This patch adds experimental-quality CMake build tooling.

The libmspack build required a modification to use "" instead of <> for
header #includes. This will hopefully be included in the libmspack
upstream project when adding CMake build tooling to libmspack.

Removed use of libltdl when using CMake.

Flex & Bison are now required to build.

If -DMAINTAINER_MODE, then GPERF is also required, though it currently
doesn't actually do anything.  TODO!

I found that the autotools build system was generating the lexer output
but not actually compiling it, instead using previously generated (and
manually renamed) lexer c source. As a consequence, changes to the .l
and .y files weren't making it into the build. To resolve this, I
removed generated flex/bison files and fixed the tooling to use the
freshly generated files. Flex and bison are now required build tools.
On Windows, this adds a dependency on the winflexbison package,
which can be obtained using Chocolatey or may be manually installed.

CMake tooling only has partial support for building with external LLVM
library, and no support for the internal LLVM (to be removed in the
future). I.e. The CMake build currently only supports the bytecode
interpreter.

Many files used include paths relative to the top source directory or
relative to the current project, rather than relative to each build
target. Modern CMake support requires including internal dependency
headers the same way you would external dependency headers (albeit
with "" instead of <>). This meant correcting all header includes to
be relative to the build targets and not relative to the workspace.

For example, ...

```c
include "../libclamav/clamav.h"
include "clamd/clamd_others.h"
```

... becomes:

```c
// libclamav
include "clamav.h"

// clamd
include "clamd_others.h"
```

Fixes header name conflicts by renaming a few of the files.

Converted the "shared" code into a static library, which depends on
libclamav. The ironically named "shared" static library provides
features common to the ClamAV apps which are not required in
libclamav itself and are not intended for use by downstream projects.
This change was required for correct modern CMake practices but was
also required to use the automake "subdir-objects" option.
This eliminates warnings when running autoreconf which, in the next
version of autoconf & automake are likely to break the build.

libclamav used to build in multiple stages where an earlier stage is
a static library containing utils required by the "shared" code.
Linking clamdscan and clamdtop with this libclamav utils static lib
allowed these two apps to function without libclamav. While this is
nice in theory, the practical gains are minimal and it complicates
the build system. As such, the autotools and CMake tooling was
simplified for improved maintainability and this feature was thrown
out. clamdtop and clamdscan now require libclamav to function.

Removed the nopthreads version of the autotools
libclamav_internal_utils static library and added pthread linking to
a couple apps that may have issues building on some platforms without
it, with the intention of removing needless complexity from the
source. Kept the regular version of libclamav_internal_utils.la
though it is no longer used anywhere but in libclamav.

Added an experimental doxygen build option which attempts to build
clamav.h and libfreshclam doxygen html docs.

The CMake build tooling also may build the example program(s), which
isn't a feature in the Autotools build system.

Changed C standard to C90+ due to inline linking issues with socket.h
when linking libfreshclam.so on Linux.

Generate common.rc for win32.

Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef
from misc.c.

Add CMake files to the automake dist, so users can try the new
CMake tooling w/out having to build from a git clone.

clamonacc changes:
- Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other
  similar macros.
- Added a new clamav-clamonacc.service systemd unit file, based on
  the work of ChadDevOps & Aaron Brighton.
- Added missing clamonacc man page.

Updates to clamdscan man page, add missing options.

Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use
libclamav).

Rename Windows mspack.dll to libmspack.dll so all ClamAV-built
libraries have the lib-prefix with Visual Studio as with CMake.
2020-08-13 00:25:34 -07:00
Micah Snyder
e2f59af30a Clang-format touchup 2020-07-24 16:37:25 -07:00
Jonas Zaddach (jzaddach)
d5a733ef90 XLM (Excel 4.0) macro detection and extraction
XLM is a macro language in Excel that was used before VBA (before
1996). It is still parsed and executed by modern Excel and is gaining
popularity with malware authors.

This patch adds rudimentary support for detecting and extracting
Excel 4.0 (XLM) macros.

The code is based on Didier Steven's plugin_biff for oletools.py.
2020-04-29 14:19:41 -07:00
Micah Snyder (micasnyd)
485d8dec67 Check test support for check 0.13
Tests in libcheck 0.13 must have {} between START_TEST and END_TEST
else it will not compile.

Also replaced all deprecated "fail_" macros with "ck_" macros.
E.g. fail_unless() becomes ck_assert_msg()

The checks_common.h header file provided a couple of macros to
support versions older than 0.9.3.  As these older versions are
no longer relevant, I've removed those compatibility macros
entirely.
2020-01-15 08:14:23 -08:00
Micah Snyder
206dbaefe8 Update copyright dates for 2020 2020-01-03 15:44:07 -05:00
Micah Snyder
52cddcbcfd Updating and cleaning up copyright notices. 2019-10-02 16:08:18 -04:00
Micah Snyder
72fd33c8b2 clang-format'd using new .clang-format rules. 2019-10-02 16:08:16 -04:00
Mickey Sola
46a35abe56 mass update of copyright headers 2015-09-17 13:41:26 -04:00
Shawn Webb
60d8d2c352 Move all the crypto API to clamav.h 2014-07-01 19:38:01 -04:00
Shawn Webb
b2e7c931d0 Use OpenSSL for hashing. 2014-02-08 00:31:12 -05:00
Török Edvin
569bdeebe8 Merge branch 'fmapify'
* fmapify: (54 commits)
  workaround for unrar not supporting fmap.
  stfu on large lzma allocs
  handle 7z encryption detection albeit post extraction and blockencrypted
  add 7z SFX support - bb#3063
  fix makefile for external LLVM 2.9
  fix wrong interaction between prescan_cb caching and postscan_cb
  bytecode_watchdog: fix use of unaddressable data
  UPgrade lzma SDK to version 9.20 Also fmapify
  export cl_fmap_close
  cli_map_scandesc convenience API
  Introduce cli_map_scandesc to scan a portion of the existing file
  fix utf16_to_utf8, and add testcase
  cli_utf16_to_utf8
  fmapify jpeg_exploit
  fmaify cli_scan_riff
  fmapify mydoom
  export filetype cb
  factor out common code
  fix mem API of new fmap
  unit tests for new fmap scan API
  ...

Conflicts:
	libclamav/Makefile.in
	libclamav/c++/Makefile.am
	libclamav/c++/Makefile.in
	libclamav/filetypes_int.h
	libclamav/scanners.c
	libclamav/str.c
	unit_tests/check_clamav.c
2012-01-04 15:52:33 +02:00
Török Edvin
0eafa898e9 fix utf16_to_utf8, and add testcase 2011-06-17 22:20:31 +03:00
Török Edvin
e4a0f2c94f fix compiler warnings (bb #1872, bb #1934, bb #1935) 2010-04-13 16:19:47 +03:00
Török Edvin
b6dab5a7d8 fix warning
git-svn: trunk@4975
2009-03-22 17:18:58 +00:00
Török Edvin
62b7686d21 fix trailing bytes in base64 decoding (bb #1388, thanks Thiyaga <mthiyaga*corp.untd.com>)
git-svn: trunk@4974
2009-03-22 16:55:41 +00:00
Török Edvin
15d67313c4 allow 'make check' to work even if check is not installed
by skipping checks that require it. (bb #1157)
if configure is not able to find check, you can use
--with-libcheck-prefix, instead of CHECK_CFLAGS and
CHECK_LIBS.
remove accidental AC_DEFINE GETHOSTBYNAME_R_6 from last commit.

git-svn: trunk@4172
2008-09-11 11:02:12 +00:00
Török Edvin
dfc0c031cb if there is a version.h.static use that instead of output from svnversion
Makefile portability fixes
fix assert failure
add lcov to top level makefile
cleanup after lcov when you run make clean (bb #1112)
fix parsing of [^.] character class
fix parsing of [r-t]
fix handling of @ for URL hashes
fix handling of &# inside URLs
drop some dead code
more unit tests for str
portability fixes

git-svn: trunk@4078
2008-08-04 12:44:16 +00:00
Török Edvin
2e64bd9fc5 add test for cli_hex2str (bb #930)
git-svn: trunk@4056
2008-08-01 14:50:38 +00:00
Török Edvin
5ee56e4103 split up regex_list.
begin testing for regex_suffix


git-svn: trunk@3985
2008-07-24 18:48:31 +00:00
Török Edvin
a39b29cbfe avoid misleading message when unit tests are disabled (bb #1090)
fix some compiler warnings


git-svn: trunk@3933
2008-07-10 13:29:32 +00:00
Török Edvin
e3c912e174 add missing file
git-svn: trunk@3931
2008-07-10 10:30:41 +00:00