use size_t for strbuffer writes, and avoid integer overflow