Fix a few more coverity issues around potential buffer overflows.