From 563cd3b45a1926422e6ee04ff89ad1ea53b92fc0 Mon Sep 17 00:00:00 2001
From: Brian Carrier <carrier@sleuthkit.org>
Date: Fri, 27 May 2011 13:50:30 +0000
Subject: [PATCH] cleanup non-ASCII volume label names

---
 tsk3/fs/fatfs_meta.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tsk3/fs/fatfs_meta.c b/tsk3/fs/fatfs_meta.c
index 788eae5f6..5175867d8 100644
--- a/tsk3/fs/fatfs_meta.c
+++ b/tsk3/fs/fatfs_meta.c
@@ -471,6 +471,16 @@ fatfs_dinode_copy(FATFS_INFO * fatfs, TSK_FS_META * fs_meta,
                 fs_meta->name2->name[i++] = in->ext[a];
         }
         fs_meta->name2->name[i] = '\0';
+
+        /* clean up non-ASCII because we are
+         * copying it into a buffer that is supposed to be UTF-8 and
+         * we don't know what encoding it is actually in or if it is 
+         * simply junk. */
+        for (i = 0; fs_meta->name2->name[i] != '\0'; i++) {
+            if ((unsigned char)(fs_meta->name2->name[i]) > 0x7e) {
+                fs_meta->name2->name[i] = '^';
+            }
+        }
     }
     /* If the entry is a normal short entry, then copy the name
      * and add the '.' for the extension
-- 
GitLab