Commit graph

33 commits

Author SHA1 Message Date
Val Snyder
7ff29b8c37
Bump copyright dates for 2025 2025-02-14 10:24:30 -05:00
Micah Snyder
405829ee88 Refine max-allocation and safer-allocation function and macro names
We add the _OR_GOTO_DONE suffix to the macros that go to done if the
allocation fails. This makes it obvious what is different about the
macro versus the equivalent function, and that error handling is
built-in.

Renamed the cli_strdup to safer_strdup to make it obvious that it exists
because it is safer than regular strdup. Regular strdup doesn't have the
NULL check before trying to dup, and so may result in a NULL-deref
crash.

Also remove unused STRDUP (_OR_GOTO_DONE) macro, since the one with the
NULL-check is preferred.
2024-03-15 13:18:47 -04:00
Micah Snyder
6d6e04ddf8 Optimization: replace limited allocation calls
There are a large number of allocations for fix sized buffers using the
`cli_malloc` and `cli_calloc` calls that check if the requested size is
larger than our allocation threshold for allocations based on untrusted
input. These allocations will *always* be higher than the threshold, so
the extra stack frame and check for these calls is a waste of CPU.

This commit replaces needless calls with A -> B:
- cli_malloc -> malloc
- cli_calloc -> calloc
- CLI_MALLOC -> MALLOC
- CLI_CALLOC -> CALLOC

I also noticed that our MPOOL_MALLOC / MPOOL_CALLOC are not limited by
the max-allocation threshold, when MMAP is found/enabled. But the
alternative was set to cli_malloc / cli_calloc when disabled. I changed
those as well.

I didn't change the cli_realloc/2 calls because our version of realloc
not only implements a threshold but also stabilizes the undefined
behavior in realloc to protect against accidental double-free's.
It may be worth implementing a cli_realloc that doesn't have the
threshold built-in, however, so as to allow reallocaitons for things
like buffers for loading signatures, which aren't subject to the same
concern as allocations for scanning possible malware.

There was one case in mbox.c where I changed MALLOC -> CLI_MALLOC,
because it appears to be allocating based on untrusted input.
2024-03-15 13:18:47 -04:00
Micah Snyder
9cb28e51e6 Bump copyright dates for 2024 2024-01-22 11:27:17 -05:00
Micah Snyder
6eebecc303 Bump copyright for 2023 2023-02-12 11:20:22 -08:00
mko-x
a21cc6dcd7
Add explicit log level parameter to application logging API
* Added loglevel parameter to logg()

* Fix logg and mprintf internals with new loglevels

* Update all logg calls to set loglevel

* Update all mprintf calls to set loglevel

* Fix hidden logg calls

* Executed clam-format
2022-02-15 15:13:55 -08: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
206dbaefe8 Update copyright dates for 2020 2020-01-03 15:44:07 -05:00
Micah Snyder
5f4f69102d Correcting types from int to cl_error_t where appropriate. Eliminating unused variables and referencing unused parameters to remove warnings. 2019-10-02 16:08:25 -04: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
Micah Snyder
38fe8b69a0 Added .clang-format style rules, clam-format script to automate formatting of ClamAV code, and preparing select files so that clang-format does not alter carefully formatted sections. 2019-10-02 16:08:16 -04:00
Micah Snyder
ce2dcb5392 bb11432 - cleaning up additional warning messages. 2017-08-21 17:03:42 -04:00
Steven Morgan
f939eee569 bb11330 - fix regressed code for YARA offset matching. 2015-05-29 15:22:25 -04:00
Steven Morgan
5842265fd9 Enable YARA include directives, import YARA compiler struct and functions, improve YARA parse/lex error messages. 2015-05-27 18:27:48 -04:00
Steven Morgan
6d55a8253b One more clean up. 2015-05-07 15:56:39 -04:00
Steven Morgan
d03c18bed3 Fix YARA arena management, improve error reporting, clean up some code. 2015-05-07 15:50:37 -04:00
Steven Morgan
b7999b89c9 YARA: capture offsets in matcher and use for processing YARA condition 'at' clauses. 2015-03-30 17:12:01 -04:00
Steven Morgan
f51f42e95c Capture YARA compiled condition string and anchor in struct cli_ac_lsig. 2015-03-06 17:10:47 -05:00
Steven Morgan
39d0a152a3 Use YARA arena for rule memory. 2015-02-25 14:52:33 -05:00
Steven Morgan
7f7491099e parser and memory management improvements. 2015-02-25 11:14:27 -05:00
Steven Morgan
cc1c1c7d18 Fix memory leaks. 2015-02-24 17:04:53 -05:00
Steven Morgan
90941cad26 Improve YARA error messages. Enable parser yr_parser_check_types() function. 2015-02-23 16:35:27 -05:00
Steven Morgan
12cb2f3d17 Enable additional YARA parser function. 2015-02-23 13:24:49 -05:00
Steven Morgan
3ca6d4c020 YARA work in progress: enable parser functions, add YARA arenas and hash tables. 2015-02-20 17:31:10 -05:00
Steven Morgan
016b79e682 minor change of yara parse code II. 2015-02-13 16:45:51 -05:00
Steven Morgan
46dc3c4a53 minor change of yara parse code. 2015-02-13 16:43:02 -05:00
Steven Morgan
b3a7a511aa Handle yara entrypoint keyword in prototype. 2014-12-14 22:23:04 -05:00
Steven Morgan
b9af0434e5 Support yara 'all of them/any of them' conditions, enforce maximum subsig constraint, and fix signature length calculation error. 2014-12-12 05:52:48 -05:00
Steven Morgan
88c4a39fe2 work in progress: support more yara parser functionality. 2014-12-10 09:49:22 -05:00
Steven Morgan
a3c5f974ca pull ascii, nocase, and wide keywords from YARA rule strings. 2014-10-16 18:59:37 -04:00
Steven Morgan
6e767879e0 YARA work in progress: add parser skeleton, add string and rule queuing. 2014-10-14 19:18:46 -04:00