From: ShadowFlare Date: Wed, 16 Jan 2013 05:49:30 +0000 (-0700) Subject: Fix SFileSetFilePointer for move methods other than FILE_BEGIN X-Git-Url: https://sfsrealm.hopto.org/projects/?a=commitdiff_plain;h=6d1c48f704d39efdcffdfc10665bdf95113e3477;p=SFmpqapi.git Fix SFileSetFilePointer for move methods other than FILE_BEGIN --- diff --git a/SFmpqapi.cpp b/SFmpqapi.cpp old mode 100644 new mode 100755 index faf2701..56cca21 --- a/SFmpqapi.cpp +++ b/SFmpqapi.cpp @@ -1136,21 +1136,18 @@ DWORD SFMPQAPI WINAPI SFileSetFilePointer(MPQHANDLE hFile, LONG lDistanceToMove, long fsz = mpqOpenFile->lpBlockEntry->dwFullSize; long cpos = mpqOpenFile->dwFilePointer; switch (dwMoveMethod) { - case FILE_BEGIN: - if (lDistanceToMove<0 || lDistanceToMove>fsz) return (DWORD)-1; - mpqOpenFile->dwFilePointer = lDistanceToMove; - break; case FILE_CURRENT: - if (lDistanceToMovefsz) return (DWORD)-1; + if (cpos + lDistanceToMove < 0 || cpos + lDistanceToMove > fsz) return (DWORD)-1; mpqOpenFile->dwFilePointer += lDistanceToMove; break; case FILE_END: - if (lDistanceToMove0) return (DWORD)-1; - mpqOpenFile->dwFilePointer = fsz+lDistanceToMove; + if (fsz + lDistanceToMove < 0 || lDistanceToMove > 0) return (DWORD)-1; + mpqOpenFile->dwFilePointer = fsz + lDistanceToMove; break; + case FILE_BEGIN: default: - if (lDistanceToMove<0 || lDistanceToMove>fsz) return (DWORD)-1; + if (lDistanceToMove < 0 || lDistanceToMove > fsz) return (DWORD)-1; mpqOpenFile->dwFilePointer = lDistanceToMove; } if (lplDistanceToMoveHigh!=0) *lplDistanceToMoveHigh = 0;