Avoid potential buffer overflow in make_filename()