This is the mail archive of the cygwin@sourceware.cygnus.com 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]

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


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).

The bug:  Even though it removed #CR bytes, it still returns that it
read finfo.st_size bytes, and includes the #CR bytes at the end which
should have been completely thrown out.  Because of this, MKBUILTINS.C
writes extra junk to the .C file that it creates, causing a CPP error.

This is probably the reason that so many text programs do not work
anymore.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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