-
Notifications
You must be signed in to change notification settings - Fork 716
Open
Description
Violation of io.Seeker contract
According to Go's io.Seeker documentation:
Seeking to an offset before the start of the file is an error. Seeking to any positive offset may be allowed, but if the new offset exceeds the size of the underlying object, the behavior of subsequent I/O operations is implementation-dependent.
Currently, minio.Object does not respect this contract (its not possible to seek to any positive offset), making it incompatible with standard Go I/O expectations.
How to reproduce
Use tests from standard library testing/iotest. minio.Object returned by GetObject will fail on those tests.
Currently, it fails with:
Seek(-1, 1) from EOF = 0, Negative position not allowed for 1, want 39, nil
The issue likely originates here:
Line 539 in 60b85ef
| if offset < 0 && whence != 2 { |
Since testing/iotest is part of the standard Go library, this behavior prevents minio.Object from being safely used in other libraries that rely on standard I/O behavior.
Proposed solution:
// Negative offset not valid for whence of '0'.
if offset < 0 && whence == 0 {
return 0, errInvalidArgument("Negative position not allowed for 0")
}WGH-
Metadata
Metadata
Assignees
Labels
No labels