Skip to content

Commit c26dabb

Browse files
committed
Merge pull request trusteddomainproject#219 from futatuki/db_walk_avoid_abort
This saves incorrect usage of DKIMF_DB_TYPE_MEMCACHE from assertion failure addressing to unknown DB type error, and avoid execute verification of signing table on loading configurations. (See the issue trusteddomainproject#218) trusteddomainproject#218 trusteddomainproject#219
2 parents d95b8e4 + 7c39a62 commit c26dabb

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

opendkim/opendkim-db.c

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5805,6 +5805,34 @@ dkimf_db_strerror(DKIMF_DB db, char *err, size_t errlen)
58055805
/* NOTREACHED */
58065806
}
58075807

5808+
/*
5809+
** DKIMF_DB_CAN_WALK -- check if the db supports dkimf_db_walk operation
5810+
**
5811+
** Parameters:
5812+
** db -- database
5813+
**
5814+
** Return value:
5815+
** TRUE -- suppots
5816+
** FALSE -- does not support
5817+
*/
5818+
5819+
_Bool
5820+
dkimf_db_can_walk(DKIMF_DB db)
5821+
{
5822+
assert(db != NULL);
5823+
5824+
switch (db->db_type)
5825+
{
5826+
case DKIMF_DB_TYPE_REFILE:
5827+
case DKIMF_DB_TYPE_SOCKET:
5828+
case DKIMF_DB_TYPE_LUA:
5829+
case DKIMF_DB_TYPE_MEMCACHE:
5830+
case DKIMF_DB_TYPE_UNKNOWN:
5831+
return FALSE;
5832+
}
5833+
return TRUE;
5834+
}
5835+
58085836
/*
58095837
** DKIMF_DB_WALK -- walk a database
58105838
**
@@ -5832,13 +5860,16 @@ dkimf_db_walk(DKIMF_DB db, _Bool first, void *key, size_t *keylen,
58325860
(key == NULL && keylen != NULL))
58335861
return -1;
58345862

5835-
if (db->db_type == DKIMF_DB_TYPE_REFILE ||
5836-
db->db_type == DKIMF_DB_TYPE_SOCKET ||
5837-
db->db_type == DKIMF_DB_TYPE_LUA)
5838-
return -1;
5839-
58405863
switch (db->db_type)
58415864
{
5865+
case DKIMF_DB_TYPE_REFILE:
5866+
case DKIMF_DB_TYPE_SOCKET:
5867+
case DKIMF_DB_TYPE_LUA:
5868+
case DKIMF_DB_TYPE_MEMCACHE:
5869+
{
5870+
/* This operation does not support these type of dbs. */
5871+
return -1;
5872+
}
58425873
case DKIMF_DB_TYPE_CSL:
58435874
case DKIMF_DB_TYPE_FILE:
58445875
{

opendkim/opendkim-db.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ extern int dkimf_db_rewalk __P((DKIMF_DB, char *, DKIMF_DBDATA, unsigned int,
9494
extern void dkimf_db_set_ldap_param __P((int, char *));
9595
extern int dkimf_db_strerror __P((DKIMF_DB, char *, size_t));
9696
extern int dkimf_db_type __P((DKIMF_DB));
97+
extern _Bool dkimf_db_can_walk __P((DKIMF_DB));
9798
extern int dkimf_db_walk __P((DKIMF_DB, _Bool, void *, size_t *,
9899
DKIMF_DBDATA, unsigned int));
99100

opendkim/opendkim.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8339,7 +8339,9 @@ dkimf_config_load(struct config *data, struct dkimf_config *conf,
83398339
** missing KeyTable entries.
83408340
*/
83418341

8342-
if (conf->conf_signtabledb != NULL && conf->conf_checksigningtable != FALSE)
8342+
if (conf->conf_checksigningtable &&
8343+
conf->conf_signtabledb != NULL &&
8344+
dkimf_db_can_walk(conf->conf_signtabledb))
83438345
{
83448346
_Bool first = TRUE;
83458347
_Bool found;

0 commit comments

Comments
 (0)