Skip to content

Fix four crash and memory-safety bugs (issues #18, #140, #152, #256)#298

Open
thegushi wants to merge 1 commit into
developfrom
fix/crashes-18-140-152-256
Open

Fix four crash and memory-safety bugs (issues #18, #140, #152, #256)#298
thegushi wants to merge 1 commit into
developfrom
fix/crashes-18-140-152-256

Conversation

@thegushi
Copy link
Copy Markdown
Collaborator

Summary

Closes #18, #140, #152, #256. Tracked in #297.

Test plan

#256 - opendmarc_policy_fetch_ruf(): || should be && when guarding the
memset() call. The condition (list_buf != NULL || size_of_buf > 0) would
call memset(NULL, '\0', size) when list_buf is NULL but size_of_buf is
non-zero, causing a segfault. Changed to &&, matching the identical guard
already used correctly in opendmarc_policy_fetch_rua(). Regression test
added to test_dmarc_fetch.c.

#18 - dmarcf_config_free(): remove assert(conf->conf_refcnt == 0). Several
shutdown and config-reload call sites invoke dmarcf_config_free() without
first checking the refcount, so the assert can fire on normal teardown
paths, aborting the daemon.

#140 - mlfi_envfrom(): replace strncpy(mctx_envdomain, p+1, BUFRSZ) with
strlcpy(..., sizeof mctx_envdomain). strncpy does not guarantee
null-termination when the source fills the buffer; strlcpy always does.

#152 - Bump MAXHEADER from 1024 to 4096 in opendmarc.h. Two snprintf()
calls building the Authentication-Results header can produce ~2080 bytes;
the old 1025-byte buffer caused silent truncation of outgoing headers.
Also fix the off-by-one inconsistency in opendmarc-ar.c (MAXHEADER+2
-> MAXHEADER+1).
@dilyanpalauzov
Copy link
Copy Markdown
Contributor

It has to be evaluated, if the field ref_cnt is still needed.

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

Labels

needs-testing Item in a testing branch, feedback required to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants