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

buffer overrun in mii_disk.c #24

Open
jawaidbazyar2 opened this issue Jan 4, 2025 · 0 comments
Open

buffer overrun in mii_disk.c #24

jawaidbazyar2 opened this issue Jan 4, 2025 · 0 comments

Comments

@jawaidbazyar2
Copy link

Hi, I was testing this code in another program:

uint8_t nibbles[0x156] = {};
const unsigned ptr2 = 0;
const unsigned ptr6 = 0x56;

int i2 = 0x55;
for (int i6 = 0x101; i6 >= 0; --i6) {
	uint8_t val6 = data[i6 % 0x100];
	uint8_t val2 = nibbles[ptr2 + i2];
	val2 = (val2 << 1) | (val6 & 1); val6 >>= 1;
	val2 = (val2 << 1) | (val6 & 1); val6 >>= 1;
	nibbles[ptr6 + i6] = val6;
	nibbles[ptr2 + i2] = val2;
	if (--i2 < 0)
		i2 = 0x55;
}

The buffer nibbles (0x156) is not large enough, as you are accessing in the first loop with index:

ptr6 (value 0x56) plus i6 (value 0x101 first time through loop) == index 0x157; that is two bytes more than you have allocated.

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

1 participant