Comments (3)
@ColinFinck Hey, thanks for all the explanations, make sense now. And ye this fixes all the new issues I had so you can make a minor bug fix with the changes.
I am fuzzing the latest version and it looks very promising ! No crashes nor infinite loops so far. I am gonna let it run for a while to see if it can found deeper bug but so far so good, I'll get back to you if I find something
from ntfs.
The fix 441ea7b for #24 introduced a new bug because
sector_position_end
still needs to be verified inside the loop because it is incremented at each iteration and so still needs to be checked.
sector_position
begins at NTFS_BLOCK_SIZE - mem::size_of::<u16>()
.
sector_position_end
begins at sector_position + mem::size_of::<u16>()
, hence it effectively begins at NTFS_BLOCK_SIZE
.
Both variables are incremented by NTFS_BLOCK_SIZE
in each iteration.
The loop runs while array_position < array_end
.
array_position
begins at update_sequence_array_start()
, which equals update_sequence_offset() + mem::size_of::<u16>()
.
array_end
is set to update_sequence_offset() + update_sequence_size()
, which equals update_sequence_offset() + update_sequence_count * mem::size_of::<u16>()
.
I'm incrementing array_position
by mem::size_of::<u16>()
in every iteration.
So to determine the number of iterations, we can calculate:
NumberOfIterations = (array_end - array_position) / mem::size_of::<u16>()
= (update_sequence_offset() + update_sequence_count * mem::size_of::<u16>() - update_sequence_offset() - mem::size_of::<u16>()) / mem::size_of::<u16>()
= (update_sequence_count * mem::size_of::<u16>() - mem::size_of::<u16>()) / mem::size_of::<u16>()
= update_sequence_count - 1
As a result, we know that sector_position_end
will be set to (update_sequence_count - 1) * NTFS_BLOCK_SIZE
at the end of the loop.
update_sequence_count - 1
is actually what I wanted to calculate in update_sequence_array_count()
.
Unfortunately, this also proves that I indeed messed up, because I'm subtracting mem::size_of::<u16>()
there instead of just 1
.
However, this calculation also shows that I can safely determine the final value of sector_position_end
beforehand, which is what I'm doing with the newly introduced sectors_end
variable in 441ea7b.
All of this can likely be simplified. But it's not necessary to check sector_position_end
in every iteration when we know the final value beforehand and can just check that once.
from ntfs.
Fixed this and #26 in 5cc2416
Please let me know if that fixes the particular crash you were hitting, then I will publish a bugfix release 0.3.1
from ntfs.
Related Issues (19)
- Multiply with oveflow when parsing malformed file system
- Panic when running ntfs_shell::dir in home directory HOT 4
- 2MB clusters lead to "The cluster size is 124928 bytes, but the maximum supported one is 2097152" HOT 3
- Large Sector Sizes HOT 1
- UEFI support HOT 2
- Publish a `0.2` or `0.1.x` version HOT 1
- NtfsFile::data string comparison is not case insensitive HOT 4
- Slice index out of bounds when parsing upcase table for malformed FS HOT 1
- Panic with malformed ntfs in non_resident_value_data_and_position HOT 4
- Infinite loop on NtfsAttributes custom iterator next HOT 3
- Crash in `Record::fixup`, `array_position_end` out of bounds of `self.data` HOT 1
- Crash on `Record::update_sequence_array_count`, substraction overflow HOT 1
- Is it safe to scan a live disk? HOT 2
- Example is outdated
- MFT may have an attribute list HOT 1
- NTFS file at byte position 0xb820fe000 has no attribute HOT 5
- PhysicalDrive0 vs C: HOT 2
- Panic on empty volume name HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ntfs.