Huge bug with C read() function for DOS text files

Sergey Okhapkin sos@buggy.prospect.com.ru
Sat May 2 23:00:00 GMT 1998


Daniel Sands wrote:
> I noticed while trying to modify BASH that there is a huge problem
> introduced when reading a text file which was formatted for DOS.  The
> problem is with the .DEF compiler in Bash's builtins directory.  Here's
> what happens:
>
>    1) It stats the file to get the size
>    2) It opens for text mode and reads the entire file into a buffer
>
> The read line looks like this:
>   if (read (fd, buffer, finfo.st_size) < finfo.st_size/2)
>
> The C function reads finfo.st_size bytes from the file, but then removes
> #CR bytes (the number of CR's).
>

Some time ago I sent a patch to bash maintainers to fix translation mode 
problems when reading shell scripts. The fix is included into current 
bash-2.02 release. This release is available on prep.ai.mit.edu/pub/gnu. 
The sourses are ready to compile with cygwin (including forced text mode 
for pipes :-), readline library has additional cygwin-specific command 
"paste from windows clipboard" as suggested by Chuck Bogorad.

--
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".



More information about the Cygwin mailing list