Skip to content

Commit

Permalink
Prevent OOB read in tsk_unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Feb 23, 2025
1 parent b6e53ee commit 87bc3aa
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tsk/fs/ntfs_dent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,9 @@ ntfs_proc_idxentry(NTFS_INFO * a_ntfs, TSK_FS_DIR * a_fs_dir,

/* do some sanity checks on the deleted entries
*/
uint16_t idxlen = tsk_getu16(fs->endian, a_idxe->idxlen);
if ((tsk_getu16(fs->endian, a_idxe->strlen) == 0) ||
(((uintptr_t) a_idxe + tsk_getu16(fs->endian,
a_idxe->idxlen)) > endaddr_alloc)) {
((uintptr_t) a_idxe + idxlen > endaddr_alloc)) {

/* name space checks */
if ((fname->nspace != NTFS_FNAME_POSIX) &&
Expand Down Expand Up @@ -513,7 +513,12 @@ ntfs_proc_idxentry(NTFS_INFO * a_ntfs, TSK_FS_DIR * a_fs_dir,
continue;
}
}

// WARNING: tsk_UTF16toUTF8 used in ntfs_dent_copy_short_only cannot check for
// all out of bounds cases.
if ((uintptr_t) a_idxe + idxlen > endaddr_alloc) {
a_idxe = (ntfs_idxentry *) ((uintptr_t) a_idxe + 4);
continue;
}

/* For all fname entries, there will exist a DOS style 8.3
* entry.
Expand Down

0 comments on commit 87bc3aa

Please sign in to comment.