Fix possible buffer overflows.