From 35e97b51459ab95d845e72ef55428b662bba0ee9 Mon Sep 17 00:00:00 2001 From: Marc Stern Date: Thu, 1 Feb 2024 11:48:21 +0100 Subject: [PATCH] When there's a problem writing a collection key (it's too big for instance), we have no info on the involved key. This adds the key name in the log (and its size, as this is the problem most of the time). --- apache2/apache2_config.c | 3 +++ apache2/persist_dbm.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apache2/apache2_config.c b/apache2/apache2_config.c index 74c76a58..6b71dea7 100644 --- a/apache2/apache2_config.c +++ b/apache2/apache2_config.c @@ -1749,6 +1749,9 @@ char *parser_conn_limits_operator(apr_pool_t *mp, const char *p2, apr_filepath_merge(&file, config_orig_path, param, APR_FILEPATH_TRUENAME, mp); + if (config_orig_path == NULL) { + return apr_psprintf(mp, "ModSecurity: failed to duplicate filename in parser_conn_limits_operator"); + } if ((strncasecmp(p2, "!@ipMatchFromFile", strlen("!@ipMatchFromFile")) == 0) || (strncasecmp(p2, "!@ipMatchF", strlen("!@ipMatchF")) == 0)) { diff --git a/apache2/persist_dbm.c b/apache2/persist_dbm.c index edd41c11..b71796bd 100644 --- a/apache2/persist_dbm.c +++ b/apache2/persist_dbm.c @@ -608,8 +608,8 @@ int collection_store(modsec_rec *msr, apr_table_t *col) { rc = apr_sdbm_store(dbm, key, value, APR_SDBM_REPLACE); if (rc != APR_SUCCESS) { - msr_log(msr, 1, "collection_store: Failed to write to DBM file \"%s\": %s", dbm_filename, - get_apr_error(msr->mp, rc)); + msr_log(msr, 1, "collection_store: Failed to write to DBM file \"%s\": %s (key=%s, length=%d)", dbm_filename, + get_apr_error(msr->mp, rc), key.dptr, value.dsize); if (dbm != NULL) { #ifdef GLOBAL_COLLECTION_LOCK apr_sdbm_close(dbm);