lzip-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lzip-bug] Request for help with Windows version of Plzip.


From: Antonio Diaz Diaz
Subject: Re: [Lzip-bug] Request for help with Windows version of Plzip.
Date: Fri, 22 Jun 2018 18:03:39 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14

p.z.l wrote:
Now, I don't get why

ssize_t pread (int fd, void *buf, size_t count, __int64 offset)
{
  _lseeki64 (fd, offset, SEEK_SET);
  return read (fd, buf, count);
}

or

ssize_t pread(int fd, void *buf, size_t count, long long offset)
{
(...)
ret = ReadFile(fh, buf, (DWORD)count, &bytes, &o);
(...)
}

would work as they don't preserve file pointer, and are not thread safe either.

I guess they don't work, and you have just been lucky until now. But sooner or later the seek of one thread will be executed between the seek and the read of another thread, and corrupt data will result.

Plzip needs a thread safe pread function to guarantee safe operation, like the one defined by posix:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html
"The pread() function shall be equivalent to read(), except that it shall read from a given position in the file without changing the file offset."


Best regards,
Antonio.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]