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

Christian Franke Christian.Franke@t-online.de
Sat May 19 17:18:00 GMT 2007

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.


More information about the Cygwin-patches mailing list