Jump to content

leebo

Members
  • Posts

    1
  • Joined

  • Last visited

Reputation

2 Neutral

2 Followers

Profile Information

  • Gender
    Male
  1. I don`t think the problem is within this function itself. It`s probably failing because the dest buffer is too small to hold the data that is being put into it. This could theoretically happen if a super long run was decompressed prior to copying the next character from src to dest (I`m referring to the line that causes the exception). Now, of course, this shouldn`t happen assuming the src buffer is properly encoded so it probably isn`t properly encoded. If you haven`t done so already, I would just put a little piece of protective code in this function to prevent it from overflowing the dest buffer. Working backwards (in soda`s original server code), it looks like the size of the dest buffer is ultimately (ultima-tely (lol)) defined by TCP_BUFFER_SIZE which should be 65530 bytes by default which means the function knows it should never write more than TCP_BUFFER_SIZE bytes to the dest buffer. When it tries to do this, you could save a dump of the entire src buffer somewhere for later inspection. You should be able to apply the same reasoning to every method in the call stack until the problem is found and then you could remove the protective code afterwards if you choose to do so. By the way exceptions would be REALLY nice here but unfortunately C doesn`t support exceptions. I`m not really familiar with the context for this code but if it`s trying to decompress a chunk of data that comes from the game client, the server shouldn`t expect it to be encoded properly. Unscrupulous individuals could theoretically hand-craft such a malicious piece of data to crash the server. Anyways, putting in some protective code should help you to at least prevent the program from crashing even if you have to close a socket or something to keep it alive.That`s my 2 cents!
×
×
  • Create New...