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

Handle out of bound access in D3DX12ParsePipelineStream #147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RuslanKutdusov
Copy link

Hi, was working on some project that uses DirectX-Headers, launched it with Asan and catched out of bound reads. This pull request fixes it

@@ -1362,126 +1362,197 @@ inline HRESULT D3DX12ParsePipelineStream(const D3D12_PIPELINE_STATE_STREAM_DESC&
pCallbacks->ErrorDuplicateSubobject(SubobjectType);
return E_INVALIDARG; // disallow subobject duplicates in a stream
}
switch (SubobjectType)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since all these sizes are static, this seems like a switch statement isn't particular efficient as an implementation.

Why note create a const static array indexed by SubobjectType that has the sizeof in it? That way the look-up in trivial and the information is encoded in the readonly dataseg instead of as a code jumptable? The only reason the size was in the original switch statement is it already needed the code-paths for the callbacks.

Some use of static_assert should make it easy to notice when new pipeline state values are added as well as the runtime error.

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