Skip to content

Commit

Permalink
More fixes to the internal SPF implementation:
Browse files Browse the repository at this point in the history
* In opendmarc_spf_reverse(), fix a typo that caused the string to be flipped
  on the wrong delimiter (i.e., not flipped at all), which fixes the "ptr"
  mechanism's subdomain testing.
* In opendmarc_spf_dns_lookup_a(), handle the return values of the lookup
  functions appropriately.  This plugs a memory leak and resolves some
  false negatives.
  • Loading branch information
Murray S. Kucherawy committed Apr 15, 2021
1 parent 5ed1d6e commit 2cdffd3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libopendmarc/opendmarc_spf.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ opendmarc_spf_reverse(char *str, char *buf, size_t buflen)

dotp = strchr(dupe, '.');
if (dotp != NULL)
dotorcolon = ',';
dotorcolon = '.';
else
{
dotp = strchr(dupe, ':');
Expand Down
24 changes: 19 additions & 5 deletions libopendmarc/opendmarc_spf_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,21 +219,35 @@ opendmarc_spf_dns_lookup_a_actual(char *domain, int sought, char **ary, int *cnt
** cnt -- Pointer to count of lines in array
** Returns:
** ary -- on success
** NULL -- otherise, and place the h_errno error into reply
** NULL -- otherwise, and place the h_errno error into reply
** Side Effects:
** Makes a connection to the local name server and blocks
** waiting for a reply.
***************************************************************************************************/
char **
opendmarc_spf_dns_lookup_a(char *domain, char **ary, int *cnt)
{
char **retp;
bool found = FALSE;
char **a_retp;
char **aaaa_retp;

a_retp = opendmarc_spf_dns_lookup_a_actual(domain, T_A, ary, cnt);
if (a_retp != (char **) NULL)
{
ary = a_retp;
found = TRUE;
}

retp = opendmarc_spf_dns_lookup_a_actual(domain, T_A, ary, cnt);
#ifdef T_AAAA
retp = opendmarc_spf_dns_lookup_a_actual(domain, T_AAAA, retp, cnt);
aaaa_retp = opendmarc_spf_dns_lookup_a_actual(domain, T_AAAA, ary, cnt);
if (aaaa_retp != (char **) NULL)
{
ary = aaaa_retp;
found = TRUE;
}
#endif /* T_AAAA */
return retp;

return *cnt > 0 ? ary : NULL;
}

/***************************************************************************************************
Expand Down

0 comments on commit 2cdffd3

Please sign in to comment.