Fix bug 6546: Avoid accessing buf[-1] if NUL byte comes from fgets