A really dumb buffer overflow

About ten minutes ago I fixed a really stupid bug in the code that I’m currently working on. A lot of what I’m writing recently isn’t great and has been cobbled together rather hastily. The bug is a buffer overflow that occurs when writing to a temporary buffer for display to the VMU. On the server the Y position is decremented every update step, which counts up pretty quick. By default the output was displaying the number to five decimal places. No problem for numbers up to -99.00000 seeing as the line was printed as “Y: -99.00000” the issue is that there are only twelve characters total for each line. This quickly resulted in going beyond the bounds of the array and corrupting other things in the stack. The main thing I was concerned with during that particular debugging session was the number of entities. This was stored close to the print buffer and ended up being wildly too large for normal operation. A lot more items than the lone entity, at any rate.

I thought it was amusing enough to write a short entry on before stopping for the day. The good news is that entities can be updated well enough, but I’ve acquired some baggage from bad decisions made during the creation of the ECS that I’ll have to address before moving forward.