Commit graph

42 commits

Author SHA1 Message Date
John Humlick
f0289f0b90
libclamav: Fix compiler error on some Apple systems.
clamav_dbload_fuzzer.cpp and clamav_scanfile_fuzzer.cpp use __pid_t, which some
Apple systems do not define, and this causes a compilation error. This change
defines __pid_t as pid_t, which does exist on those systems and allows clamav
to build.
2025-05-30 12:41:45 -07:00
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
RainRat
caf324e544
Fix typos (no functional changes) 2023-11-26 18:01:19 -05:00
Micah Snyder
6eebecc303 Bump copyright for 2023 2023-02-12 11:20:22 -08:00
Micah Snyder
2d99b49797 fuzz: stability of parallel fuzz testing
The fuzz targets that write a temp file currently use the same filename
every time. One of the users identified that if the tests are running
in parallel mode, many processes are accessing the same file.
This results in unstable input to the API being tested, where the file
may be overwritten as the function is being tested.

This commit fixes it by putting the fuzz process PID in the filenames
for the scanfile and dbload fuzz targets.

Resolves: https://github.com/Cisco-Talos/clamav/issues/432

Also fixed a CMake bug that built an extra fuzz target file that doesn't
serve any purpose.

Resolves: https://github.com/Cisco-Talos/clamav/issues/431
2022-03-30 13:17:02 -07:00
micasnyd
0037f5825b fuzz: fix cl_load fuzz target
I found two issues with the cl_load fuzz targets, one of which impacts
the scanfile and scanmap fuzz targets:

1. We were defining the preprocessor definitions incorrectly using
  "SCAN_TARGETS" instead of "TARGET" in unit_tests/CMakeLists.txt.
  For the scan fuzz targets this meant it wasn't properly defining
  unique settings for each compiled target.
  For the cl_load fuzz target it's worse, it wasn't setting the
  database file name correctly which means it rejected the filenames
  entirely for not having a legitimate suffix.

2. We were pre-compiling the engine before loading signatures.
  You can't load sigs for an engine that's already compiled, so this
  would also fail right away without trying to load any sigs.
2022-01-18 16:09:44 -07:00
micasnyd
140c88aa4e Bump copyright for 2022
Includes minor format corrections.
2022-01-09 14:23:25 -07:00
Micah Snyder
201e1b12a7 XOR test files; clean up tests directory
The split test files are flagged by some AV's because they look like
broken executables. Instead of splitting the test files to prevent
detections, we should encrypt them. This commit replaces the "reassemble
testfiles" script with a basic "XOR testfiles" script that can be used
to encrypt or decrypt test files. This commit also of course then
replaces all the split files with xor'ed files.

The test and unit_tests directories were a bit of a mess, so I
reorganized them all into unit_tests with all of the test files placed
under "unit_tests/input" using subdirectories for different types of files.
2021-07-17 10:39:27 -07:00
Micah Snyder
a746d344df Remove Autotools build system & built-in LLVM
CMake is now required to build.

The built-in LLVM is no longer available.

Also removed support for libltdl calls, which is not used in the CMake
builds, was only used when building with Autotools.

TODO: Fix CMake LLVM support & update to work with modern versions.
2021-05-19 14:20:59 -07:00
Micah Snyder
c025afd683 Rename "shared" library to "common"
The named "shared" is confusing, especially now that these features are
built as a static library instead of being directly compiled into the
various applications.
2021-04-20 17:31:19 -07:00
Andrew
5553a5e206 Minor fuzz testbench improvements 2021-03-20 09:20:52 -04: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
451279876e CMake: Add fuzz support.
Enabled the metadata collection feature, scan heuristics, and all-match
mode when fuzzing in the interest of better code coverage.

Also remove deprecated STREAM command.
2021-02-25 11:41:26 -08:00
Jim Klimov
3a8537207e Add newlines at end of sources to satisfy strict warnings (C/C++ standard requires them) 2020-08-21 04:56:33 +02: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
1db4787f8a Remove autotools generated files, add autogen.sh
Removed all autotools generates files. Autotools (autoconf, automake,
libtool, pkg-config, m4) will be required from now on for builds from
git clones.

Added autogen.sh to be run before ./configure.

Significant update to main .gitignore file.

Removed extraneous .gitignore files. A Git repository only needs one
.gitignore file.
2020-07-17 15:40:32 -07:00
Micah Snyder
9b03090a0a Autotools compatibility fixes
Fixes breaking issues when using autoconf 2.69 and automake 1.15.
2020-07-17 15:40:32 -07:00
Micah Snyder
206dbaefe8 Update copyright dates for 2020 2020-01-03 15:44:07 -05:00
Mickey Sola
a0e8d2ffbb autojunk'd 2019-11-06 09:50:38 -08:00
Mickey Sola
5b7fac5aeb autojunk'd 2019-10-02 16:08:31 -04:00
Mickey Sola
56a068c29f autojunk'd 2019-10-02 16:08:31 -04:00
Micah Snyder
10c06218aa Autojunk'd 2019-10-02 16:08:31 -04:00
Mickey Sola
28459aec91 autojunk'd 2019-10-02 16:08:31 -04:00
Micah Snyder
d39035d95d Autojunk'd 2019-10-02 16:08:30 -04:00
Mickey Sola
f7d82063dd autojunk'd 2019-10-02 16:08:28 -04:00
Mickey Sola
3921323b62 autojunk'd 2019-10-02 16:08:28 -04:00
Mickey Sola
4ca79bd7cb autojunk'd 2019-10-02 16:08:28 -04:00
Mickey Sola
18b723e697 autojunk'd 2019-10-02 16:08:27 -04:00
Micah Snyder
c3cc2841e7 Autojunk'd 2019-10-02 16:08:24 -04:00
Micah Snyder
5fef7399da Autojunk'ed 2019-10-02 16:08:23 -04:00
Micah Snyder
cef54eaf8f Freshclam refresh. This update makes libcurl a hard requirement for ClamAV.
New features added to freshclam:
- Update signature definitions over HTTPS.
- Support for HTTP protocol v1.1 (formerly v1.0).
- New libfreshclam library with an all new API and versioning separate from libclamav (v2.0.0). This library is now build and installed alongside libclamav as a hard dependency of freshclam.
- The ability to opt-in and opt-out of standard and optional official ClamAV databases (ExtraDatabase, ExcludeDatabase)
- The option to specify the protocol and port number of official and private mirror servers.
- Support for additional types of proxy servers beyond plain HTTP (SOCKS 4, SOCKS 5).

Features removed from freshclam:
- Mirror management (mirrors.dat) file. This feature is no longer needed as official signature databases are distributed using a paid content delivery network (Cloudflare).

This commit also adds the following features for Windows users:
- The clamsubmit tool.
- The json-c library dependency, which will enable the --gen-json option in clamscan.
- Third party libraries under the win32/3rdparty directory have been removed. Developers will need to build the libraries separately from ClamAV and provide the headers and lib/dll library files the same way they do for OpenSSL. This includes libxml2, pthread-win32, bzip2, zlib, pcre2 as well as new dependencies: curl, json-c. Developers are encouraged to use the build tool Mussels to simplify this task.
2019-10-02 16:08:22 -04:00
Micah Snyder
817a919d65 Autojunk'ed 2019-10-02 16:08:20 -04:00
Micah Snyder
a30884058c oss-fuzz-issue-2317: changing LIB_FUZZING_ENGINE to LIB_FUZZING_ENGINE_DEPRECATED as temporary fix. 2019-10-02 16:08:20 -04:00
Micah Snyder
fe4433b01f Autojunk'd 2019-10-02 16:08:20 -04:00
Mickey Sola
393edc437d automake'd 2019-10-02 16:08:18 -04:00
Micah Snyder
ea722d9486 Autojunk'd 2019-10-02 16:08:18 -04:00
Micah Snyder
43062b1397 Makefile changes to fix distcheck after addition of fuzz directory. 2019-10-02 16:08:18 -04:00
Micah Snyder
b8dbe267cf Corrections to dist to account for moving of UserManual and addition of fuzz directory. 2019-10-02 16:08:18 -04:00
Micah Snyder
52cddcbcfd Updating and cleaning up copyright notices. 2019-10-02 16:08:18 -04:00
Micah Snyder
35f04d064c Improvements to the fuzz Makefile settings. 2019-10-02 16:08:17 -04:00
Micah Snyder (micasnyd)
ce6402f7fe Added oss-fuzz integration. 2019-10-02 16:08:17 -04:00