This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug in pread/pwrite ?


Hi,

After upgrading my compiler from cygwin 1.5.17-1 to 1.5.24-2,
TestDisk & PhotoRec, my GPL data recovery programs, were
unable to read data!

I have written a little program (see attachment) to reproduce
the problem. As administrator, run "test_pread /dev/sda".

The program use lseek() to go the disk end, the function failed.
Now pread will now always failed, because it ends
(cf cygwin-1.5.24-2/newlib/libc/unix/pread.c) by
an lseek to the backuped location. The same problem also applies
to pwrite.

I don't know if the following patch is a good idea:

--- cygwin-1.5.24-2/newlib/libc/unix/pread.org.c  2002-05-06 22:29:28.000000000 +0200
+++ cygwin-1.5.24-2/newlib/libc/unix/pread.c      2007-03-08 23:37:34.000000000 +0100
@@ -70,8 +70,7 @@ _DEFUN (_pread_r, (rptr, fd, buf, n, off

num_read = _read_r (rptr, fd, buf, n);

-  if (_lseek_r (rptr, fd, cur_pos, SEEK_SET) == (off_t)-1)
-    return -1;
+  _lseek_r (rptr, fd, cur_pos, SEEK_SET);

   return (ssize_t)num_read;
 }

Regards,

Christophe

--
   ,-~~-.___.     ._.
  / |  '     \    | |"""""""""|   Christophe GRENIER
 (  )         0   | |         | grenier@cgsecurity.org
  \_/-, ,----'    | |         |
     ====         !_!--v---v--"
     /  \-'~;      |""""""""|   TestDisk & PhotoRec
    /  __/~| ._-""||        |   Data Recovery
  =(  _____|_|____||________|   http://www.cgsecurity.org

Attachment: test_pread.c
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]