Skip to content

Conversation

smallmodel
Copy link

@smallmodel smallmodel commented Apr 19, 2025

Currently for example, if bit is 65536 and maxsize is 8192, then cursize would be (65536 >> 3) + 1 = 8193, after the maximum size. (Netchan_Transmit would drop an error when trying to send more than 49152 bytes)
This commit simply sets the overflow flag when the number of bits written reaches the maximum size.

I didn't find better solutions. I first found this one solution:

msg->cursize = (msg->bit>>3);
if (msg->bit & 7)
  msg->cursize++;

However this change must be made in MSG_ReadBits as well, which would break compatibility with existing clients.

@WofWca
Copy link

WofWca commented Jun 12, 2025

However this change must be made in MSG_ReadBits as well, which would break compatibility with existing clients.

Are you saying that this MR cannot be merged at its current state?

@smallmodel
Copy link
Author

The PR is ok, the commit only changes a condition so the number of bits read/written can't be greater than or equal the maximum bit size

@timangus
Copy link
Member

Does this fix a bug you've actually experienced, or I guess put another way, how did you come across this?

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.

3 participants