Skip to content

Use an IPA type for flow states #473

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

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,24 @@ class ReallocationFunction extends AllocationFunction {
ReallocationFunction() { exists(this.getReallocPtrArg()) }
}

/**
* A data-flow state for a pointer which has not been reallocated.
*/
class IndirectCastDefaultFlowState extends DataFlow::FlowState {
IndirectCastDefaultFlowState() { this = "IndirectCastDefaultFlowState" }
}

/**
* A data-flow state for a pointer which has been reallocated but
* has not yet been zeroed with a memset call.
*/
class IndirectCastReallocatedFlowState extends DataFlow::FlowState {
IndirectCastReallocatedFlowState() { this = "IndirectCastReallocatedFlowState" }
}
newtype IndirectCastFlowState =
/**
* A data-flow state for a pointer which has not been reallocated.
*/
IndirectCastDefaultFlowState() or
/**
* A data-flow state for a pointer which has been reallocated but
* has not yet been zeroed with a memset call.
*/
IndirectCastReallocatedFlowState()

/**
* A data-flow configuration to track the flow from cast expressions to either
* other cast expressions or to dereferences of pointers reallocated with a call
* to `realloc` but not cleared via a function call to `memset`.
*/
module IndirectCastConfig implements DataFlow::StateConfigSig {
class FlowState = DataFlow::FlowState;
class FlowState = IndirectCastFlowState;

predicate isSource(DataFlow::Node source, FlowState state) {
state instanceof IndirectCastDefaultFlowState and
Expand Down