crt: Check for underflow in _lseeki64() and fsetpos() functions
Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/stdio/_lseeki64.c b/mingw-w64-crt/stdio/_lseeki64.c
index 2408a6c..6ead4a9 100644
--- a/mingw-w64-crt/stdio/_lseeki64.c
+++ b/mingw-w64-crt/stdio/_lseeki64.c
@@ -11,7 +11,7 @@
/* Define 64-bit _lseeki64() function via 32-bit _lseek() function */
__int64 __cdecl _lseeki64(int fd, __int64 offset, int whence)
{
- if (offset > LONG_MAX)
+ if (offset < LONG_MIN || offset > LONG_MAX)
{
errno = EOVERFLOW;
return -1;
diff --git a/mingw-w64-crt/stdio/fsetpos.c b/mingw-w64-crt/stdio/fsetpos.c
index 1d3f032..4bb9e5c 100644
--- a/mingw-w64-crt/stdio/fsetpos.c
+++ b/mingw-w64-crt/stdio/fsetpos.c
@@ -14,7 +14,7 @@
{
long pos32;
- if (*_Pos > LONG_MAX)
+ if (*_Pos < LONG_MIN || *_Pos > LONG_MAX)
{
errno = EOVERFLOW;
return -1;