Comments (3)
Hey @Arthur-PI! Thanks for opening this bug report.
As you already saw, I fixed it a bit differently in #23, but an explanation is still missing. So here it comes: Zero-byte seeks are totally legit and also happen very often when parsing healthy filesystems. In fact, .seek(SeekFrom::Current(0))
has been the official way to determine the current seek position in Rust for a long time until they introduced .stream_position()
in 1.51.0.
As a result, we can't fix this problem by treating zero-byte seeks as an error.
Instead, I've added code to reset stream_data_run
and data_position
when seeking beyond the data covered by Data Runs (for non-resident attributes). Previously, attributes could lie about their total length, and your test48
file did exactly that (u64::MAX
was chosen for length). This also means that the "infinite loop" was finite after all, just taking VERY long until all Data Runs were seeked (and working with a stale data_position
in the process -- definitely a serious bug!). The new code bails out early now as soon as we seeked through all available Data Runs and none is left.
Your test48
file also has a Data Run with zero cluster_count
but non-zero vcn
, which is also invalid. I've added a validation step to also return a specific error in this case.
from ntfs.
News! After some digging, turns out the problem is in the seek implementation of NtfsNonResidentAttributeValue
here :
ntfs/src/attribute_value/non_resident.rs
Lines 149 to 193 in 9348d72
And the problem is that
bytes_left_to_seek
is equal it 0 and so it does not seek a thing, so the state of NonResidentAttributeValue
never change and so on...So I have implemented a simple fix once again but I doubt that this is is the preferred solution for you, you tell me.
So my solution is to just add before the
while bytes_left_to_seek > 0
if bytes_left_to_seek == 0 {
return Err(NtfsError::NoBytesToSeekNonResidentValue {});
}
With a new custom error that need to be decide
from ntfs.
Fixed in #23
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
- Crash in `Record::fixup`, `array_position_end` out of bounds of `self.data` HOT 1
- Crash on `Record::fixup` `sector_position_end` out of bounds of data length and HOT 3
- 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.