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

Fix issue #229: fix db handling on verification of SigningTable in dkimf_config_load #230

Open
wants to merge 2 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
28 changes: 23 additions & 5 deletions opendkim/opendkim.c
Original file line number Diff line number Diff line change
Expand Up @@ -8333,20 +8333,23 @@ dkimf_config_load(struct config *data, struct dkimf_config *conf,
char selector[BUFRSZ + 1];
char keydata[BUFRSZ + 1];
char signer[BUFRSZ + 1];
int db_stat;

dbd[0].dbdata_flags = 0;

memset(keyname, '\0', sizeof keyname);
/*
** As we don't care signer values here,
** we don't need to clear it.
*/

dbd[0].dbdata_buffer = keyname;
dbd[0].dbdata_buflen = sizeof keyname - 1;
dbd[0].dbdata_flags = 0;
dbd[1].dbdata_buffer = signer;
dbd[1].dbdata_buflen = sizeof signer - 1;
dbd[1].dbdata_flags = 0;
dbd[1].dbdata_flags = DKIMF_DB_DATA_OPTIONAL;

while (dkimf_db_walk(conf->conf_signtabledb, first,
NULL, NULL, dbd, 2) == 0)
while ((db_stat = dkimf_db_walk(conf->conf_signtabledb,
first, NULL, NULL, dbd, 2)) == 0)
{
first = FALSE;
found = FALSE;
Expand All @@ -8359,6 +8362,11 @@ dkimf_config_load(struct config *data, struct dkimf_config *conf,
dbd[2].dbdata_buffer = keydata;
dbd[2].dbdata_buflen = sizeof keydata - 1;
dbd[2].dbdata_flags = DKIMF_DB_DATA_BINARY;
/*
** As we don't care for values of the entry
** in KeyTable here, we don't need to clear
** buffers for them.
*/

if (dkimf_db_get(conf->conf_keytabledb,
keyname, strlen(keyname),
Expand All @@ -8379,6 +8387,16 @@ dkimf_config_load(struct config *data, struct dkimf_config *conf,
dbd[0].dbdata_buffer = keyname;
dbd[0].dbdata_buflen = sizeof keyname - 1;
dbd[0].dbdata_flags = 0;
dbd[1].dbdata_buffer = signer;
dbd[1].dbdata_buflen = sizeof signer - 1;
dbd[1].dbdata_flags = DKIMF_DB_DATA_OPTIONAL;
}
if (db_stat == -1)
{
snprintf(err, errlen,
"error on retrieving an entry from \"%s\"",
conf->conf_signtable);
return -1;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion opendkim/tests/t-sign-rs-tables-bad.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Background No
Canonicalization relaxed/simple
RequireSafeKeys No
KeyTable file:t-sign-rs-tables-bad.keys
SigningTable file:t-sign-rs-tables.sign
SigningTable refile:t-sign-rs-tables.sign