Skip to content

Commit

Permalink
cachedb_local: fix crashes when cachedb_url modparam is not set
Browse files Browse the repository at this point in the history
This commit fixes crashes when an OpenSIPS module uses a collection that is
not explicitly set for any cachedb_url modparam.

(cherry picked from commit 92512fc)
  • Loading branch information
rvlad-patrascu committed Jul 21, 2022
1 parent c0898ca commit 315d1fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
12 changes: 0 additions & 12 deletions modules/cachedb_local/cachedb_local.c
Expand Up @@ -308,7 +308,6 @@ lcache_con* lcache_new_connection(struct cachedb_id* id)
}

con->col = it;
it->is_used = 1;

return con;
}
Expand Down Expand Up @@ -494,10 +493,6 @@ static int mod_init(void)
default_col->col_name.len = sizeof(DEFAULT_COLLECTION_NAME) - 1;
default_col->size = (1 << HASH_SIZE_DEFAULT);

/* the default collection is special; it's always there, it doesn't have
* to be used in order to keep backwards compatibility */
default_col->is_used = 1;

/* link the default collection */
default_col->next = lcache_collection;
lcache_collection = default_col;
Expand Down Expand Up @@ -538,13 +533,6 @@ static int mod_init(void)
clean_rpm_cache_old();

for ( col_it=lcache_collection; col_it; col_it=col_it->next ) {
/* check to see if we've got unused collections */
if ( !col_it->is_used ) {
LM_WARN("collection <%.*s> is not assigned to any url!\n",
col_it->col_name.len, col_it->col_name.s);
continue;
}

if (!cluster_id && col_it->replicated) {
LM_WARN("collection <%.*s> is replicated but no "
"'cluster_id' defined!\n",
Expand Down
4 changes: 0 additions & 4 deletions modules/cachedb_local/cachedb_local.h
Expand Up @@ -58,10 +58,6 @@ typedef struct lcache_col {
lcache_htable_t *col_htable;
int size;

/* we need to know somehow if this collection is used or not;
* if not used we'll need to throw an error */
int is_used;

int replicated;

osips_malloc_f malloc;
Expand Down
10 changes: 6 additions & 4 deletions modules/cachedb_local/doc/cachedb_local_admin.xml
Expand Up @@ -95,8 +95,11 @@
<section id="param_cachedb_url" xreflabel="cachedb_url">
<title><varname>cachedb_url</varname> (string)</title>
<para>
URL parameter used to define cachedb_local collections. One collection
can belong to multiple URLs, but one URL can have only one collection.
URLs of local cache groups to be used used for the script and MI cacheDB
operations. The parameter can be set multiple times.
</para>
<para>
One collection can belong to multiple URLs, but one URL can have only one collection.
Redefining an URL with the same schema and group name will result in overwriting
that URL. Each collection used in URL definition must be defined using
<emphasis>cachedb_collection</emphasis> parameter. The collection shall be defined
Expand Down Expand Up @@ -138,8 +141,7 @@ cache_store("local:group2", ...)
Using this parameter collections(hash tables) and their sizes can be defined. Each
collection definition must be separated one from another using ';'. Default size
for a hash is 512. The size must be separated from the name of the collection using
'='. Every collection that is defined in this parameter <emphasis>SHOULD</emphasis> be
used in at least one URL, else you'll receive a WARNING.
'='.
</para>
<para>
If clustering is enabled you have to specify which collections you want to replicate
Expand Down

0 comments on commit 315d1fc

Please sign in to comment.