Commit graph

50 commits

Author SHA1 Message Date
Val Snyder
7ff29b8c37
Bump copyright dates for 2025 2025-02-14 10:24:30 -05:00
Micah Snyder
e48dfad49a Windows: Fix C/Rust FFI compat issue + Windows compile warnings
Primarily this commit fixes an issue with the size of the parameters
passed to cli_checklimits(). The parameters were "unsigned long", which
varies in size depending on platform.
I've switched them to uint64_t / u64.

While working on this, I observed some concerning warnigns on Windows,
and some less serious ones, primarily regarding inconsistencies with
`const` parameters.

Finally, in `scanmem.c`, there is a warning regarding use of `wchar_t *`
with `GetModuleFileNameEx()` instead of `GetModuleFileNameExW()`.
This made me realize this code assumes we're not defining `UNICODE`,
which would have such macros use the 'A' variant.
I have fixed it the best I can, although I'm still a little
uncomfortable with some of this code that uses `char` or `wchar_t`
instead of TCHAR.

I also remove the `if (GetModuleFileNameEx) {` conditional, because this
macro/function will always be defined. The original code was checking a
function pointer, and so this was a bug when integrating into ClamAV.

Regarding the changes to `rijndael.c`, I found that this module assumes
`unsigned long` == 32bits. It does not.
I have corrected it to use `uint32_t`.
2024-04-09 10:35:22 -04: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
6f54fe2d66 Find and scan base64'd images found in HTML <style> url() args
This commit adds a feature to find, decode, and scan each image found
within HTML <style> tags where the image data is embedded in `url()`
function parameters a base64 blob

In C in the html normalization process we extract style tag contents
to new buffer for processing. We call into a new feature in Rust code to
find and decode each image (if there are multiple).

Once extracted, the images are scanned as contained files of unknown
type, and file type identifcation will determine the actual type.
2023-02-07 22:02:02 -06: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
afbf0b6180 Fix Windows text file EOL conversion issues
On Windows, files open()'ed without the O_BINARY flag will have new-line
LF (aka \n) converted to CRLF (aka \r\n) automatically when read from or
written to. This is undesirable for all scan targets AND temp files
because it affects pattern matching and with hashing.

This commit converts a handful of instances throughout the codebase
where it appears that O_BINARY was mistakenly omitted and could result
in unexpected behavior on Windows.

Git on Windows also converts LF -> CRLF for "text" files, for editing
purposes.
This is problematic for scan files and test files that should match
verbatim.
We can prevent this issue by marking .ref test files as "binary" in the
.gitattributes file and by always opening scan files and temp files as
binary.

In this commit I've also removed the `ChangeLog merge=cl-merge` line
that was once used to reduce ChangeLog merge conflicts by using the
gnulib git-merge-changlog tool. This project now categorizes changes in
the NEWS.md.
For finer detail, git commit history is fully accessible on github.com.
2021-02-25 11:41:28 -08:00
Orion Poplawski
18306a8899 unit tests: Fix ck_assert_msg() call
The first argument to ck_assert_msg() should be a logical condition.
2021-01-07 14:24:59 -08: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 (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
Steven Morgan
60671e3deb bb11798 - fix unit tests. 2017-03-08 08:58:28 -05: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
Shawn Webb
e522909e19 bb6061 2012-11-19 13:20:33 -05:00
Török Edvin
b3c69e9236 More verbose error message in unit test. 2009-10-26 19:35:27 +02:00
Török Edvin
7d5e0e1e5a Make error message more verbose. 2009-10-26 19:10:26 +02:00
Török Edvin
d659015bb6 Unit-tests need to call cl_init, otherwise mkdir can fail randomly. 2009-10-26 19:01:56 +02:00
Török Edvin
08402afa4c fix more compiler warnings (bb #273)
git-svn: trunk@4353
2008-11-07 18:49:47 +00:00
Török Edvin
563582a1ec fix unit tests when mpool is activated
git-svn: trunk@4323
2008-11-03 19:26:57 +00:00
Török Edvin
d5d06eccaa support building with older versions of check
git-svn: trunk@4289
2008-10-22 17:27:44 +00:00
Török Edvin
a66b62f88b handle unfinishes string tokens in JS parser
git-svn: trunk@4247
2008-10-11 10:27:27 +00:00
Török Edvin
6a53bbdf9a JS normalizer fixes (bb #1155)
git-svn: trunk@4202
2008-09-23 20:52:27 +00:00
Török Edvin
1279faf61e add htmlnorm unit tests and fix jsnorm space normalization
git-svn: trunk@4201
2008-09-23 20:52:22 +00:00
Török Edvin
85398f3ed8 fix overlapping arguments in disasm/debug (bb #1150)
move copt out of main, so that valgrind is not reporting false leaks
make distcheck works now

git-svn: trunk@4193
2008-09-18 14:54:36 +00:00
Török Edvin
81040d73db bb #1160
git-svn: trunk@4183
2008-09-16 18:13:07 +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
72733fbabb fix infloop in jsnorm (bb #1146)
add unit test for bb #1146

git-svn: trunk@4138
2008-08-25 12:39:09 +00:00
Török Edvin
5cd3f734a9 add lots of warnings flags to 'make distcheck',
and turn some warnings into errors (bb #1092)

git-svn: trunk@4129
2008-08-21 20:21:43 +00:00
aCaB
61b295f494 spam if lcheck is too old
git-svn: trunk@4121
2008-08-20 12:55:42 +00:00
aCaB
99f74adcc1 check for check
git-svn: trunk@4098
2008-08-10 16:19:01 +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
e2354bdb46 fix infloop in screnc detection code (introduced around SVN r3945).
generic safeguard against infinite loops due to state == next_state
add testcase

git-svn: trunk@4062
2008-08-01 17:37:06 +00:00
Török Edvin
fb6208fd12 fixes for bb #177:
if all we have is a script in a html file still normalize it
keep global scope, we need it to parse variable names in the correct scope

git-svn: trunk@4058
2008-08-01 14:50:50 +00:00
Török Edvin
6ba8b9503c lowercase JS parser output
git-svn: trunk@4057
2008-08-01 14:50:45 +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
ea5c80854b fix compiler warnings
restore cli_debug state after test


git-svn: trunk@3959
2008-07-16 10:40:03 +00:00
Török Edvin
533e76aa5e cleanup
some more unit tests


git-svn: trunk@3958
2008-07-16 09:53:18 +00:00
Török Edvin
377a2330a1 more unit tests for js-norm
fix js-norm bugs discovered during unit testing


git-svn: trunk@3951
2008-07-15 14:31:33 +00:00
Török Edvin
5be3029f8f fix crash in js parser
fix configure test for check: if it is not available, and we didn't pass
--enable-check, do not complain
add unit test for jsnorm bug


git-svn: trunk@3949
2008-07-14 19:31:56 +00:00
Török Edvin
d5db8faf3b useless code
git-svn: trunk@3938
2008-07-11 15:44:54 +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
eb2901515b move cli_unescape, and cli_textbuffer_append_normalize to str.c
add unit-test for cli_textbuffer_append_normalize
fix a bug in cli_textbuffer_append_normalize shown by unit-test


git-svn: trunk@3930
2008-07-10 10:29:29 +00:00
Török Edvin
37e6472959 more unit tests for js normalizer
git-svn: trunk@3925
2008-07-08 19:37:18 +00:00
Török Edvin
4a6ade4489 add all needed files to EXTRA_DIST (to fix make distcheck)
create unit tests for js normalizer
cleanups


git-svn: trunk@3924
2008-07-08 19:02:15 +00:00