Prevent buffer overflow crashes on long filenames