From 5354d2f6cafa7b663cb19c0bbf20270c2e84f858 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 27 Oct 2013 00:05:54 +0100 Subject: [PATCH] [iso] sanitize invalid FAT & NFTS filenames * Also fix support for labels containing double quotes * Closes #135 * Closes #193 --- src/format.c | 2 +- src/iso.c | 29 +++++++++++++++++++++++++++-- src/rufus.rc | 10 +++++----- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/format.c b/src/format.c index 9a713fcf..8210d260 100644 --- a/src/format.c +++ b/src/format.c @@ -206,7 +206,7 @@ static void ToValidLabel(WCHAR* name, BOOL bFAT) { size_t i, j, k; BOOL found; - WCHAR unauthorized[] = L"*?,;:/\\|+=<>[]"; + WCHAR unauthorized[] = L"*?,;:/\\|+=<>[]\""; WCHAR to_underscore[] = L"\t."; if (name == NULL) diff --git a/src/iso.c b/src/iso.c index 33364e11..cfc482ab 100644 --- a/src/iso.c +++ b/src/iso.c @@ -91,6 +91,25 @@ static __inline char* size_to_hr(int64_t size) return str_size; } +// Ensure filenames do not contain invalid FAT32 or NTFS characters +static __inline BOOL sanitize_filename(char* filename) +{ + size_t i, j; + BOOL ret = FALSE; + char unauthorized[] = {'<', '>', ':', '|', '*', '?'}; + + // Must start after the drive part (D:\...) so that we don't eliminate the first column + for (i=2; i