Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lavabit/magma.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLadar Levison <ladar@lavabit.com>2022-04-05 06:43:28 +0300
committerLadar Levison <ladar@lavabit.com>2022-04-05 06:43:28 +0300
commiteddef7cf97bdcf059c464b4723dba0310b0e8d38 (patch)
tree9562f5892c77b46ef8f38b2edc1e5e304de80936
parent7d417f06b0162da6e8281e65aef8c8bb39809df4 (diff)
Adding ClamAV 0.104.2 patches/updates/tarball for future use.
-rwxr-xr-xdev/scripts/builders/build.lib.sh15
-rw-r--r--lib/archives/clamav-0.104.2.tar.gzbin0 -> 11950409 bytes
-rw-r--r--lib/patches/clamav/freshclam_cafile_option_01042.patch107
-rw-r--r--lib/patches/clamav/shutdown_rarload_01042.patch178
4 files changed, 298 insertions, 2 deletions
diff --git a/dev/scripts/builders/build.lib.sh b/dev/scripts/builders/build.lib.sh
index e22f7957..fccf0c82 100755
--- a/dev/scripts/builders/build.lib.sh
+++ b/dev/scripts/builders/build.lib.sh
@@ -1299,8 +1299,8 @@ clamav() {
# Output the version number and not the git commit hash.
cat "$M_PATCHES/clamav/"version_0984.patch | patch -p1 --verbose &>> "$M_LOGS/clamav.txt"; error
- else
- # Add the shutdown and clean up functions and fix the rar library dynamic loading logic.
+ elif [[ $CLAMAV =~ "clamav-0.102.3" ]]; then
+ # Add the shutdown and clean up functions and fix the rar library dynamic loading logic.
cat "$M_PATCHES/clamav/"shutdown_rarload_01023.patch | patch -p1 --fuzz=100 --verbose &>> "$M_LOGS/clamav.txt"; error
# Add the ability to dictate the CA bundle file location when running freshclam.
@@ -1308,6 +1308,17 @@ clamav() {
# Output the version number and not the git commit hash.
cat "$M_PATCHES/clamav/"version_0984.patch | patch -p1 --verbose &>> "$M_LOGS/clamav.txt"; error
+
+ # Applied to most recent version.
+ else
+ # Add the shutdown and clean up functions and fix the rar library dynamic loading logic.
+ cat "$M_PATCHES/clamav/"shutdown_rarload_01042.patch | patch -p1 --fuzz=100 --verbose &>> "$M_LOGS/clamav.txt"; error
+
+ # Add the ability to dictate the CA bundle file location when running freshclam.
+ cat "$M_PATCHES/clamav/"freshclam_cafile_option_01042.patch | patch -p1 --verbose &>> "$M_LOGS/clamav.txt"; error
+
+ # Output the version number and not the git commit hash.
+ cat "$M_PATCHES/clamav/"version_0984.patch | patch -p1 --verbose &>> "$M_LOGS/clamav.txt"; error
fi
# Fix reference conflict with libpng over the filename png.h.
diff --git a/lib/archives/clamav-0.104.2.tar.gz b/lib/archives/clamav-0.104.2.tar.gz
new file mode 100644
index 00000000..82c66731
--- /dev/null
+++ b/lib/archives/clamav-0.104.2.tar.gz
Binary files differ
diff --git a/lib/patches/clamav/freshclam_cafile_option_01042.patch b/lib/patches/clamav/freshclam_cafile_option_01042.patch
new file mode 100644
index 00000000..57bfc391
--- /dev/null
+++ b/lib/patches/clamav/freshclam_cafile_option_01042.patch
@@ -0,0 +1,107 @@
+diff --git a/common/optparser.c b/common/optparser.c
+index 5f06a9c..ef9ee72 100644
+--- a/common/optparser.c
++++ b/common/optparser.c
+@@ -271,6 +271,8 @@ const struct clam_option __clam_options[] = {
+
+ {"DatabaseDirectory", "datadir", 0, CLOPT_TYPE_STRING, NULL, -1, CONST_DATADIR, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_SIGTOOL, "This option allows you to change the default database directory.\nIf you enable it, please make sure it points to the same directory in\nboth clamd and freshclam.", "/var/lib/clamav"},
+
++ {"CAFile", "ca", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM, "This option allows you to override the location of the CA bundle file used by freshclam.\nIf you enable it, please make sure it points to a valid certifcate bundle file.\n", ""},
++
+ {"OfficialDatabaseOnly", "official-db-only", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "Only load the official signatures published by the ClamAV project.", "no"},
+
+ {"YaraRules", "yara-rules", 0, CLOPT_TYPE_STRING, NULL, 0, NULL, 0, OPT_CLAMSCAN, "By default, yara rules will be loaded. This option allows you to exclude yara rules when scanning and also to scan only using yara rules. Valid options are yes|no|only", "yes"},
+diff --git a/freshclam/freshclam.c b/freshclam/freshclam.c
+index d5896b5..bee4967 100644
+--- a/freshclam/freshclam.c
++++ b/freshclam/freshclam.c
+@@ -154,6 +154,7 @@ static int writepid(const char *pidfile)
+ }
+ #endif /*_WIN32 */
+
++ printf(" --ca=FILE Override the certificate bundle FILE location\n");
+ return 0;
+ }
+
+@@ -856,6 +857,7 @@ static fc_error_t initialize(struct optstruct *opts)
+
+ if (optget(opts, "LogTime")->enabled) {
+ fcConfig.logFlags |= FC_CONFIG_LOG_TIME;
++ fcConfig.caFile = optget(opts, "CAFile")->strarg;
+ }
+ if (optget(opts, "LogFileMaxSize")->numarg && optget(opts, "LogRotate")->enabled) {
+ fcConfig.logFlags |= FC_CONFIG_LOG_ROTATE;
+diff --git a/libfreshclam/libfreshclam.c b/libfreshclam/libfreshclam.c
+index 76c9db0..3f17aba 100644
+--- a/libfreshclam/libfreshclam.c
++++ b/libfreshclam/libfreshclam.c
+@@ -213,6 +213,9 @@ fc_error_t fc_initialize(fc_config *fcConfig)
+ if (NULL != fcConfig->proxyPassword) {
+ g_proxyPassword = cli_strdup(fcConfig->proxyPassword);
+ }
++ if (NULL != fcConfig->caFile) {
++ g_caFile = cli_strdup(fcConfig->caFile);
++ }
+
+ #ifdef _WIN32
+ if ((fcConfig->databaseDirectory[strlen(fcConfig->databaseDirectory) - 1] != '/') &&
+@@ -288,6 +291,10 @@ void fc_cleanup(void)
+ free(g_userAgent);
+ g_userAgent = NULL;
+ }
++ if (NULL != g_caFile) {
++ free(g_caFile);
++ g_caFile = NULL;
++ }
+ if (NULL != g_proxyServer) {
+ free(g_proxyServer);
+ g_proxyServer = NULL;
+diff --git a/libfreshclam/libfreshclam.h b/libfreshclam/libfreshclam.h
+index a3f1bc4..9d6a422 100644
+--- a/libfreshclam/libfreshclam.h
++++ b/libfreshclam/libfreshclam.h
+@@ -50,6 +50,7 @@ typedef struct fc_config_ {
+ uint32_t connectTimeout; /**< CURLOPT_CONNECTTIMEOUT, Timeout for the. connection phase (seconds). */
+ uint32_t requestTimeout; /**< CURLOPT_TIMEOUT, Timeout for libcurl transfer operation (seconds). */
+ uint32_t bCompressLocalDatabase; /**< If set, will apply gz compression to CLD databases. */
++ const char *caFile; /**< (optional) CA file to use for certificate verification, if desired. */
+ const char *logFile; /**< (optional) Filepath to use for log output, if desired. */
+ const char *logFacility; /**< (optional) System logging facility (I.e. "syslog"), if desired. */
+ const char *localIP; /**< (optional) client IP for multihomed systems. */
+diff --git a/libfreshclam/libfreshclam_internal.c b/libfreshclam/libfreshclam_internal.c
+index b836302..0aec176 100644
+--- a/libfreshclam/libfreshclam_internal.c
++++ b/libfreshclam/libfreshclam_internal.c
+@@ -107,6 +107,7 @@ uint16_t g_proxyPort = 0;
+ char *g_proxyUsername = NULL;
+ char *g_proxyPassword = NULL;
+
++char *g_caFile = NULL;
+ char *g_tempDirectory = NULL;
+ char *g_databaseDirectory = NULL;
+
+@@ -714,6 +715,12 @@ static fc_error_t create_curl_handle(
+ }
+ }
+
++ if (g_caFile) {
++ if (CURLE_OK != curl_easy_setopt(curl, CURLOPT_CAINFO, g_caFile)) {
++ logg("!create_curl_handle: Failed to set CURLOPT_CAINFO (%s)!\n", g_caFile);
++ }
++ }
++
+ #if defined(C_DARWIN) || defined(_WIN32)
+ if (CURLE_OK != curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function)) {
+ logg("*create_curl_handle: Failed to set SSL CTX function. Your libcurl may use an SSL backend that does not support CURLOPT_SSL_CTX_FUNCTION.\n");
+diff --git a/libfreshclam/libfreshclam_internal.h b/libfreshclam/libfreshclam_internal.h
+index 890d7e5..401d0d4 100644
+--- a/libfreshclam/libfreshclam_internal.h
++++ b/libfreshclam/libfreshclam_internal.h
+@@ -54,6 +54,7 @@ extern uint16_t g_proxyPort;
+ extern char *g_proxyUsername;
+ extern char *g_proxyPassword;
+
++extern char *g_caFile;
+ extern char *g_tempDirectory;
+ extern char *g_databaseDirectory;
+
diff --git a/lib/patches/clamav/shutdown_rarload_01042.patch b/lib/patches/clamav/shutdown_rarload_01042.patch
new file mode 100644
index 00000000..373869ef
--- /dev/null
+++ b/lib/patches/clamav/shutdown_rarload_01042.patch
@@ -0,0 +1,178 @@
+diff --git a/libclamav/clamav.h b/libclamav/clamav.h
+index d4be07e..c49c484 100644
+--- a/libclamav/clamav.h
++++ b/libclamav/clamav.h
+@@ -261,6 +261,7 @@ void cl_cleanup_crypto(void);
+ /**
+ * @brief Initialize the ClamAV library.
+ *
++extern void cl_shutdown(void);
+ * @param initoptions Unused.
+ * @return cl_error_t CL_SUCCESS if everything initalized correctly.
+ */
+diff --git a/libclamav/mbox.c b/libclamav/mbox.c
+index 1f1e1c3..ac97d18 100644
+--- a/libclamav/mbox.c
++++ b/libclamav/mbox.c
+@@ -3052,6 +3052,30 @@ initialiseTables(table_t **rfc821Table, table_t **subtypeTable)
+ }
+
+ /*
++ * Cleanup the various lookup tables
++ */
++void
++cli_mbox_shutdown(void)
++{
++
++#ifdef CL_THREAD_SAFE
++ pthread_mutex_lock(&tables_mutex);
++#endif
++ if(rfc821) {
++ tableDestroy(rfc821);
++ rfc821 = NULL;
++ }
++ if(subtype) {
++ tableDestroy(subtype);
++ subtype = NULL;
++ }
++#ifdef CL_THREAD_SAFE
++ pthread_mutex_unlock(&tables_mutex);
++#endif
++
++}
++
++/*
+ * If there's a HTML text version use that, otherwise
+ * use the first text part, otherwise just use the
+ * first one around. HTML text is most likely to include
+diff --git a/libclamav/mbox.h b/libclamav/mbox.h
+index 63ee0c4..fb767f5 100644
+--- a/libclamav/mbox.h
++++ b/libclamav/mbox.h
+@@ -75,4 +75,6 @@ typedef enum {
+ size_t strstrip(char *s); /* remove trailing white space */
+ int cli_mbox(const char *dir, cli_ctx *ctx);
+
++void cli_mbox_shutdown(void);
++
+ #endif /* __MBOX_H */
+diff --git a/libclamav/message.c b/libclamav/message.c
+index 75c86ec..cc2fb7b 100644
+--- a/libclamav/message.c
++++ b/libclamav/message.c
+@@ -137,6 +137,32 @@ static const unsigned char base64Table[256] = {
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255};
+
++static table_t *mime_table = NULL;
++
++#ifdef CL_THREAD_SAFE
++ static pthread_mutex_t mime_mutex = PTHREAD_MUTEX_INITIALIZER;
++#endif
++
++/*
++ * Cleanup the various lookup tables
++ */
++void
++cli_mime_shutdown(void)
++{
++
++#ifdef CL_THREAD_SAFE
++ pthread_mutex_lock(&mime_mutex);
++#endif
++ if(mime_table) {
++ tableDestroy(mime_table);
++ mime_table = NULL;
++ }
++#ifdef CL_THREAD_SAFE
++ pthread_mutex_unlock(&mime_mutex);
++#endif
++
++}
++
+ message *
+ messageCreate(void)
+ {
+@@ -211,12 +237,8 @@ void messageReset(message *m)
+ */
+ int messageSetMimeType(message *mess, const char *type)
+ {
+-#ifdef CL_THREAD_SAFE
+- static pthread_mutex_t mime_mutex = PTHREAD_MUTEX_INITIALIZER;
+-#endif
+ const struct mime_map *m;
+ int typeval;
+- static table_t *mime_table;
+
+ if (mess == NULL) {
+ cli_dbgmsg("messageSetMimeType: NULL message pointer\n");
+diff --git a/libclamav/message.h b/libclamav/message.h
+index 62f6b85..a0ec5cd 100644
+--- a/libclamav/message.h
++++ b/libclamav/message.h
+@@ -93,4 +93,6 @@ int messageSavePartial(message *m, const char *dir, const char *id, unsigned par
+ json_object *messageGetJObj(message *m);
+ #endif
+
++void cli_mime_shutdown(void);
++
+ #endif /*_MESSAGE_H*/
+diff --git a/libclamav/others.c b/libclamav/others.c
+index 4c31381..20a0fdf 100644
+--- a/libclamav/others.c
++++ b/libclamav/others.c
+@@ -302,20 +302,26 @@ static void rarload(void)
+ cli_unrar_skip_file = unrar_skip_file;
+ cli_unrar_close = unrar_close;
+ #else
+- rhandle = load_module("libclamunrar_iface", "unrar");
+- if (NULL == rhandle)
+- return;
+-
+- if ((NULL == (cli_unrar_open = (cl_unrar_error_t(*)(const char *, void **, char **, uint32_t *, uint8_t))get_module_function(rhandle, "libclamunrar_iface_LTX_unrar_open"))) ||
+- (NULL == (cli_unrar_peek_file_header = (cl_unrar_error_t(*)(void *, unrar_metadata_t *))get_module_function(rhandle, "libclamunrar_iface_LTX_unrar_peek_file_header"))) ||
+- (NULL == (cli_unrar_extract_file = (cl_unrar_error_t(*)(void *, const char *, char *))get_module_function(rhandle, "libclamunrar_iface_LTX_unrar_extract_file"))) ||
+- (NULL == (cli_unrar_skip_file = (cl_unrar_error_t(*)(void *))get_module_function(rhandle, "libclamunrar_iface_LTX_unrar_skip_file"))) ||
+- (NULL == (cli_unrar_close = (void (*)(void *))get_module_function(rhandle, "libclamunrar_iface_LTX_unrar_close")))) {
+
+- cli_warnmsg("Failed to load function from UnRAR module\n");
+- cli_warnmsg("Version mismatch?\n");
+- cli_warnmsg("UnRAR support unavailable\n");
+- return;
++ if ((NULL == (cli_unrar_open = (cl_unrar_error_t(*)(const char *, void **, char **, uint32_t *, uint8_t))get_module_function(NULL, "libclamunrar_iface_LTX_unrar_open"))) ||
++ (NULL == (cli_unrar_peek_file_header = (cl_unrar_error_t(*)(void *, unrar_metadata_t *))get_module_function(NULL, "libclamunrar_iface_LTX_unrar_peek_file_header"))) ||
++ (NULL == (cli_unrar_extract_file = (cl_unrar_error_t(*)(void *, const char *, char *))get_module_function(NULL, "libclamunrar_iface_LTX_unrar_extract_file"))) ||
++ (NULL == (cli_unrar_skip_file = (cl_unrar_error_t(*)(void *))get_module_function(NULL, "libclamunrar_iface_LTX_unrar_skip_file"))) ||
++ (NULL == (cli_unrar_close = (void (*)(void *))get_module_function(NULL, "libclamunrar_iface_LTX_unrar_close")))) {
++
++ rhandle = load_module("libclamunrar_iface", "unrar");
++ if (NULL == rhandle) return;
++
++ if ((NULL == (cli_unrar_open = (cl_unrar_error_t(*)(const char *, void **, char **, uint32_t *, uint8_t))get_module_function(rhandle, "libclamunrar_iface_LTX_unrar_open"))) ||
++ (NULL == (cli_unrar_peek_file_header = (cl_unrar_error_t(*)(void *, unrar_metadata_t *))get_module_function(rhandle, "libclamunrar_iface_LTX_unrar_peek_file_header"))) ||
++ (NULL == (cli_unrar_extract_file = (cl_unrar_error_t(*)(void *, const char *, char *))get_module_function(rhandle, "libclamunrar_iface_LTX_unrar_extract_file"))) ||
++ (NULL == (cli_unrar_skip_file = (cl_unrar_error_t(*)(void *))get_module_function(rhandle, "libclamunrar_iface_LTX_unrar_skip_file"))) ||
++ (NULL == (cli_unrar_close = (void (*)(void *))get_module_function(rhandle, "libclamunrar_iface_LTX_unrar_close")))) {
++ cli_warnmsg("Failed to load function from UnRAR module\n");
++ cli_warnmsg("Version mismatch?\n");
++ cli_warnmsg("UnRAR support unavailable\n");
++ return;
++ }
+ }
+ #endif
+
+@@ -440,6 +446,14 @@ cl_error_t cl_init(unsigned int initoptions)
+ return CL_SUCCESS;
+ }
+
++void cl_shutdown(void) {
++ cli_mbox_shutdown();
++ cli_mime_shutdown();
++ if (lt_dlexit()) {
++ cli_errmsg("lt_dlexit: Library exit error, probably because of an invalid reference counter");
++ }
++}
++
+ struct cl_engine *cl_engine_new(void)
+ {
+ struct cl_engine *new;