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]

Re: [Patch] Segfault on unaligned lseek() on /dev/sdX (was: [ITP] ddrescue 1.3)


Pedro Alves wrote:
...
I'm just looking at fhandler_floopy.cc for the first time,
but, isn't there the possibility that bytes_left can be a bit too big
for alloca?

AFAIK not: bytes_left is always less than bytes_per_sector.
The _dev_floppy class is only used for Floppy (512), HD (usually 512) and CD (2048) devices.



It looks like that the raw_read call is there to
advance the position by the needed amount (moving back is forbidden
a bit above).  Perhaps it would be better to read in a loop with
read amount limited by the size of the buffer:

while more bytes
do
    read minimum of bytes left or size of buffer
    if couldn't read, bail out. (oooops internal state broken now).
done


BTW: This "oooops" may be an issue in the current code. The lseek() call returns success if raw_read() fails. This may possibly lead to undetected read errors in very rare cases.

Christian


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