> Do not use fixed size buffers with variable sized data - always calculate how much space you’ll need and allocate it.
Actually, sometimes it is best to have a fixed size buffer, sized appropriately for the maximum data-bytes allowed as per design. Especially true for embedded systems where dynamic allocation is usually frowned upon.