| Previous | Next |
| ERROR_DIRECT_ACCESS_HANDLE | ERROR_SEEK_ON_DEVICE |
ERROR_NEGATIVE_SEEK
Log the original offset, seek origin, and arithmetic used to compute the new position before casting types. Fix underflow or invalid relative positioning at the caller rather than clamping negative results and hiding a size-calculation bug.
The requested file position is negative
ERROR_NEGATIVE_SEEK is returned when file-position arithmetic produces an offset before byte zero. This often comes from signed underflow, subtracting a header size from a small position, or using the wrong seek origin.
Checks
- Log the current position, displacement, and seek origin.
- Validate subtraction before performing it.
- Use signed 64-bit arithmetic consistently for offsets.
- Check conversions from unsigned sizes to signed positions.
Fix
Reject or clamp invalid positions according to the file-format contract. Do not continue I/O as though the seek succeeded.
References
Looking for a different code? Search another status or error code.