Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dkimf_db_walk: explicitly treat DKIMF_DB_MEMCACHE as unsupported db type. #219

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions opendkim/opendkim-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -5805,6 +5805,34 @@ dkimf_db_strerror(DKIMF_DB db, char *err, size_t errlen)
/* NOTREACHED */
}

/*
** DKIMF_DB_CAN_WALK -- check if the db supports dkimf_db_walk operation
**
** Parameters:
** db -- database
**
** Return value:
** TRUE -- suppots
** FALSE -- does not support
*/

_Bool
dkimf_db_can_walk(DKIMF_DB db)
{
assert(db != NULL);

switch (db->db_type)
{
case DKIMF_DB_TYPE_REFILE:
case DKIMF_DB_TYPE_SOCKET:
case DKIMF_DB_TYPE_LUA:
case DKIMF_DB_TYPE_MEMCACHE:
case DKIMF_DB_TYPE_UNKNOWN:
return FALSE;
}
return TRUE;
}

/*
** DKIMF_DB_WALK -- walk a database
**
Expand Down Expand Up @@ -5832,13 +5860,16 @@ dkimf_db_walk(DKIMF_DB db, _Bool first, void *key, size_t *keylen,
(key == NULL && keylen != NULL))
return -1;

if (db->db_type == DKIMF_DB_TYPE_REFILE ||
db->db_type == DKIMF_DB_TYPE_SOCKET ||
db->db_type == DKIMF_DB_TYPE_LUA)
return -1;

switch (db->db_type)
{
case DKIMF_DB_TYPE_REFILE:
case DKIMF_DB_TYPE_SOCKET:
case DKIMF_DB_TYPE_LUA:
case DKIMF_DB_TYPE_MEMCACHE:
{
/* This operation does not support these type of dbs. */
return -1;
}
case DKIMF_DB_TYPE_CSL:
case DKIMF_DB_TYPE_FILE:
{
Expand Down
1 change: 1 addition & 0 deletions opendkim/opendkim-db.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ extern int dkimf_db_rewalk __P((DKIMF_DB, char *, DKIMF_DBDATA, unsigned int,
extern void dkimf_db_set_ldap_param __P((int, char *));
extern int dkimf_db_strerror __P((DKIMF_DB, char *, size_t));
extern int dkimf_db_type __P((DKIMF_DB));
extern _Bool dkimf_db_can_walk __P((DKIMF_DB));
extern int dkimf_db_walk __P((DKIMF_DB, _Bool, void *, size_t *,
DKIMF_DBDATA, unsigned int));

Expand Down
3 changes: 2 additions & 1 deletion opendkim/opendkim.c
Original file line number Diff line number Diff line change
Expand Up @@ -8323,7 +8323,8 @@ dkimf_config_load(struct config *data, struct dkimf_config *conf,
** missing KeyTable entries.
*/

if (conf->conf_signtabledb != NULL)
if (conf->conf_signtabledb != NULL &&
dkimf_db_can_walk(conf->conf_signtabledb))
{
_Bool first = TRUE;
_Bool found;
Expand Down