[osx] Properly handle 0 length on Windows implementation of flocking().

This commit is contained in:
Lorenzo Cogotti 2022-12-12 19:46:30 +01:00
parent 0e3125e59c
commit 89751336d2
1 changed files with 4 additions and 0 deletions

4
osx.c
View File

@ -93,6 +93,10 @@ static int flocking(FILE *fh, int mode, __int64 ofs, __int64 len)
len = _filelengthi64(_fileno(fh));
if (len < 0)
goto fail;
len -= ofs;
if (len < 0)
len = 0;
if (len > LONG_MAX) {
errno = ERANGE;
goto fail;