make sure data buffers don't overflow