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

Out of bounds access in CStudioModelRenderer::StudioSetupBones #3360

Open
SamVanheer opened this issue Aug 12, 2023 · 2 comments
Open

Out of bounds access in CStudioModelRenderer::StudioSetupBones #3360

SamVanheer opened this issue Aug 12, 2023 · 2 comments

Comments

@SamVanheer
Copy link

The studio model renderer accesses bone data using an invalid index here:

else if ( !strcmp( pbones[ pbones[i].parent ].name, "Bip01 Pelvis" ) )

Bones that don't have a parent have a parent index of -1. This code thus treats the memory region right before the first bone to be a bone as well. Since the entire model is loaded into a contiguous chunk of memory this is accessing another part of the model and reinterpreting it. This is also why it doesn't crash due to accessing invalid memory.

It is also possible to access out of bounds memory if the parent index is invalid.

This can be fixed by adding bounds checking to that code. Additionally bounds checking in the model loading code can help catch invalid access as well.

SamVanheer added a commit to twhl-community/halflife-updated that referenced this issue Aug 12, 2023
@tschumann
Copy link

tschumann commented Aug 16, 2023 via email

@SamVanheer
Copy link
Author

You can see how i fixed here: twhl-community/halflife-updated@68bb362

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

No branches or pull requests

2 participants