From fe652fe4a6e02041194a0f1b29a0086bd99fb14d Mon Sep 17 00:00:00 2001 From: nvs Date: Thu, 26 Apr 2018 14:51:31 -0700 Subject: Set SFileSetFilePointer error when new pointer < 0 This addresses an apparent oversight in the following commit: - 951f416398b3aa0b32969b4a391a3103443ad99e An error is not actually set, even though the return value now correctly indicates failure. Per the documentation for [`SetFilerPointer ()`][1], this should be set to `ERROR_NEGATIVE_SEEK` on Windows. On Mac/Linux, this would be `EINVAL` as per the documentation for [`fseek ()`][2]. [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365541(v=vs.85).aspx [2]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/fseek.html --- src/SFileReadFile.cpp | 1 + src/StormPort.h | 1 + 2 files changed, 2 insertions(+) (limited to 'src') diff --git a/src/SFileReadFile.cpp b/src/SFileReadFile.cpp index f91d2af..3831165 100644 --- a/src/SFileReadFile.cpp +++ b/src/SFileReadFile.cpp @@ -868,6 +868,7 @@ DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * plFilePosHi if((LONGLONG)DeltaPos < 0) { if(NewPosition > FileSize) // Position is negative + SetLastError(ERROR_NEGATIVE_SEEK); return SFILE_INVALID_POS; } diff --git a/src/StormPort.h b/src/StormPort.h index 40e418c..1da974b 100644 --- a/src/StormPort.h +++ b/src/StormPort.h @@ -211,6 +211,7 @@ #define ERROR_NOT_ENOUGH_MEMORY ENOMEM #define ERROR_NOT_SUPPORTED ENOTSUP #define ERROR_INVALID_PARAMETER EINVAL + #define ERROR_NEGATIVE_SEEK EINVAL #define ERROR_DISK_FULL ENOSPC #define ERROR_ALREADY_EXISTS EEXIST #define ERROR_INSUFFICIENT_BUFFER ENOBUFS -- cgit v1.2.3