From b307b63074fd4c00b79061e7106233e1dd3c370a Mon Sep 17 00:00:00 2001
From: Brian Carrier <carrier@sleuthkit.org>
Date: Wed, 12 Nov 2008 01:05:17 +0000
Subject: [PATCH] Fixed bug 2265927 (ifind crash)

---
 CHANGES.txt         |  2 ++
 tsk3/fs/ifind_lib.c | 14 +++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 2dcda4038..0b8846289 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,8 @@
 ---------------- VERSION 3.1.0 --------------
 10/26/08: Update: Removed 'docs' files and moved them to the wiki.
 
+11/11/08: Bug Fix: Fixed crashing bug in ifind on FAT file system.  Bug: 2265927
+
 ---------------- VERSION 3.0.0 --------------
 0/00/00: Update: Many, many, many API changes.
 
diff --git a/tsk3/fs/ifind_lib.c b/tsk3/fs/ifind_lib.c
index 78e20a8e6..b7932921c 100644
--- a/tsk3/fs/ifind_lib.c
+++ b/tsk3/fs/ifind_lib.c
@@ -246,7 +246,7 @@ tsk_fs_path2inum(TSK_FS_INFO * a_fs, const char *a_path,
              */
             if (TSK_FS_TYPE_ISFFS(a_fs->ftype)
                 || TSK_FS_TYPE_ISEXT(a_fs->ftype)) {
-                if (strcmp(fs_file->name->name, cur_dir) == 0) {
+                if ((fs_file->name->name) && (strcmp(fs_file->name->name, cur_dir) == 0)) {
                     found_name = 1;
                 }
             }
@@ -254,18 +254,18 @@ tsk_fs_path2inum(TSK_FS_INFO * a_fs, const char *a_path,
              * the short name 
              */
             else if (TSK_FS_TYPE_ISFAT(a_fs->ftype)) {
-                if (strcasecmp(fs_file->name->name, cur_dir) == 0) {
+                if ((fs_file->name->name) && (strcasecmp(fs_file->name->name, cur_dir) == 0)) {
                     found_name = 1;
                 }
-                else if (strcasecmp(fs_file->name->shrt_name,
-                        cur_dir) == 0) {
+                else if ((fs_file->name->shrt_name) && (strcasecmp(fs_file->name->shrt_name,
+                        cur_dir) == 0)) {
                     found_name = 1;
                 }
             }
 
             /* NTFS gets a case insensitive comparison */
             else if (TSK_FS_TYPE_ISNTFS(a_fs->ftype)) {
-                if (strcasecmp(fs_file->name->name, cur_dir) == 0) {
+                if ((fs_file->name->name) && (strcasecmp(fs_file->name->name, cur_dir) == 0)) {
                     /*  ensure we have the right attribute name */
                     if (cur_attr == NULL) {
                         found_name = 1;
@@ -282,8 +282,8 @@ tsk_fs_path2inum(TSK_FS_INFO * a_fs, const char *a_path,
                                 if (!fs_attr)
                                     continue;
 
-                                if (strcasecmp(fs_attr->name,
-                                        cur_attr) == 0) {
+                                if ((fs_attr->name) && (strcasecmp(fs_attr->name,
+                                        cur_attr) == 0)) {
                                     found_name = 1;
                                 }
                             }
-- 
GitLab