From 4532571bdfd5fac4ec06969b00e45260094d42ce Mon Sep 17 00:00:00 2001 From: Dan Mahoney Date: Mon, 22 Jun 2026 18:28:28 -0400 Subject: [PATCH 1/2] fix: quiet -Walloc-size-larger-than and -Wformat-truncation warnings OPENDMARC_MAX_SHELVES_LG2 was derived from sizeof(size_t) under the assumption that OPENDMARC_HASH_SHELF is <= 32 bytes, but it actually holds a pthread_mutex_t and runs 48-72 bytes depending on platform, so the theoretical max calloc() request could exceed the allocator limit. The only real caller asks for 8192 buckets, so cap the table size at a fixed, generous bound instead. MAXHEADER was sized so that a maxed-out authservid_hdr plus a maxed-out From-domain could together exceed the malloc'd header buffer, risking silent truncation of the Authentication-Results header in pathological cases. Double it so the worst case fits. --- libopendmarc/opendmarc_internal.h | 11 ++++++++--- opendmarc/opendmarc.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libopendmarc/opendmarc_internal.h b/libopendmarc/opendmarc_internal.h index 3e8f771b..703d5520 100644 --- a/libopendmarc/opendmarc_internal.h +++ b/libopendmarc/opendmarc_internal.h @@ -209,10 +209,15 @@ typedef struct { #define OPENDMARC_MIN_SHELVES (1 << OPENDMARC_MIN_SHELVES_LG2) /* - * max * sizeof internal_entry must fit into size_t. - * assumes internal_entry is <= 32 (2^5) bytes. + * Largest table size opendmarc_hash_init() will honor. The real + * caller (opendmarc_tld.c) only ever asks for 8192; this just keeps a + * runaway or hostile tablesize argument from reaching calloc(). Fixed + * well below any allocator limit rather than derived from sizeof(size_t), + * since the size of OPENDMARC_HASH_SHELF (which includes a pthread_mutex_t) + * varies by platform and a sizeof-derived bound can creep past what + * calloc() will actually allocate. */ -#define OPENDMARC_MAX_SHELVES_LG2 (sizeof (size_t) * 8 - 1 - 5) +#define OPENDMARC_MAX_SHELVES_LG2 24 #define OPENDMARC_MAX_SHELVES ((size_t)1 << OPENDMARC_MAX_SHELVES_LG2) typedef struct { diff --git a/opendmarc/opendmarc.h b/opendmarc/opendmarc.h index 08ef5190..24ccbae7 100644 --- a/opendmarc/opendmarc.h +++ b/opendmarc/opendmarc.h @@ -37,7 +37,7 @@ #define REPORTCMD_EXIT_SUPPRESSED 2 /* ReportCommand sent nothing; all recipients were suppressed by policy (e.g. NoReportsList/StaleMARC), not an error */ #define JOBIDUNKNOWN "(unknown-jobid)" #define MAXARGV 65536 -#define MAXHEADER 4096 +#define MAXHEADER 8192 #define TEMPFILE "/var/tmp/dmarcXXXXXX" #define AUTHRESULTSHDR "Authentication-Results" From b36b4fcce8e4eb50ad138f24589febfadc039956 Mon Sep 17 00:00:00 2001 From: Dan Mahoney Date: Mon, 22 Jun 2026 21:23:57 -0400 Subject: [PATCH 2/2] fix: enable subdir-objects to quiet automake forward-incompat warning test_arcares and test_spf_parse pull source files from $(top_srcdir)/opendmarc/, which automake warns will become a hard error in a future release without subdir-objects enabled. Verified make check still passes (13/13) with objects now placed in a path mirroring their source tree instead of being flattened. --- libopendmarc/tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/libopendmarc/tests/Makefile.am b/libopendmarc/tests/Makefile.am index 59f8a7a5..0e900d85 100644 --- a/libopendmarc/tests/Makefile.am +++ b/libopendmarc/tests/Makefile.am @@ -1,3 +1,4 @@ +AUTOMAKE_OPTIONS = subdir-objects SUBDIRS=testfiles LDADD = ../libopendmarc.la $(LIBRESOLV) AM_CPPFLAGS = -I.. -I../..