You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will spin in a loop until it has read `remaining` bytes in total which might never happen: For one the file might have shrunk between that `fstat` and the `read` calls and on top of that some pseudo-files in Linux (especially in `/sys`) return a large `st_size` and you can't actually read any bytes. For example on my machine:
Simon Evans [15:19]
I think we should unify `NSData.readBytesFromFileWithExtendedAttributes()` and `FileHandle._readDataOfLength()` since they both duplicate each other as part of the fix for SR-8999
Lily Vulcano [15:26]
good call
perhaps NSData can just form a FileHandle and read to the end of the file.
we don’t know the length, which is the problem.
Simon Evans [15:29]
`FileHandle.readDataToEndOfFile()` should probably work
Additional Detail from JIRA
md5: fd2ac0a4981a8b2036f67f99bf55ad26
Issue Description:
There's a number of bugs in NSData's file reading code: [Its code](https://github.com/apple/swift-corelibs-foundation/blob/43ecec27e47099e49aa2e668bdb6b00cb642850c/Foundation/NSData.swift#L457-L466) relies on two things that both are not true:
How does this code rely on those untrue conditions?
This will spin in a loop until it has read `remaining` bytes in total which might never happen: For one the file might have shrunk between that `fstat` and the `read` calls and on top of that some pseudo-files in Linux (especially in `/sys`) return a large `st_size` and you can't actually read any bytes. For example on my machine:
so the file has `st_size = 4096` but
so we can't actually read anything from it... Testing this with `Foundation` shows this problem "nicely"
The text was updated successfully, but these errors were encountered: