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

Rend2 out-of-bounds write while outside the map in the negative direction. #1189

Open
Charlese2 opened this issue Nov 15, 2023 · 1 comment

Comments

@Charlese2
Copy link

Reporting a bug? Please make sure you've given the following information - thanks!

Operating system and version:
Windows 11 Version 22H2 (OS build 22621.2428)

Is this for single player or multiplayer?
Multiplayer

Description of the bug (and if possible, steps to reproduce the bug):
The Remainder of a negative Dividend with a positive Divisor can be a negative number. For example this modulo -1 % 3 would result in -1. If centerZoneOffsetX (or Y) is a low enough number by noclipping outside the map while going in a negative direction, it will make the Dividend negative.

chunkIndex = (int(centerZoneOffsetX + numMinZonesX) + x + 1) % 3;
chunkIndex += (int(centerZoneOffsetY + numMinZonesY) + y + 1) % 3 * 3;
VectorSet2(
zoneOffsets[chunkIndex],
x,
y);

If chunkIndex ends up as a negative number it writes outside of the zoneOffsets buffer.
vec2_t zoneOffsets[9];

What did you expect to happen instead?
I expected it to not crash from stack corruption from noclipping outside the map. I know it is a obscure use case.

@zen-v0
Copy link

zen-v0 commented Nov 15, 2023

I was able to replicate this on vjun1.
Will fix and open up a PR.

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