Skip to content

Fix dangling hostname pointer in dns_poller; review cleanups#208

Open
aarond10 wants to merge 1 commit into
masterfrom
fixes
Open

Fix dangling hostname pointer in dns_poller; review cleanups#208
aarond10 wants to merge 1 commit into
masterfrom
fixes

Conversation

@aarond10

Copy link
Copy Markdown
Owner

The hostname buffer passed to dns_poller_init() is block-scoped in main() since 6b4de73, but the poller stored the raw pointer and read it on every poll cycle after the block exited — use of a dead stack object. Copy the hostname in dns_poller_init() and free it in dns_poller_cleanup() instead of relying on the caller's buffer lifetime. The poller owns the copy, so the struct member is a plain char * (no const cast needed to free it).

Also:

  • flipped clang-tidy from wildcard check to finer grained checks to avoid pulling in irrelevant stuff like altera-struct-pack-align.
  • main.c: check the dns_poller calloc for NULL like every other allocation site; validate -R as an IPv4/IPv6 literal before building the curl resolve entry; warn when -R is ignored because the resolver URL already contains an IP address
  • doh_proxy.c: don't crash if doh_proxy_await_bootstrap() was given a NULL callback

The hostname buffer passed to dns_poller_init() is block-scoped in main()
since 6b4de73, but the poller stored the raw pointer and read it on every
poll cycle after the block exited — use of a dead stack object. Copy the
hostname in dns_poller_init() and free it in dns_poller_cleanup() instead
of relying on the caller's buffer lifetime. The poller owns the copy, so
the struct member is a plain char * (no const cast needed to free it).

Also:
- flipped clang-tidy from wildcard check to finer grained checks
  to avoid pulling in irrelevant stuff like altera-struct-pack-align.
- main.c: check the dns_poller calloc for NULL like every other
  allocation site; validate -R as an IPv4/IPv6 literal before building
  the curl resolve entry; warn when -R is ignored because the resolver
  URL already contains an IP address
- doh_proxy.c: don't crash if doh_proxy_await_bootstrap() was given a
  NULL callback
@aarond10

Copy link
Copy Markdown
Owner Author

@baranyaib90, thoughts on any of this?

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