Skip to content

fix: resolve char/u_char pointer-sign compiler warnings#426

Merged
thegushi merged 1 commit into
trusteddomainproject:developfrom
thegushi:fix/pointer-sign-warnings
Jun 20, 2026
Merged

fix: resolve char/u_char pointer-sign compiler warnings#426
thegushi merged 1 commit into
trusteddomainproject:developfrom
thegushi:fix/pointer-sign-warnings

Conversation

@thegushi

Copy link
Copy Markdown
Collaborator

Summary

  • A non-CI build (clang on FreeBSD, no -Wno-pointer-sign) surfaced ~240 -Wpointer-sign warnings from the long-standing char */u_char * mixing throughout libopendmarc and the milter, plus one stray nested-comment warning and one real -Wincompatible-pointer-types mismatch.
  • Adds explicit casts at each char/u_char boundary rather than changing declared types, matching the existing style already used elsewhere in these files.
  • Drops two backwards (u_char *) casts on dfc->mctx_jobid, which is actually declared char *.
  • Removes a duplicate stray /* inside an already-open block comment in opendmarc.c.
  • Fixes a genuine pointer-type mismatch in the ignorereceivers history path where locally-scoped char *user/domain were passed to a function expecting unsigned char **.

Test plan

  • Full clean make rebuild (libopendmarc, opendmarc milter w/ libmilter + libspf2, reports) with default CFLAGS (no -Wno-pointer-sign): 0 warnings, 0 errors
  • libopendmarc/tests: test_alignment, test_parse_to_buf, test_spf_parse all pass
  • opendmarc-check google.com runs correctly end-to-end

Adds explicit casts at the char*/u_char* boundary throughout
libopendmarc and the milter, eliminating -Wpointer-sign and a stray
nested-comment warning surfaced by a non-CI build (CI suppresses
these via -Wno-pointer-sign). Also drops two backwards casts on
dfc->mctx_jobid (char *) and fixes a real -Wincompatible-pointer-types
mismatch in the ignorereceivers history path.
@thegushi thegushi merged commit 087d44e into trusteddomainproject:develop Jun 20, 2026
2 checks passed
thegushi added a commit to thegushi/OpenDMARC that referenced this pull request Jun 21, 2026
Casts strdup() results back to u_char * for organizational_domain
assignments in query_dmarc_psl, query_dmarc_rfc7489_walk, and
query_dmarc_rfc9989_walk, matching the cast convention applied
elsewhere in trusteddomainproject#426.
thegushi added a commit that referenced this pull request Jun 21, 2026
* feat: add DMARCbis walk mode selection (RFC 9989 DNS Tree Walk)

Refactor organizational domain discovery in libopendmarc into three
independently-callable walk strategies selectable at runtime via a new
DMARCbisWalkMode config option in opendmarc.conf.

- Add OPENDMARC_WALK_MODE_{AUTO,PSL,RFC7489,RFC9989} constants and walk_mode
  field to OPENDMARC_LIB_T (dmarc.h.in)
- Add np= and psd= fields to DMARC_POLICY_T (opendmarc_internal.h)
- Extract dmarc_query_at(), psd_from_record(), query_dmarc_psl(),
  query_dmarc_rfc7489_walk(), and query_dmarc_rfc9989_walk() from the
  monolithic opendmarc_policy_query_dmarc(); dispatch by walk_mode
- Parse np= and psd= tags in opendmarc_policy_parse_dmarc()
- Wire DMARCbisWalkMode config key in opendmarc-config.h and opendmarc.c
- Document DMARCbisWalkMode in opendmarc.conf.sample and opendmarc.conf.5.in
- Add DMARCBIS-WALK-NOTES.txt capturing RFC 9989 open questions

AUTO mode preserves pre-DMARCbis behaviour (PSL if configured, label-strip
walk otherwise). No #ifdef compile-time gates.

* fix: discard multiple DMARC records at one name (RFC 7489 S 6.6.3, RFC 9989 S 4.10)

dmarc_dns_get_record() previously returned the first "v=DMARC" TXT record
found without checking for duplicates, silently violating the rule in both
RFCs that multiple valid DMARC records at a single DNS name must all be
discarded.

- Scan all TXT records in the answer before returning; count those
  containing "v=DMARC".  Return the record only when exactly one is found;
  return NULL/NO_DATA when zero or more than one are found.
- Fix the fake DNS table path with the same count-before-returning logic.
- Fix a pre-existing cursor advancement bug: the non-DMARC TXT branch was
  adding the already-consumed dn_expand name length a second time.  Replace
  ad-hoc cur_ptr arithmetic with an rdata_end pointer set from RDLENGTH.
- Add a fake-DNS test case: two v=DMARC1 entries for the same name must
  yield DMARC_DNS_ERROR_NO_RECORD.

* feat(survey): check RFC 7489 S 7.1 external reporting consent in pct-survey

For every rua= and ruf= URI whose destination domain differs from the
policy domain, query {policy-domain}._report._dmarc.{dest-domain} and
flag any that lack a v=DMARC1 consent record.

- New output columns rua_bad / ruf_bad: comma-separated list of external
  URIs missing consent, or "-" if none problematic
- Async consent-check phase after the main DNS loop, at full concurrency
- Same-domain and subdomain URIs skipped (no check needed)
- Output buffered until consent phase completes; then written in one pass
- Summary log gains rua_ext_bad / ruf_ext_bad columns for trend tracking

* fix: resolve pointer-sign warnings in DMARCbis walk-mode helpers

Casts strdup() results back to u_char * for organizational_domain
assignments in query_dmarc_psl, query_dmarc_rfc7489_walk, and
query_dmarc_rfc9989_walk, matching the cast convention applied
elsewhere in #426.

* docs: record AUTO-mode fallback scope decision in DMARCbis walk notes

Documents that AUTO mode's fallback to the RFC 7489 walk applies
whenever the PSL path fails, not only when no PSL boundary was found,
which is a deliberate broadening versus pre-refactor behavior.

---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant