mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-10-10 22:38:44 +02:00
fix(fs): reject negative offsets when seeking from the start (#3633)
In plugins/fs/src/commands.rs seek, `SeekFrom::Start(offset as u64)` turned -1 into u64::MAX. The offset is now converted with u64::try_from and a negative one is an error. E2E spec added.
This commit is contained in:
1 parent
5c144e7466
commit
77d00a4f54
3 files changed
+29
-9
No files matched your search
@@ -371,6 +371,19 @@ describePlugin('fs', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('FileHandle.seek rejects a negative offset from the start', async () => {
|
||||
const message = await tauriError(async (api, path) => {
|
||||
const baseDir = api.fs.BaseDirectory.AppData
|
||||
const file = await api.fs.create(path, { baseDir })
|
||||
try {
|
||||
await file.seek(-1, api.fs.SeekMode.Start)
|
||||
} finally {
|
||||
await file.close()
|
||||
}
|
||||
}, `${dir}/seek.txt`)
|
||||
expect(message).toMatch(/must not be negative/)
|
||||
})
|
||||
|
||||
it('a closed FileHandle cannot be used again', async () => {
|
||||
const message = await tauriError(async (api, path) => {
|
||||
const baseDir = api.fs.BaseDirectory.AppData
|
||||
|
||||
Reference in new issue
Block a user