Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid what coverity calls "downcasting" (CID #1542293) #5170

Merged
merged 1 commit into from
Sep 28, 2023

Conversation

jejones3141
Copy link
Contributor

packet->data is a uint8_t * formerly cast to dhcp_packet_t const * to be passed to fr_dhcpv4_packet_get_option(). dhcp_packet_t is more strictly aligned than uint8_t, so coverity considers this a "tainted_data_downcast" and infers that the pointed-at data is tainted.

To avoid the issue, the talloc_memdup() result is assigned first to a dhcp_packet_t * to pass to fr_dhcpv4_packet_get_option(), and cast to (uint8_t *) to assign to packet->data.

packet->data is a uint8_t * formerly cast to dhcp_packet_t const *
to be passed to fr_dhcpv4_packet_get_option(). dhcp_packet_t is
more strictly aligned than uint8_t, so coverity considers this a
"tainted_data_downcast" and infers that the pointed-at data is
tainted.

To avoid the issue, the talloc_memdup() result is assigned first
to a dhcp_packet_t * to pass to fr_dhcpv4_packet_get_option(),
and cast to (uint8_t *) to assign to packet->data.
@arr2036 arr2036 merged commit 73ffc12 into FreeRADIUS:master Sep 28, 2023
@jejones3141 jejones3141 deleted the downcast branch September 28, 2023 18:20
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.

2 participants