Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ntfs.c #2904

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 23 additions & 11 deletions tsk/fs/ntfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ nt2unixtime(uint64_t ntdate)
// return 0 if before 1970
if (ntdate < NSEC_BTWN_1601_1970)
return 0;

ntdate -= (uint64_t) NSEC_BTWN_1601_1970;
ntdate /= (uint64_t) 10000000;

Expand Down Expand Up @@ -5314,13 +5314,25 @@ ntfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset,
goto on_error;
}

if ((ntfs->fs->csize != 0x01) &&
(ntfs->fs->csize != 0x02) &&
(ntfs->fs->csize != 0x04) &&
(ntfs->fs->csize != 0x08) &&
(ntfs->fs->csize != 0x10) &&
(ntfs->fs->csize != 0x20) && (ntfs->fs->csize != 0x40)
&& (ntfs->fs->csize != 0x80)) {
uint32_t csize = ntfs->fs->csize;
if (ntfs->fs->csize > 0x80) {
csize = 1 << -(int8_t)ntfs->fs->csize;
}

if ((csize != 0x01) &&
(csize != 0x02) &&
(csize != 0x04) &&
(csize != 0x08) &&
(csize != 0x10) &&
(csize != 0x20) &&
(csize != 0x40) &&
(csize != 0x80) &&
(csize != 0x100) &&
(csize != 0x200) &&
(csize != 0x400) &&
(csize != 0x800) &&
(csize != 0x1000)
) {
tsk_error_reset();
tsk_error_set_errno(TSK_ERR_FS_MAGIC);
tsk_error_set_errstr
Expand All @@ -5332,14 +5344,14 @@ ntfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset,
goto on_error;
}

ntfs->csize_b = ntfs->fs->csize * ntfs->ssize_b;
ntfs->csize_b = csize * ntfs->ssize_b;
fs->first_block = 0;
/* This field is defined as 64-bits but according to the
* NTFS drivers in Linux, old Windows versions used only 32-bits
*/
fs->block_count =
(TSK_DADDR_T) tsk_getu64(fs->endian,
ntfs->fs->vol_size_s) / ntfs->fs->csize;
ntfs->fs->vol_size_s) / csize;
if (fs->block_count == 0) {
tsk_error_reset();
tsk_error_set_errno(TSK_ERR_FS_MAGIC);
Expand Down Expand Up @@ -5532,7 +5544,7 @@ ntfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset,
"ssize: %" PRIu16
" csize: %d serial: %" PRIx64 "\n",
tsk_getu16(fs->endian, ntfs->fs->ssize),
ntfs->fs->csize, tsk_getu64(fs->endian, ntfs->fs->serial));
csize, tsk_getu64(fs->endian, ntfs->fs->serial));
tsk_fprintf(stderr,
"mft_rsize: %d idx_rsize: %d vol: %d mft: %"
PRIu64 " mft_mir: %" PRIu64 "\n",
Expand Down